<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/online-api/conversations/set-conversation-labels

# Set Conversation Labels

`POST https://online.99digital.co.il/api/v1/accounts/{account_id}/conversations/{conversation_id}/labels`

Add labels to a conversation.

:::note

Using this request will overwrite the existing list of labels associated to
the conversation: labels you leave out are removed. Send the full list — or
`[]` to remove every label.

:::

To add or remove single labels without sending the full list, use
[Bulk Update Conversations](https://docs.99digital.co.il/online-api/conversations/bulk-update-conversations)
with `labels.add` / `labels.remove`. The labels themselves are managed with
the [Labels](https://docs.99digital.co.il/online-api/labels/list-labels) endpoints.

**Settings:**

| Setting | Value |
| --- | --- |
| URL | `https://online.99digital.co.il/api/v1/accounts/{account_id}/conversations/{conversation_id}/labels` |
| Method | JSON via POST |

**Authorization:**

| Header Parameter | Description |
| --- | --- |
| `api_access_token` | User API key |

The user API key provides access to endpoints based on the user's permission
level, and can be obtained on the profile page.

**Permissions:**

- User token: the caller must be able to see the conversation — see
  [Who can see a conversation](https://docs.99digital.co.il/online-api/conversations/conversation-basics#who-can-see-a-conversation).
  New rules system: **Inbox assign labels** for the conversation's inbox.
- Agent-bot token: allowed.

**Path Parameters:**

| Parameter | Description | Required |
| --- | --- | --- |
| `account_id` | The numeric ID of the account | Yes |
| `conversation_id` | The numeric ID of the conversation (its display ID) | Yes |

**Request body:**

| Parameter | type | Description | Required |
| --- | --- | --- | --- |
| `labels` | array of strings | An array of labels: the full list of label titles the conversation should have (see [List Labels](https://docs.99digital.co.il/online-api/labels/list-labels)) | Yes |

**Request body example:**

```json
{
  "labels": ["vip", "billing"]
}
```

**Response:**

```json
{
  "payload": [
    "vip",
    "billing"
  ]
}
```

**Response-Explain:**

| Parameter | Description |
| --- | --- |
| `payload` | Array of strings (label): the titles of the conversation's labels after the change |

## Remarks

- A change fires the `conversation_updated`
  [webhook event](https://docs.99digital.co.il/online-api/webhooks/webhook-events).

## Authentication

`api_access_token` in the header — Your access token. A user token is in the dashboard under **Profile settings → Access Token**, and grants exactly what that agent's role allows. An agent-bot token may call only the endpoints marked for agent bots. See [Getting Started](https://docs.99digital.co.il/online-api/getting-started#authentication).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `account_id` | path | integer | Yes | The numeric ID of your account: the number after `/app/accounts/` in the dashboard URL. Example: `12`. |
| `conversation_id` | path | integer | Yes | The numeric ID of the conversation: its display ID, which is the `id` in conversation responses and the number in the dashboard URL. Example: `1501`. |

## Request body

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `labels` | array of string | Yes | An array of labels: the full list of label titles the conversation should have. Labels you leave out are removed, and `[]` removes every label. See [List Labels](https://docs.99digital.co.il/online-api/labels/list-labels) for the account's labels. |

### Example: Set labels

The conversation gets exactly these two labels.

```json
{
  "labels": [
    "vip",
    "billing"
  ]
}
```

### Example: Remove all labels

An empty list removes every label.

```json
{
  "labels": []
}
```

## Responses

### 200 — The conversation's labels after the change.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `payload` | array of string | The titles of the conversation's labels. |

#### Example: Set labels

The answer to the "Set labels" request.

```json
{
  "payload": [
    "vip",
    "billing"
  ]
}
```

#### Example: Remove all labels

The answer to the "Remove all labels" request.

```json
{
  "payload": []
}
```

### 401 — The access token is missing or wrong, or its user does not belong to this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: Invalid token

The api_access_token header is missing or wrong.

```json
{
  "error": "Invalid Access Token"
}
```

#### Example: Another account

A valid token, for a user who is not in this account.

```json
{
  "error": "You are not authorized to access this account"
}
```

### 403 — The token's role does not have the permission this endpoint needs, or the endpoint is not open to agent-bot tokens. See [Authorization](https://docs.99digital.co.il/online-api/getting-started#authorization).

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: No permission

The role lacks the permission.

```json
{
  "error": "You are not authorized to do this action"
}
```

#### Example: Agent bot

An agent-bot token on an endpoint that is not open to bots.

```json
{
  "error": "Access to this endpoint is not authorized for bots"
}
```

### 404 — The resource does not exist in this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example

```json
{
  "error": "Resource could not be found"
}
```
