Welcome to the Kinde community

Updated 6 days ago

Handling user creation errors when using the management api

When creating a user through the management API I could have sworn I've seen the error "USER_ALREADY_EXISTS", I even have the check in my code. However I can't seem to recreate this error response in any way when i create users with existing information. I've tried a simple create user with given name, family name and email, the exact same request done twice doesn't result in already exist, but just a generic ERROR_CREATING_IDENTITY USER_NOT_CREATED. How am I supposed to best know if creating a user fails due to the user already existing? Do I have to use get GET /users endpoint and filter by email? Feels heavy-handed

D
J
4 comments

Hi there, sounds like this should be returning the original error you referenced, we'll look into this for you

Thanks for the quick reply David!

Could you provide a sample request you're making please, there might be an issue with your payload or a scenario we're not catching.

Testing the following in postman:

{
  "profile": {
    "given_name": "Simple",
    "family_name": "Test"
  },
  "identities": [
    {
      "type": "email",
      "details": {
        "email": "simple@test.com"
      }
    }
  ]
}

Gives the following response:
{
    "errors": [
        {
            "code": "USER_ALREADY_EXISTS",
            "message": "An existing user was found against the identity data provided."
        }
    ]
}

If there's an issue with your identity structure the error responses you provided could occur.

This is curious. With your input I do get the user exist error. I'll send you the exact input I use in PM in case it matters

Add a reply
Sign up and join the conversation on Slack