---
title: "Update a sub-user"
method: PUT
path: "/sub-users/{subUserId}"
tags: ["Sub-User Management"]
---

# Update a sub-user

`PUT /sub-users/{subUserId}`

## Request

- Base URL: `https://api.chat-data.com/api/v2`
- URL: `https://api.chat-data.com/api/v2/sub-users/{subUserId}`
- Auth: HTTP bearer

Update an existing sub-user's name, password, chatbot assignments, permissions or analytics dashboard sections. Only provided fields are updated; omitted fields remain unchanged.

Requires the SSO Login add-on (see [plans](/pricing)) and a workspace API key; without the add-on, or with a chatbot-scoped key, the request gets a 403.

To remove a sub-user's password (disabling password login), send:
```json
{
  "removePassword": true
}
```

## Path parameters

- `subUserId` string, required

## Request body

- object
  - `name` string: Updated display name. HTML tags are stripped.
  - `password` string: New password. It must meet the same complexity requirements as on creation. If both `password` and `removePassword` are sent, `password` wins and the new password is set.
  - `removePassword` boolean: Set to `true` to remove the sub-user's password, disabling password login. Ignored when `password` is also sent.
  - `chatbotIds` string[]: Updated chatbot assignments; replaces the current list. All IDs must belong to chatbots in your workspace. Duplicates are automatically removed.
  - `permissions` string[]: Updated permissions; replaces the current list. Invalid values are removed, and at least one valid permission is required.
  - `analyticsDashboardSections` string[]: Updated analytics dashboard sections; replaces the current list. Unknown section names are ignored.

## Response `200`

Sub-user updated successfully.

- SubUserObject
  - `_id` string, required: The unique identifier of the sub-user.
  - `company` string, required: The ID of the company this sub-user belongs to.
  - `email` string, email, required: The sub-user's email address.
  - `name` string: The sub-user's display name.
  - `avatar` string: URL of the sub-user's avatar image, or an empty string if none is set.
  - `chatbotIds` object[], required: The assigned chatbots, each with its `_id` and `name`.
    - `_id` string: The chatbot ID.
    - `name` string: The chatbot name.
  - `permissions` string[], required: Permissions granted to this sub-user.
  - `analyticsDashboardSections` string[]: Analytics dashboard sections visible to this sub-user.
  - `hasPassword` boolean, required: Whether the sub-user has a password configured (the actual password is never returned).
  - `hasGoogle` boolean, required: Whether the sub-user has signed in with a linked Google account (the Google ID is never returned). It stays `false` when Google sign-in is only enabled.
  - `createdAt` string, date-time: Timestamp when the sub-user was created.
  - `lastLoginAt` string, date-time: Timestamp of the sub-user's last sign-in. Absent until they first sign in.

## Other responses

- `400`: The sub-user could not be updated. For example: the workspace has no SSO company, `chatbotIds` is empty or contains an ID that is not a chatbot in your workspace, `name` is not a string or is longer than 100 characters, the password is too weak, `permissions` is empty or contains no valid permission, or `analyticsDashboardSections` is not an array.
- `401`: Authentication failed: the `Authorization` header is missing or not in the `Bearer <key>` format, the API key does not exist, its workspace is unavailable or has no owner, or the workspace's plan does not include API access. `message` says which.
- `403`: The request used a chatbot-scoped API key (`This operation requires a user-level API key, not a chatbot-specific key`, with `status: error`), or the workspace does not have the SSO Login add-on (`SSO Login is unavailable with your current plan`, with no `status` field).
- `404`: `subUserId` is not a valid ID, or the company has no sub-user with this ID.
- `429`: The workspace sent more than 600 API requests in the last minute. Wait the number of seconds given in the `Retry-After` header (and in `message`) before retrying.
- `500`: An unexpected error occurred while processing the request; `message` contains the error.

---

[API](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide.md) · [All operations](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/llms.txt) · [OpenAPI document](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/revisions/72871007f7f0?raw)
