
# Approve a role mapping

`POST /v1/connections/{connection_id}/role-mappings/{mapping_id}:approve` · permissions `connections:write` and `roles:write`

Approves a mapping whose role became privileged after the mapping was created; after approval, sign-in grants the role again. Requires `roles:write` in addition to `connections:write`. A mapping to a non-privileged role needs no approval (`409 conflict`); approving an approved mapping changes nothing. The write is audited as `role_mapping.approved`.

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `connection_id` | path | yes | Enterprise connection ID (`conn_…`). |
| `mapping_id` | path | yes | Role mapping ID (`rmp_…`). |

No request body.

## Response

`200 OK` with the approved mapping.

```json
{
  "id": "rmp_01j9xw0x4y5z9a1b3c5d7e9f1h",
  "connection_id": "conn_01j9xp6q0r1s5t7v9w1x3y5z7b",
  "organization_id": "org_01j9xk3m7q8r2s4t6v8w0y2z4a",
  "external_group_key": "cn=engineering,ou=groups,dc=example,dc=com",
  "role_id": "rol_01j9xr7s1t2w6x8y0z2a4b6c8e",
  "role_privileged": true,
  "approved_at": "2026-10-12T09:31:00.123456Z",
  "created_at": "2026-10-12T09:31:00.123456Z"
}
```

## Errors

| HTTP | code | When |
|---|---|---|
| 404 | `not_found` | The mapping does not exist on this connection. |
| 403 | `privileged_role_mapping_forbidden` | The credential lacks `roles:write`. |
| 409 | `conflict` | The mapped role is not privileged, so there is nothing to approve. |
| 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 POST "https://api.eu.keenauth.com/v1/connections/conn_01j9xp6q0r1s5t7v9w1x3y5z7b/role-mappings/rmp_01j9xw0x4y5z9a1b3c5d7e9f1h:approve" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"
```
