Skip to content

User Attributes

User attributes are per-user key-value metadata stored alongside the user record. Attributes are opaque strings — Kotauth does not interpret the values. When combined with claim mappers, attributes can be projected into JWT access and ID tokens.

Required scopes: user_attributes:read for GET, user_attributes:write for PUT and DELETE.


{
"attributes": {
"plan": "enterprise",
"department": "engineering",
"employee_id": "E-4217"
}
}
FieldTypeDescription
attributesobjectKey-value map of all attributes for the user

Attribute keys are limited to 64 characters. Values are limited to 1024 characters.


GET /t/{slug}/api/v1/users/{userId}/attributes

Returns all attributes for the specified user as a key-value map.

Path parameters:

ParameterTypeDescription
userIdintegerThe user’s numeric ID

Example request:

Terminal window
curl https://auth.yourdomain.com/t/my-app/api/v1/users/42/attributes \
-H "Authorization: Bearer kauth_my-app_KEY"

Response 200 OK:

{
"attributes": {
"plan": "enterprise",
"department": "engineering"
}
}

PUT /t/{slug}/api/v1/users/{userId}/attributes/{key}

Creates the attribute if it does not exist, or updates it if it does. This is an upsert operation.

Path parameters:

ParameterTypeDescription
userIdintegerThe user’s numeric ID
keystringAttribute key (max 64 characters)

Request body:

{
"value": "enterprise"
}
FieldTypeRequiredDescription
valuestringYesAttribute value (max 1024 characters)

Example request:

Terminal window
curl -X PUT https://auth.yourdomain.com/t/my-app/api/v1/users/42/attributes/plan \
-H "Authorization: Bearer kauth_my-app_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "enterprise"}'

Response 204 No Content

Error responses:

StatusCondition
404 Not FoundUser does not exist in this workspace
422 Unprocessable EntityKey exceeds 64 characters or value exceeds 1024 characters

DELETE /t/{slug}/api/v1/users/{userId}/attributes/{key}

Removes the attribute from the user. If a claim mapper references this key, the claim will no longer appear in newly issued tokens.

Path parameters:

ParameterTypeDescription
userIdintegerThe user’s numeric ID
keystringAttribute key to delete

Example request:

Terminal window
curl -X DELETE https://auth.yourdomain.com/t/my-app/api/v1/users/42/attributes/plan \
-H "Authorization: Bearer kauth_my-app_KEY"

Response 204 No Content

Error responses:

StatusCondition
404 Not FoundUser or attribute does not exist