> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/cookbooks/platform-admin/give-people-access/change-someones-access.md).

# Change a user's roles

Add or remove roles on an existing user record, and what that affects.

`PATCH /users/{id}` updates a user record, including their role assignment. This is the API equivalent of [Change a user's roles](https://docs.uptiq.ai/platform-guides/admin/give-people-access/change-a-users-roles).

## At a glance

| Item            | Value                                           |
| --------------- | ----------------------------------------------- |
| ⚙️ Microservice | `Identity Hub`                                  |
| 🌍 Environment  | `QA`                                            |
| 🔗 Base URL     | `https://api-builder-qa.uptiq.dev/identity-hub` |
| ⌘ Endpoint      | `PATCH /users/{id}`                             |

{% columns %}
{% column %}

#### What it does

Replaces a user's role assignments in the account.
{% endcolumn %}

{% column %}

#### Success looks like

The service returns `200 OK` with the updated user record.
{% endcolumn %}
{% endcolumns %}

## Before you start

| You need                      | Why                                                                              |
| ----------------------------- | -------------------------------------------------------------------------------- |
| 🔑 **Manage user** capability | Authorizes the request (`ManageUser`).                                           |
| 🆔 `User ID`                  | Identifies the account member. Call `GET /users` when you only have their email. |
| 🆔 Complete `roleIds` list    | The request replaces existing roles. It does not add to them.                    |

## Request

`PATCH /users/{id}`

| Field         | Type   | Required | What it does                                                |
| ------------- | ------ | -------- | ----------------------------------------------------------- |
| `roleIds`     | array  | No       | The complete new set of role IDs. Replaces, does not merge. |
| `firstName`   | string | No       |                                                             |
| `lastName`    | string | No       |                                                             |
| `phoneNumber` | string | No       |                                                             |

{% hint style="danger" %}
**`roleIds` is a replacement, not a patch.** Sending `["role_auditor"]` when the person also held `role_developer` removes the developer role. Fetch the user's current `roleIds` with `GET /users/{id}` first if you're adding to the set rather than setting it from scratch.
{% endhint %}

## Code snippets

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X PATCH https://api-builder-qa.uptiq.dev/identity-hub/users/USER_ID \
  -H "x-platform-key: YOUR_API_KEY" \
  -H "accountid: YOUR_ACCOUNT_ID" \
  -H "content-type: application/json" \
  -d '{ "roleIds": ["role_developer", "role_auditor"] }'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const res = await fetch(`https://api-builder-qa.uptiq.dev/identity-hub/users/${userId}`, {
  method: "PATCH",
  headers: {
    "x-platform-key": process.env.UPTIQ_API_KEY,
    accountid: process.env.UPTIQ_ACCOUNT_ID,
    "content-type": "application/json",
  },
  body: JSON.stringify({ roleIds: ["role_developer", "role_auditor"] }),
});
const { data } = await res.json();
```

{% endtab %}

{% tab title="Python" %}

```python
import os, requests

res = requests.patch(
    f"https://api-builder-qa.uptiq.dev/identity-hub/users/{user_id}",
    headers={
        "x-platform-key": os.environ["UPTIQ_API_KEY"],
        "accountid": os.environ["UPTIQ_ACCOUNT_ID"],
    },
    json={"roleIds": ["role_developer", "role_auditor"]},
)
```

{% endtab %}
{% endtabs %}

## Response

| Result     | What it means                                 | Next action                                            |
| ---------- | --------------------------------------------- | ------------------------------------------------------ |
| ✅ `200 OK` | `data` contains the full updated user record. | Re-fetch the user and verify the final `roleIds` list. |

{% hint style="success" %}
**Verified against QA on 22 September 2026.** Field names and nesting below are exactly as returned; identifiers and personal data are placeholders.
{% endhint %}

```json
{
  "message": "User updated successfully",
  "data": {
    "id": "571781cc-f16d-4652-9042-3ef90e82efc4",
    "email": "new.person@example.com",
    "firstName": "Alex",
    "lastName": "Chen",
    "accessCode": null,
    "initialAuthMethod": "Pending",
    "onboarding": { "details": {}, "isPending": true },
    "roleIds": [],
    "utmParams": null,
    "createdAt": "2026-09-22T14:32:05.234Z",
    "createdBy": "system",
    "updatedAt": "2026-09-22T14:32:07.263Z",
    "updatedBy": "system",
    "isOnboardingPending": true
  }
}
```

{% hint style="warning" %}
**`roleIds` came back empty in the response even though the request set it.** Observed on QA against a user still in the Invited state. Do not treat the echoed `roleIds` as confirmation that the change applied — re-fetch with `GET /users/{id}` and check there before reporting success.
{% endhint %}

## Developer notes

| Situation                                | What to do                                                                                                                                                                                        |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ⚠️ You need to reduce access             | Send the smaller `roleIds` list. There is no separate remove-role call.                                                                                                                           |
| ⚠️ A permission remains                  | Check whether another role still grants it. Permissions accumulate with no deny rule. See the [Permission reference](https://docs.uptiq.ai/platform-guides/admin/reference/permission-reference). |
| ⚠️ The user belongs to multiple accounts | This request only affects the account in the `accountid` header.                                                                                                                                  |

## Related

| Related cookbook                                                                                             | When to use it                             |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| [Change a user's roles](https://docs.uptiq.ai/platform-guides/admin/give-people-access/change-a-users-roles) | Use the Control Center instead of the API. |
| [Invite a user](/cookbooks/platform-admin/give-people-access/invite-someone.md)                              | Create the user before assigning roles.    |
| [Remove a user's access](/cookbooks/platform-admin/give-people-access/remove-someones-access.md)             | Offboard the person.                       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uptiq.ai/cookbooks/platform-admin/give-people-access/change-someones-access.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
