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

Canonical page: https://docs.99digital.co.il/online-api/contacts/filter-contacts

# Filter Contacts

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

Advanced filtering of contacts with a list of conditions.

Each condition is combined with the **next** one using its `query_operator` (`and` / `or`). The last condition has `query_operator: null`. Results come 10 per page by default, with the same paging and sorting options as [List Contacts](https://docs.99digital.co.il/online-api/contacts/list-contacts).

| Setting | Value |
| --- | --- |
| **Method** | `POST` |
| **Path** | `/api/v1/accounts/{account_id}/contacts/filter` |
| **Authorization** | User token. Legacy: any agent. New rules: **Contacts → read**. Agent-bot tokens: not allowed. |

**Path parameters**

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

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page`, `per_page`, `sort`, `include_contact_inboxes` | | No | Same as [List Contacts](https://docs.99digital.co.il/online-api/contacts/list-contacts). |
| `include_conversations` | boolean | No | Also return each contact's `conversations`. Default `false`. |

**Body parameters (JSON)**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | array | Yes | List of conditions. |
| `payload[].attribute_key` | string | Yes | Attribute to filter on (table below), or the key of a contact custom attribute. |
| `payload[].filter_operator` | string | Yes | Operator (table below). |
| `payload[].values` | array | Yes | Values to compare. Most operators use `values[0]`. Send `[]` for `is_present` / `is_not_present`. |
| `payload[].query_operator` | string | Yes | `and` / `or` to join with the next condition; `null` on the last one. Any other value returns `422`. |

**Filterable attributes**

| `attribute_key` | Operators |
| --- | --- |
| `name` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain` |
| `phone_number` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain`, `is_present`, `is_not_present` (the value may be sent with or without `+`) |
| `email` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain`, `is_present`, `is_not_present` |
| `identifier` | `equal_to`, `not_equal_to` |
| `country_code` | `equal_to`, `not_equal_to` |
| `city` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain` |
| `browser_language` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain` |
| `company`, `company_name` | `equal_to`, `not_equal_to`, `contains`, `does_not_contain`, `is_present`, `is_not_present` |
| `labels` | `equal_to` (has any of the labels), `not_equal_to` (has none of them), `is_present`, `is_not_present` |
| `created_at`, `last_activity_at` | `is_greater_than`, `is_less_than` (value `YYYY-MM-DD`), `days_before` (value = number of days) |
| `blocked` | `equal_to`, `not_equal_to` (value `true` / `false`) |
| *custom attribute key* | Key of a **contact** custom attribute defined in Settings → Custom attributes. Operators depend on the attribute type: text `equal_to` / `not_equal_to` / `contains` / `does_not_contain`; number and date `equal_to` / `not_equal_to` / `is_greater_than` / `is_less_than`; plus `is_present` / `is_not_present`. |

Text comparisons are case-insensitive.

:::warning

A condition with an unsupported operator (for example `contains` on `labels`) or an unknown attribute key is **silently ignored**, so the filter returns more results than expected. Stick to the operators in the table.

:::

#### Example: email contains X **or** phone equals Y

```bash
curl -X POST 'https://online.99digital.co.il/api/v1/accounts/12/contacts/filter?page=1&include_contact_inboxes=false' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "payload": [
      { "attribute_key": "email", "filter_operator": "contains", "values": ["dana.cohen"], "query_operator": "or" },
      { "attribute_key": "phone_number", "filter_operator": "equal_to", "values": ["972521234567"], "query_operator": null }
    ]
  }'
```

Response (`200 OK`). The two contacts are shown by ID and name only; each item is a full contact object.

```json
{
  "meta": { "count": 2, "current_page": "1" },
  "payload": [
    { "id": 801, "name": "Dana Cohen" },
    { "id": 802, "name": "Avi Levi" }
  ]
}
```

#### Example: city equals Tel Aviv **and** created after a date

```bash
curl -X POST 'https://online.99digital.co.il/api/v1/accounts/12/contacts/filter?include_contact_inboxes=false' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "payload": [
      { "attribute_key": "city", "filter_operator": "equal_to", "values": ["Tel Aviv"], "query_operator": "and" },
      { "attribute_key": "created_at", "filter_operator": "is_greater_than", "values": ["2026-11-11"], "query_operator": null }
    ]
  }'
```

Response (`200 OK`):

```json
{
  "meta": {
    "count": 1,
    "current_page": 1
  },
  "payload": [
    {
      "additional_attributes": {
        "company_name": "Example Ltd",
        "city": "Tel Aviv"
      },
      "availability_status": "offline",
      "email": "dana.cohen@example.com",
      "id": 801,
      "name": "Dana Cohen",
      "phone_number": "+972501234567",
      "identifier": "crm-801",
      "thumbnail": "",
      "custom_attributes": {
        "customer_tier": "gold"
      },
      "blocked": false,
      "is_whatsapp_contact": false,
      "created_at": 1794470500
    }
  ]
}
```

**Error responses**

| Status | When | Body |
| --- | --- | --- |
| `422` | `query_operator` is not `and` / `or` / `null`. | `{"error": "Query operator must be either \"AND\" or \"OR\"."}` |

## Remarks

- `meta.current_page` may come back as a string (for example `"1"`), so parse it before comparing.

## 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`. |
| `page` | query | integer | No | The page parameter — the number of the page to return. Default: `1`. |
| `per_page` | query | integer | No | The page size — the number of contacts per page, at most 100. Default: `10`. Maximum: 100. |
| `sort` | query | string | No | The attribute by which the list should be sorted. Prefix it with `-` for descending order (for example `-created_at`). One of: `name` — By name, ascending (A to Z); `email` — By email address, ascending; `phone_number` — By phone number, ascending; `last_activity_at` — By last activity, oldest first; `created_at` — By creation time, oldest first; `company` — By company name (`company_name` in `additional_attributes`), ascending; `city` — By city (`city` in `additional_attributes`), ascending; `country` — By country (`country` in `additional_attributes`), ascending; `-name` — By name, descending (Z to A); `-email` — By email address, descending; `-phone_number` — By phone number, descending; `-last_activity_at` — By last activity, newest first; `-created_at` — By creation time, newest first; `-company` — By company name, descending; `-city` — By city, descending; `-country` — By country, descending. |
| `include_contact_inboxes` | query | boolean | No | Include `contact_inboxes` in each contact. Send `false` for much smaller responses. Default: `true`. |
| `include_conversations` | query | boolean | No | Also return each contact's `conversations`, each a full conversation object as returned by [Get Conversation](https://docs.99digital.co.il/online-api/conversations/get-conversation). Default: `false`. |

## Request body

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | array of object | Yes | The conditions, in order. Each one is joined to the next with its `query_operator`. |
| `payload[].attribute_key` | string | Yes | The attribute to filter on (see the table above), or the key of a contact custom attribute. Example: `city`. |
| `payload[].filter_operator` | string | Yes | The comparison. Which operators an attribute supports is in the table above. Text comparisons ignore case. One of: `equal_to` — The attribute equals the value. For `labels`: the contact has any of the given labels; `not_equal_to` — The attribute does not equal the value. For `labels`: the contact has none of the given labels; `contains` — The attribute contains the value as part of it; `does_not_contain` — The attribute does not contain the value; `is_present` — The attribute has a value. Send `values` as `[]`; `is_not_present` — The attribute is empty. Send `values` as `[]`; `is_greater_than` — After the date (`YYYY-MM-DD`), or more than the number (number attributes); `is_less_than` — Before the date (`YYYY-MM-DD`), or less than the number (number attributes); `days_before` — For `created_at` and `last_activity_at`: the date is more than the given number of days ago. The value is a number of days. |
| `payload[].values` | array of string \| number \| boolean | Yes | The values to compare with. Most operators use the first value only. Send `[]` for `is_present` and `is_not_present`. |
| `payload[].query_operator` | string \| null | Yes | How this condition is joined to the next one. `null` on the last condition. Any other value returns `422`. One of: `and` — Both this condition and the next one must match; `or` — This condition or the next one must match; `null`. |

### Example: Email or phone

The email contains a text, or the phone number equals a number.

```json
{
  "payload": [
    {
      "attribute_key": "email",
      "filter_operator": "contains",
      "values": [
        "dana.cohen"
      ],
      "query_operator": "or"
    },
    {
      "attribute_key": "phone_number",
      "filter_operator": "equal_to",
      "values": [
        "972521234567"
      ],
      "query_operator": null
    }
  ]
}
```

### Example: City and creation date

The city equals a value, and the contact was created after a date.

```json
{
  "payload": [
    {
      "attribute_key": "city",
      "filter_operator": "equal_to",
      "values": [
        "Tel Aviv"
      ],
      "query_operator": "and"
    },
    {
      "attribute_key": "created_at",
      "filter_operator": "is_greater_than",
      "values": [
        "2026-11-11"
      ],
      "query_operator": null
    }
  ]
}
```

## Responses

### 200 — A page of the contacts that match the conditions.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `meta` | object | Paging information for the result. |
| `meta.count` | integer | The total number of matching contacts, across all pages. |
| `meta.current_page` | integer \| string | The current page number. It may come back as a string (for example `"1"`). |
| `payload` | array of object | The matching contacts on this page. With `include_conversations=true`, each contact also has a `conversations` array. |
| `payload[].id` | integer | The contact's numeric ID. |
| `payload[].name` | string | The full name of the contact. |
| `payload[].email` | string \| null | The email address of the contact, stored in lower case, or `null`. |
| `payload[].phone_number` | string \| null | The phone number of the contact in E.164 format (`+` and the country code, then the number, for example `+972501234567`), or `null`. Israeli mobile numbers are normalized automatically: `0501234567`, `501234567` and `972501234567` are all saved as `+972501234567`. |
| `payload[].identifier` | string \| null | A unique identifier for the contact in your external system (your own ID for the contact), unique in the account, or `null`. |
| `payload[].thumbnail` | string | The avatar URL of the contact, or an empty string. |
| `payload[].availability_status` | string | The availability status of the contact: whether the contact is connected right now (website widget). One of: `online` — The contact is connected right now (website widget); `offline` — The contact is not connected. |
| `payload[].additional_attributes` | object | Object containing the additional attributes related to the contact: standard extra fields, such as `company_name`, `city`, `country`, `country_code`, `description` and `social_profiles`. Blocking data (`blocked`, `blocked_at`, `block_source`) is kept here too. |
| `payload[].custom_attributes` | object | Object containing the custom attributes related to the contact: values of the account's contact custom attributes (Settings → Custom attributes), plus any free-form keys you sent. |
| `payload[].blocked` | boolean | Indicates whether the contact is blocked — `true` while the contact is blocked. |
| `payload[].is_whatsapp_contact` | boolean | `true` if the contact belongs to a WhatsApp API inbox. |
| `payload[].created_at` | integer | The time at which the contact was created (Unix timestamp, in seconds). |
| `payload[].last_activity_at` | integer | The time of the contact's last activity (Unix timestamp, in seconds). Present only when set. |
| `payload[].email_or_phone_optional` | boolean | `true` when the contact has a WhatsApp ID, so email and phone may both be empty. Returned only together with `contact_inboxes`. |
| `payload[].contact_inboxes` | array of object | Array of contact inbox objects: the inboxes the contact is linked to, each with the contact's `source_id` there and the inbox's details. Returned by the endpoints that return one contact, and by the list, search and filter endpoints unless you send `include_contact_inboxes=false`. |
| `payload[].contact_inboxes[].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). |
| `payload[].contact_inboxes[].inbox` | object | Object containing the details of the inbox. |
| `payload[].contact_inboxes[].inbox.id` | integer | The numeric ID of the inbox. |
| `payload[].contact_inboxes[].inbox.channel_id` | integer | The numeric ID of the inbox's channel. |
| `payload[].contact_inboxes[].inbox.account_id` | integer | The numeric ID of the account. |
| `payload[].contact_inboxes[].inbox.name` | string | The name of the inbox. |
| `payload[].contact_inboxes[].inbox.channel_type` | string | The type of the inbox (its channel), for example `Channel::Api`, `Channel::Whatsapp` or `Channel::Email`. |
| `payload[].contact_inboxes[].inbox.enable_auto_assignment` | boolean | Whether auto-assignment is enabled: new conversations in the inbox are assigned to agents automatically. |
| `payload[].contact_inboxes[].inbox.timezone` | string | The inbox's time zone. |
| `payload[].contact_inboxes[].inbox.webhook_url` | string | For API inboxes, the inbox's own webhook URL. |
| `payload[].contact_inboxes[].inbox.api_type` | string | For API inboxes, the kind of API inbox, for example `incoming_calls`. |
| `payload[].conversations` | array of object | The contact's conversations, each a conversation object as returned by [Get Conversation](https://docs.99digital.co.il/online-api/conversations/get-conversation). Returned only by [Filter Contacts](https://docs.99digital.co.il/online-api/contacts/filter-contacts) with `include_conversations=true`. |

#### Example: Email or phone

The "Email or phone" request, with `?page=1&include_contact_inboxes=false`. The contacts are shown by ID and name only; each is a full contact object.

```json
{
  "meta": {
    "count": 2,
    "current_page": "1"
  },
  "payload": [
    {
      "id": 801,
      "name": "Dana Cohen"
    },
    {
      "id": 802,
      "name": "Avi Levi"
    }
  ]
}
```

#### Example: City and creation date

The "City and creation date" request, with `?include_contact_inboxes=false`.

```json
{
  "meta": {
    "count": 1,
    "current_page": 1
  },
  "payload": [
    {
      "additional_attributes": {
        "company_name": "Example Ltd",
        "city": "Tel Aviv"
      },
      "availability_status": "offline",
      "email": "dana.cohen@example.com",
      "id": 801,
      "name": "Dana Cohen",
      "phone_number": "+972501234567",
      "identifier": "crm-801",
      "thumbnail": "",
      "custom_attributes": {
        "customer_tier": "gold"
      },
      "blocked": false,
      "is_whatsapp_contact": false,
      "created_at": 1794470500
    }
  ]
}
```

### 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"
}
```

### 422 — A `query_operator` is not `and`, `or` or `null`.

Content type: `application/json`

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

#### Example

```json
{
  "error": "Query operator must be either \"AND\" or \"OR\"."
}
```
