
# Replace the permissions of an organization role

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

Replaces the organization role's permission set (at most 100). Every permission must be on the environment's organization custom role list (`GET /v1/org-custom-role-permissions`), otherwise `permission_not_allowed`. Organization roles need the `org_custom_roles` plan feature (Business) and the environment setting `org_custom_roles_enabled`. `If-Match` is optional. The change is audited as `role.updated` with `change=permissions`.

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `org_id` | path | yes | Organization ID (`org_…`). |
| `role_id` | path | yes | Role ID (`rol_…`) of a role of this organization. |
| `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 100. |

## Response

`200 OK` with the role and its `ETag`.

```json
{
  "id": "rol_01j9xr7s1t2w6x8y0z2a4b6c8e",
  "organization_id": "org_01j9xk3m7q8r2s4t6v8w0y2z4a",
  "key": "billing",
  "name": "Billing",
  "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 |
|---|---|---|
| 403 | `org_custom_roles_disabled` | Organization roles are turned off for the environment. |
| 403 | `plan_feature_unavailable` | The plan does not include `org_custom_roles`. |
| 404 | `not_found` | The organization or role does not exist, or the role belongs to another organization. |
| 412 | `precondition_failed` | `If-Match` does not match the current version. |
| 422 | `permission_not_allowed` | A permission is not on the organization custom role list. |
| 422 | `validation_failed` | `permission_ids` is missing, has a malformed or unknown ID, a duplicate or more than 100 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

```bash
curl -i -X PUT "https://api.eu.keenauth.com/v1/organizations/org_01j9xk3m7q8r2s4t6v8w0y2z4a/roles/rol_01j9xr7s1t2w6x8y0z2a4b6c8e/permissions" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"permission_ids":["perm_01j9xs0a2b4c6d8e0f2g4h6j8k"]}'
```
