> ## Documentation Index
> Fetch the complete documentation index at: https://docs.connectly.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a User's Role

> Change what a user can access in your business 🔁

## Endpoint

```json theme={null}
PATCH https://api.connectly.ai/external/v1/businesses/{businessId}/users/{userId}
```

| Parameter | Location | Description |
| - | - | - |
| `businessId` | Path | Your Connectly business ID. |
| `userId` | Path | The user's `id`. |
| `X-API-Key` | Header | A [User Management key](https://docs.connectly.ai/user-management-api/overview.md#get-an-api-key). |

***

## Request body

```json theme={null}
{
  "role": "ROLE_MARKETING"
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `role` | string | Yes | `ROLE_MARKETING`, `ROLE_ANALYTICS` or `ROLE_AGENT`. |

***

## Response

The API returns HTTP `200` with the user as changed:

```json theme={null}
{
  "entity": {
    "id": "2438ac3c-37eb-4902-adef-ed16b4431030",
    "email": "ana@example.com",
    "displayName": "Ana Souza",
    "role": "ROLE_MARKETING"
  }
}
```

The new role applies from the user's next request.

***

## Error responses

| HTTP status | `errorCode` | Meaning |
| - | - | - |
| `400` | `PRFL.USR.OWNER_PROTECTED` | The user is an Owner, or `role` is `ROLE_OWNER`. Change Owners in the dashboard. |
| `400` | | `role` is missing or unknown. |
| `404` | `PRFL.NOT_FOUND` | The user is not a current user of the business. |

See [Errors](https://docs.connectly.ai/user-management-api/overview.md#errors) for the responses every endpoint can return.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.