Register user using Rest Api in keycloak

I want to know how can I register user using rest api.
I am calling api http://localhost:8080/auth/realms/test/users to register user.
but I am not able to get response.

You can create a new user using the REST API. Documentation is here: Keycloak Admin REST API

Your path looks wrong. Should be http://localhost:8080/auth/admin/realms/test/users

Thanks for the quick response.
However I tried running the api http://localhost:8080/auth/admin/realms/test/users in postman. I am getting error as below.

"error": "unknown_error"


Looks right. A few things:

  1. try with header accept: application/json
  2. try with a minimal user, as it may not like you setting fields that get set automatically. E.g. {"enabled":true,"attributes":{},"groups":[],"email":"","emailVerified":"","firstName":"John","lastName":"Doe"}
  3. check your server logs

Thank you xgp :star_struck:

it worked perfect. Included username in data and done :clap:
Thanks :slight_smile:

user got created:

1 Like

How do I register using password in this data . I need password to login, but when I create user mentioning password, but i am getting below error saying ‘password policy not met’.

I don’t know if it works in the same request as the user creation. I’ve never tried that. I use:

Also, that’s a legitimate error if you have a password policy set on your realm. Check in the “Authentication”->“Password Policy” page of the admin.

It is working…the issue got resolved.
I have passed credentials this way
“credentials”: [{
“type”: “password”,
“value”: “Johndoe@1234”,
“temporary”: false

It worked.
But I am facing cors error.
The resources that I have passed looks correct.
Not sure what might be causing the cors error.
Can you suggest anything on it?


I have registered user using rest api /users.
But the saved data is invalid for login.
Can you suggest something about why it is Invalid when I try to login with the registered user ?