Get a user's direct roles
GET /v1/users/{user_id}/roles · permission users:read
Returns the environment roles assigned directly to the user. Roles of organization memberships are not included; read the membership for them.
Request
| Field | Type | Required | Description |
|---|---|---|---|
user_id |
path | yes | User ID (usr_…). |
No request body.
Response
200 OK with the role IDs.
{
"role_ids": [
"rol_01j9xr7s1t2w6x8y0z2a4b6c8e"
]
}
Errors
| HTTP | code | When |
|---|---|---|
| 404 | not_found |
The user does not exist in this environment. |
| 401 | unauthenticated |
The credential is missing, invalid or revoked. |
| 403 | insufficient_permissions |
The credential lacks the required permission. |
| 429 | rate_limited |
The rate limit was exceeded; retry after the Retry-After period. |
| 503 | service_unavailable |
A dependency is temporarily unavailable; retry after the Retry-After period. |
Example
curl -i -X GET "https://api.eu.keenauth.com/v1/users/usr_01j9xh2k6p7q1r3s5t7v9w1x3y/roles" \
-H "Authorization: Bearer $KEENAUTH_SECRET_KEY"