Create an environment role

POST /v1/roles · permission roles:write

Creates a role in the environment's role catalogue. The response carries an ETag; the write is audited as role.created. Idempotency-Key is optional.

Request

Field Type Required Description
key string yes Lowercase letters, digits, _ and -; 1–64 characters; unique in its scope and immutable.
name string yes Display name, up to 128 characters.
description string no Up to 1024 characters.
is_privileged boolean no Marks a privileged role: in self-service only a member holding the organization admin role (org_admin_role_id) can assign it, and mapping an external group to it requires roles:write and approval.
assignable_in_self_service boolean no Defaults to true, also for a privileged role.

Response

201 Created with the role.

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

Errors

HTTP code When
409 role_key_conflict A role with this key already exists in the scope.
409 role_limit_reached The limit of 1,000 environment roles or 50 roles per organization is reached.
422 validation_failed A field is missing or invalid.
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 POST "https://api.eu.keenauth.com/v1/roles" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key":"support","name":"Support"}'