Create a realm user
const url = 'http://localhost:8000/clusters/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/realms/customer-portal/users';
const options = {
method: 'POST',
headers: {
'API-Version': '2026-06-01.beta',
'API-Key': '<API-Key>',
'Content-Type': 'application/json'
},
body: '{"username":"john.doe","email":"john@example.com","first_name":"John","last_name":"Doe","temporary_password":"ChangeMe123","enabled":true,"roles":["admin"]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}curl --request POST \
--url http://localhost:8000/clusters/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/realms/customer-portal/users \
--header 'API-Key: <API-Key>' \
--header 'API-Version: 2026-06-01.beta' \
--header 'Content-Type: application/json' \
--data '{ "username": "john.doe", "email": "john@example.com", "first_name": "John", "last_name": "Doe", "temporary_password": "ChangeMe123", "enabled": true, "roles": [ "admin" ] }'Creates a user in the specified realm.
Required scope: realm-users:write
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Keycloak realm name (not ID). Must start with a letter; allows letters, digits, and hyphens.
Example
customer-portalHeader Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Request body for creating a realm user.
object
Example
john.doeExample
john@example.comExample
JohnExample
DoeInitial password set for the user. Must be at least 8 characters.
Additional constraints are enforced by the realm’s Keycloak password policy at the time
of creation (e.g. minimum uppercase/lowercase/digit/special-character counts, disallow
reuse, disallow username/email as password). Password policy violations return 422
with a message describing the specific rule that was not met.
Example
ChangeMe123Whether the user can sign in immediately after creation.
Example
trueRealm roles to assign after the user is created.
Example
[
"admin"
]Example
{
"username": "john.doe",
"email": "john@example.com",
"first_name": "John",
"last_name": "Doe",
"temporary_password": "ChangeMe123",
"enabled": true,
"roles": [
"admin"
]
}Responses
Section titled “Responses”The request has succeeded and a new resource has been created as a result.
Public representation of a realm user.
object
Whether the user can sign in.
Whether the email address has been verified.
Organization associated with the user, when available.
Most recent successful sign-in time, when available.
Time when the user was created, when available.
Example
{
"id": "9f3f2e5c-9e3d-4b1d-9f53-2a8af5a5d9a1",
"username": "john.doe",
"email": "john@example.com",
"first_name": "John",
"last_name": "Doe",
"enabled": true,
"email_verified": true,
"organization": "Acme Corp"
}Access is unauthorized.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Access is forbidden.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}The server cannot find the requested resource.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}The request conflicts with the current state of the server.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Client error
object
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com",
"errors": [
{
"field": "example",
"detail": "example",
"code": "example",
"value": "example"
}
]
}Client error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Headers
Section titled “Headers”Server error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Server error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}