# Create user via Rest api

**URL:** <https://forum.keycloak.org/t/create-user-via-rest-api/4859>\
**Category:** Getting advice\
**Tags:** admin-console\
**Created:** [September 14, 2020, 8:35am UTC](https://forum.keycloak.org/t/create-user-via-rest-api/4859 "2020-09-14T08:35:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![huneau](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/huneau/32/1372_2.png) [@huneau](https://forum.keycloak.org/u/huneau)\
**Post date:** [September 14, 2020, 8:35am UTC](https://forum.keycloak.org/t/create-user-via-rest-api/4859/1 "2020-09-14T08:35:29Z")

</div>

Hello,

Im Stuck on the Realm Management configuration / user creation.

I have a Service in a Bearer-only mode that calls the keycloak rest api to create a new user.  
Then I created a `Registration access token` and I put it in side my app

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/1/1ef9039a9b20bcabb4d4da56bbf54b537b95aaab.png)  
Then, try it inside my app, I do the following things :

```java
Response response = client.target("https://myhost.com/auth/admin").path("realms").path("myrealm").path("users")
.request(MediaType.APPLICATION_JSON_TYPE)
.header("Authorization", "Bearer " + bearer) //where bearer is the `Registration access token`
.post(Entity.entity(new User("to...@toto.toto"), MediaType.APPLICATION_JSON_TYPE));
System.out.println(response.readEntity(String.class));

```

And I get the following response:

`<html><head><title>Error</title></head><body>403 - Forbidden</body></html>`

For me 401 mean : Im authenticate but the resources is not under my permission  
403 mean : Im not authenticate and try to access protected resources  
Maybe I dont have the right token, and I need to ask for a token but when I do it I have a response like `bearer-only not allowed`  
Or maybe I dont have the correct right inside Realm management, So I try to add it everywhere inside client/realm-management/Authorization/permissions but the same issue occurs

Have you ideas ?

Best Regards,

Romain.

---

<div class="post-metadata">

**Author:** ![diegosm](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/diegosm/32/1850_2.png) [@diegosm](https://forum.keycloak.org/u/diegosm)\
**Post date:** [December 8, 2020, 7:14pm UTC](https://forum.keycloak.org/t/create-user-via-rest-api/4859/2 "2020-12-08T19:14:05Z")

</div>

Hi,

First, how you’re authenticating the client?  
You need to verify if the user at token that you’re providing has permissions to create users, such admin or realm-management.

Go to clients \> (Current client that generate the token) \> Roles
