Replace the permissions of an environment role

PUT /v1/roles/{role_id}/permissions · permission roles:write

Replaces the role's permission set with permission_ids (the full set; an empty array removes all permissions; order does not matter). An environment role holds at most 500 permissions. The role that organizations use as their admin role must keep every system permission (permission_reserved). If-Match is optional; when given it must match the current ETag. Writing the same set again changes nothing and keeps the version. The change is audited as role.updated with change=permissions, and tokens issued after it carry the new permissions.

Request

Field Type Required Description
role_id path yes Role ID (rol_…).
If-Match header no Current ETag; 412 when it does not match.
permission_ids string[] yes The full set of permission IDs (perm_…), at most 500.

Response

200 OK with the role and its ETag.

{
  "id": "rol_01j9xr7s1t2w6x8y0z2a4b6c8e",
  "organization_id": null,
  "key": "support",
  "name": "Support",
  "description": "",
  "is_privileged": false,
  "assignable_in_self_service": true,
  "permission_ids": [
    "perm_01j9xs0a2b4c6d8e0f2g4h6j8k",
    "perm_01j9xs0a2b4c6d8e0f2g4h6j8m"
  ],
  "created_at": "2026-10-12T09:31:00.123456Z",
  "updated_at": "2026-10-12T10:00:00Z",
  "version": 2
}

Errors

HTTP code When
404 not_found The role does not exist in this environment.
412 precondition_failed If-Match does not match the current version.
422 permission_reserved The role is the organization admin role and the set drops a system permission.
422 validation_failed permission_ids is missing, has a malformed or unknown ID (unknown_permission), a duplicate or more than 500 items.
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 PUT "https://api.eu.keenauth.com/v1/roles/rol_01j9xr7s1t2w6x8y0z2a4b6c8e/permissions" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H 'If-Match: "1"' \
  -H "Content-Type: application/json" \
  -d '{"permission_ids":["perm_01j9xs0a2b4c6d8e0f2g4h6j8k","perm_01j9xs0a2b4c6d8e0f2g4h6j8m"]}'