# Change a member's role (owner-protected)

> Change a member's role (owner-protected): CustomDomain™ API reference in the members group. Covers parameters, request body, responses and error codes.

Source: https://docs.customdomain.ai/docs/api-reference/members/updateMemberRole

## `PATCH https://api.customdomain.ai/v1/members/{id}`

Demoting the tenant's last owner is refused with 400, also when two demotions or removals of owners race each other. A 409 means the member's role changed after this request read it; reload and retry.

### Authentication

`apiKey`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### Request body (JSON)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `role` | `owner`, `admin`, `member`, `viewer` | yes |  |

### Responses

| Status | Description |
| --- | --- |
| `200` | Updated |
| `400` | Error envelope: {code, title, details}. |
| `401` | Error envelope: {code, title, details}. |
| `403` | Error envelope: {code, title, details}. |
| `404` | Error envelope: {code, title, details}. |
| `409` | Error envelope: {code, title, details}. |

### `200` response body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `tenant_id` | string | yes |  |
| `email` | string | yes |  |
| `role` | `owner`, `admin`, `member`, `viewer` | yes |  |
| `status` | `active`, `pending`, `expired` | yes | `active` once accepted, `pending` while the invite link works, `expired` once it has lapsed. |
| `invited_by` | string | no | The accepting user's id in the calling application, when one was supplied at accept. |
| `inviter_email` | string | no | Who sent (or last re-sent) the invite, resolved from the sending credential. |
| `inviter_name` | string | no | The sender's display name, when one was supplied. |
| `invite_sent_at` | string | no | When the current invite link was issued. |
| `invite_expires_at` | string | no | When the current invite link stops working. Absent for members never invited by link. |
| `invite_token` | string | no | The single-use invite token. Present only in the invite, resend and get-invite responses, never in the roster. |
| `accepted_at` | string | no |  |
| `created_at` | string | yes |  |

The full specification is served at `GET https://api.customdomain.ai/v1/openapi.json`.
