KindeK
Kinde2y ago
14 replies
Kenton

Kinde Management API - 400 Bad Request: malformed Host header

I am trying to create an Organization and move a user that's in the Default Organization into it using the Kinde Management API; however, I am getting the error:
Error creating organization or adding user: A [ApiError]: Error creating user.
    at xt (webpack-internal:///(rsc)/./node_modules/@kinde/management-api-js/dist/kinde-management-api-js.cjs:1:25453)
    at eval (webpack-internal:///(rsc)/./node_modules/@kinde/management-api-js/dist/kinde-management-api-js.cjs:1:26058)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  url: 'https://{your_subdomain}.kinde.com/api/v1/organization',
  status: 400,
  statusText: 'Bad Request: malformed Host header',
  body: '400 Bad Request: malformed Host header',
  request: {
    method: 'POST',
    url: '/api/v1/organization',
    body: { name: 'test-org', handle: 'test-org' },
    mediaType: 'application/json',
    errors: {
      '400': 'Error creating user.',
      '403': 'Invalid credentials.',
      '429': 'Request was throttled.',
      '500': 'Could not create organization.'
    }
  }
}


I started by trying to enable Kinde Management API in the Kinde Console for my NextJS app but got the error:
"m2m applications can have access the kinde management api"

So I create a M2M application, added the following env variables:
KINDE_DOMAIN=https://my-handle.kinde.com
KINDE_MANAGEMENT_CLIENT_ID=m2m-application-client-id
KINDE_MANAGEMENT_CLIENT_SECRET=m2m-application-client-secret
Was this page helpful?