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

Canonical page: https://docs.99digital.co.il/online-api/contacts/create-contact-inbox

# Create Contact Inbox

`POST https://online.99digital.co.il/api/v1/accounts/{account_id}/contacts/{contact_id}/contact_inboxes`

Links an existing contact to an inbox.

This creates the contact inbox (and its `source_id`) needed to [open a conversation](https://docs.99digital.co.il/online-api/conversations/add-conversation) in that inbox. If the link already exists, it is returned unchanged.

| Setting | Value |
| --- | --- |
| **Method** | `POST` |
| **Path** | `/api/v1/accounts/{account_id}/contacts/{contact_id}/contact_inboxes` |
| **Authorization** | User token. The caller must be allowed to view the inbox. Agent-bot tokens: not allowed. |

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `account_id` | integer | Yes | Account ID. |
| `contact_id` | integer | Yes | Contact ID. |

**Body parameters (JSON)**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `inbox_id` | integer | Yes | Inbox ID. |
| `source_id` | string | No | The contact's ID on that channel. Generated if omitted. For phone channels it defaults to the contact's phone; for email inboxes to the contact's email. |
| `hmac_verified` | boolean | No | Mark the contact inbox as HMAC-verified (website widget identity validation). |

**Example request**

```bash
curl -X POST 'https://online.99digital.co.il/api/v1/accounts/12/contacts/801/contact_inboxes' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "inbox_id": 31, "source_id": "5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b" }'
```

**Example response** (`200 OK`). The `inbox` object is truncated.

```json
{
  "source_id": "5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b",
  "inbox": {
    "id": 31,
    "channel_id": 9,
    "name": "Website API",
    "channel_type": "Channel::Api",
    "enable_auto_assignment": true,
    "webhook_url": ""
  }
}
```

**Error responses**: `404 {"error": "Resource could not be found"}` when the contact or inbox does not exist.

## 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`. |
| `contact_id` | path | integer | Yes | The numeric ID of the contact. Example: `801`. |

## Request body

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `inbox_id` | integer | Yes | The inbox to link the contact to. Example: `31`. |
| `source_id` | string | No | The contact's ID on that channel. Generated when omitted: for phone channels it is the contact's phone number, for email inboxes the contact's email address. Example: `5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b`. |
| `hmac_verified` | boolean | No | Mark the contact inbox as HMAC-verified (identity validation of the website widget). |

### Example: Generated source ID

Link the contact to an inbox, with a generated `source_id`.

```json
{
  "inbox_id": 31
}
```

### Example: Your own source ID

Link the contact to an inbox with a `source_id` you choose.

```json
{
  "inbox_id": 31,
  "source_id": "5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b"
}
```

## Responses

### 200 — The contact inbox.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `source_id` | string | The contact inbox's source ID: the contact's ID on the inbox's channel (a phone number, an email address, or a generated ID for API and website inboxes). |
| `inbox` | object | Object containing the details of the inbox. |
| `inbox.id` | integer | The numeric ID of the inbox. |
| `inbox.channel_id` | integer | The numeric ID of the inbox's channel. |
| `inbox.account_id` | integer | The numeric ID of the account. |
| `inbox.name` | string | The name of the inbox. |
| `inbox.channel_type` | string | The type of the inbox (its channel), for example `Channel::Api`, `Channel::Whatsapp` or `Channel::Email`. |
| `inbox.enable_auto_assignment` | boolean | Whether auto-assignment is enabled: new conversations in the inbox are assigned to agents automatically. |
| `inbox.timezone` | string | The inbox's time zone. |
| `inbox.webhook_url` | string | For API inboxes, the inbox's own webhook URL. |
| `inbox.api_type` | string | For API inboxes, the kind of API inbox, for example `incoming_calls`. |

#### Example: Contact inbox

The `inbox` object is shortened.

```json
{
  "source_id": "5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b",
  "inbox": {
    "id": 31,
    "channel_id": 9,
    "name": "Website API",
    "channel_type": "Channel::Api",
    "enable_auto_assignment": true,
    "webhook_url": ""
  }
}
```

### 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 contact or the inbox 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"
}
```
