# Creating user via API with hashedSaltedValue

**URL:** <https://forum.keycloak.org/t/creating-user-via-api-with-hashedsaltedvalue/289>\
**Category:** Getting advice\
**Created:** [November 1, 2019, 2:04pm UTC](https://forum.keycloak.org/t/creating-user-via-api-with-hashedsaltedvalue/289 "2019-11-01T14:04:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASTP001](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/astp001/32/107_2.png) [@ASTP001](https://forum.keycloak.org/u/ASTP001)\
**Post date:** [November 1, 2019, 2:04pm UTC](https://forum.keycloak.org/t/creating-user-via-api-with-hashedsaltedvalue/289/1 "2019-11-01T14:04:28Z")

</div>

Hello,

I am trying to migrate users from a PostgreSQL table into KeyCloak. I figured it could be possible to create users in KeyCloak using the following REST endpoint: `auth/admin/realms/{realm}/users`

Currently I am able to create a user if I simply pass in the username. However, I would like to also be able to migrate their credentials, so I pass a JSON to that endpoint that looks something like this:

```
{
    "username": "test_user",
    "enabled": true,
    "credentials": [{
        "algorithm": "sha-1",
        "hashedSaltedValue": "4e8dc328ace9d8fd9048c40696461465bf16798b"
    }]
}

```

When I do this, the request goes through successfully with status code 201. However, I am unable to log in as this user, and if I try to list users either using the REST endpoint or through the admin panel I receive this error `{"error":"unknown_error"}` I am also unable to get details on this user directly, and I am also unable to delete this user.

Subsequently, I passed in `"type"` to the credential representation, and this time I was able to access the user through the admin interface, however I am unable to login using the appropriate password.

1. It would be ideal if a system breaking request would be rejected instead of returning 201.
2. Currently everything in the credential representation is marked as optional according to this doc ([https://www.keycloak.org/docs-api/7.0/rest-api/index.html#\_credentialrepresentation](https://www.keycloak.org/docs-api/7.0/rest-api/index.html#_credentialrepresentation)) could this be updated to reflect reality?

Asides from that, could someone tell me how to properly create a new user given the hashedSaltedValue, or otherwise?

Thank you!

---

<div class="post-metadata">

**Author:** ![SSR](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@SSR](https://forum.keycloak.org/u/SSR)\
**Post date:** [November 25, 2019, 7:51pm UTC](https://forum.keycloak.org/t/creating-user-via-api-with-hashedsaltedvalue/289/2 "2019-11-25T19:51:21Z")

</div>

Hi ASTP001,

From what I gather, its not possible to do that yet with Keycloak. To get around it I’m putting the credentials directly into the CREDENTIAL table after creating the user.

Regards,

Stuart.
