Set createdTImestamp field on User

1,105 views
Skip to first unread message

Bruno Parmentier

unread,
Feb 7, 2022, 12:58:50 PM2/7/22
to Keycloak User
Hi,

I'm using Keycloak 16 Admin REST API to create users with the createdTimestamp field set to a specific value (I'm importing them from another database). However this field seems to be read-only since when I open the users in Keycloak, the Created At entry shows the date and time of the request and not the value I've set.

Is this a wanted behaviour and is there an alternative way to set this this field other than using SQL? Otherwise my workaround will be to set the field in a custom attribute but I'd prefer not to, if possible.

This is the request I used:

curl --location --request POST 'http://127.0.0.1:8180/auth/admin/realms/myrealm/users' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
        "createdTimestamp": 1640995200000,
        "username": "myuser",
        "email": "myu...@example.com"
    }'

Created At shows: 2/7/22 6:41:50 PM

This is what is stored in Keycloak's database:

keycloak=# select created_timestamp from user_entity where username = 'myuser';
 created_timestamp
-------------------
     1644255710030
(1 row)


If this field is indeed read-only, couldn't it be marked as such in the documentation? https://www.keycloak.org/docs-api/16.0/rest-api/index.html#_userrepresentation

Regards,

Bruno Parmentier
Reply all
Reply to author
Forward
0 new messages