# Delete a sub-user

`DELETE https://api.chat-data.com/api/v2/sub-users/{subUserId}`

Canonical: https://www.chat-data.com/api-reference/delete-sub-user

## Authentication

Send an API key as a Bearer token: `Authorization: Bearer $CHAT_DATA_API_KEY`. Workspace keys reach every chatbot in the workspace; chatbot-scoped keys reach only their chatbot. Keep keys on the server.

## Description

Delete a sub-user from the company. This also revokes any outstanding magic link or password setup tokens for the sub-user.

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.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| subUserId | path | string | yes | The unique identifier of the sub-user to delete. |

## Example request

```bash
curl -X DELETE 'https://api.chat-data.com/api/v2/sub-users/6650f1c2a9e4b83d2c7a1f9a' \
  -H "Authorization: Bearer $CHAT_DATA_API_KEY"
```

## Example response (200)

```json
{
  "status": "ok"
}
```

## Responses

| Status | Description |
| --- | --- |
| 200 | Sub-user deleted successfully. |
| 400 | The workspace has no SSO company. |
| 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. |
