> This page is for Omni Channel.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.hams.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.hams.ai/_mcp/server.

# Filter contacts

POST https://omni-channel.hams.ai/api/v1/accounts/{account_id}/developer/contacts/filter
Content-Type: application/json

Finds contacts that match a list of conditions. Each item in `payload` is 1 condition. `query_operator` joins the item to the next item. Leave it out on the last item. The result has 20 contacts on each page.


Reference: https://docs.hams.ai/omni-channel/reference/contacts/filter-contacts

## Authentication

- `api_access_token` header (required) — An API key that an administrator creates in **Settings** > **Developer**. The personal access token of a user does not work. A key reaches every inbox, conversation, and contact in the account that created it, and nothing in other accounts.

## Request

### Path parameters

- `account_id` (integer, required) — The id of your account. It is the number after `/accounts/` in the dashboard URL.

### Query parameters

- `page` (integer, optional, default: 1) — The page number. The first page is `1`.

### Body (application/json)

This endpoint expects an object.

- `payload` (list of AccountsAccountIdDeveloperContactsFilterPostRequestBodyContentApplicationJsonSchemaPayloadItems, required)

## Response

### 200

The contacts that match.

- `meta` (ContactListMeta, optional)
- `payload` (list of Contact, optional)

## Errors

### 401 Unauthorized Error

The token does not exist, is not an API key, or belongs to another account. The token can also be the token of a user who is not a member of the account, or the account can be suspended. The body has only the `error` field.

- `error` (string, required) — `Invalid Access Token`, `Key is not authorized to access this account`, `Access to this endpoint is not authorized for this token`, `You are not authorized to access this account`, or `Account is suspended`.

### 422 Unprocessable Entity Error

An attribute, an operator, or a value is not valid. `error` gives the reason.

- `error` (string, required)

## Types

### AccountsAccountIdDeveloperContactsFilterPostRequestBodyContentApplicationJsonSchemaPayloadItems

- `attribute_key` (string, required) — `name`, `email`, `phone_number`, `identifier`, `country_code`, `city`, `company_name`, `labels`, `created_at`, `last_activity_at`, `blocked`, or the key of a contact custom attribute.
- `filter_operator` (enum, required) — The operators that each attribute accepts are on the Contacts page.
  - Allowed values: `equal_to`, `not_equal_to`, `contains`, `does_not_contain`, `starts_with`, `is_present`, `is_not_present`, `is_greater_than`, `is_less_than`, `days_before`
- `values` (list of any, optional)
- `query_operator` (enum, optional)
  - Allowed values: `AND`, `OR`

### ContactListMeta

- `count` (integer, optional)
- `current_page` (integer, optional)

### Contact

- `id` (integer, optional)
- `name` (string, optional)
- `email` (string, optional, nullable)
- `phone_number` (string, optional, nullable) — E.164, for example `+971500000000`.
- `identifier` (string, optional, nullable) — Your own id for the contact. It is unique in the account.
- `blocked` (boolean, optional)
- `availability_status` (string, optional)
- `thumbnail` (string, optional)
- `custom_attributes` (map from string to any, optional)
- `additional_attributes` (map from string to any, optional)
- `last_activity_at` (integer, optional) — Unix timestamp, in seconds.
- `created_at` (integer, optional) — Unix timestamp, in seconds.
- `contact_inboxes` (list of map from string to any, optional) — The inboxes where the contact has an address.

## Examples

### Contact with a phone number

**Request**

```json
{
  "payload": [
    {
      "attribute_key": "phone_number",
      "filter_operator": "equal_to",
      "values": [
        "+971500000000"
      ]
    }
  ]
}
```

**Response**

```json
{
  "meta": {
    "count": 1,
    "current_page": 1
  },
  "payload": [
    {
      "id": 1,
      "name": "string",
      "email": "string",
      "phone_number": "string",
      "identifier": "string",
      "blocked": true,
      "availability_status": "string",
      "thumbnail": "string",
      "custom_attributes": {},
      "additional_attributes": {},
      "last_activity_at": 1,
      "created_at": 1,
      "contact_inboxes": [
        {}
      ]
    }
  ]
}
```

**SDK Code**

```python Contact with a phone number
import requests

url = "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter"

payload = { "payload": [
        {
            "attribute_key": "phone_number",
            "filter_operator": "equal_to",
            "values": ["+971500000000"]
        }
    ] }
headers = {
    "api_access_token": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Contact with a phone number
const url = 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter';
const options = {
  method: 'POST',
  headers: {api_access_token: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"payload":[{"attribute_key":"phone_number","filter_operator":"equal_to","values":["+971500000000"]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Contact with a phone number
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter"

	payload := strings.NewReader("{\n  \"payload\": [\n    {\n      \"attribute_key\": \"phone_number\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"+971500000000\"\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api_access_token", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Contact with a phone number
require 'uri'
require 'net/http'

url = URI("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"payload\": [\n    {\n      \"attribute_key\": \"phone_number\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"+971500000000\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Contact with a phone number
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")
  .header("api_access_token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"payload\": [\n    {\n      \"attribute_key\": \"phone_number\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"+971500000000\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Contact with a phone number
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter', [
  'body' => '{
  "payload": [
    {
      "attribute_key": "phone_number",
      "filter_operator": "equal_to",
      "values": [
        "+971500000000"
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'api_access_token' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Contact with a phone number
using RestSharp;

var client = new RestClient("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter");
var request = new RestRequest(Method.POST);
request.AddHeader("api_access_token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"payload\": [\n    {\n      \"attribute_key\": \"phone_number\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"+971500000000\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Contact with a phone number
import Foundation

let headers = [
  "api_access_token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["payload": [
    [
      "attribute_key": "phone_number",
      "filter_operator": "equal_to",
      "values": ["+971500000000"]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Contacts in the UAE

**Request**

```json
{
  "payload": [
    {
      "attribute_key": "country_code",
      "filter_operator": "equal_to",
      "values": [
        "AE"
      ]
    }
  ]
}
```

**Response**

```json
{
  "meta": {
    "count": 1,
    "current_page": 1
  },
  "payload": [
    {
      "id": 1,
      "name": "string",
      "email": "string",
      "phone_number": "string",
      "identifier": "string",
      "blocked": true,
      "availability_status": "string",
      "thumbnail": "string",
      "custom_attributes": {},
      "additional_attributes": {},
      "last_activity_at": 1,
      "created_at": 1,
      "contact_inboxes": [
        {}
      ]
    }
  ]
}
```

**SDK Code**

```python Contacts in the UAE
import requests

url = "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter"

payload = { "payload": [
        {
            "attribute_key": "country_code",
            "filter_operator": "equal_to",
            "values": ["AE"]
        }
    ] }
headers = {
    "api_access_token": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Contacts in the UAE
const url = 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter';
const options = {
  method: 'POST',
  headers: {api_access_token: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"payload":[{"attribute_key":"country_code","filter_operator":"equal_to","values":["AE"]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Contacts in the UAE
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter"

	payload := strings.NewReader("{\n  \"payload\": [\n    {\n      \"attribute_key\": \"country_code\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"AE\"\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api_access_token", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Contacts in the UAE
require 'uri'
require 'net/http'

url = URI("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"payload\": [\n    {\n      \"attribute_key\": \"country_code\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"AE\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Contacts in the UAE
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")
  .header("api_access_token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"payload\": [\n    {\n      \"attribute_key\": \"country_code\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"AE\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Contacts in the UAE
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter', [
  'body' => '{
  "payload": [
    {
      "attribute_key": "country_code",
      "filter_operator": "equal_to",
      "values": [
        "AE"
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'api_access_token' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Contacts in the UAE
using RestSharp;

var client = new RestClient("https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter");
var request = new RestRequest(Method.POST);
request.AddHeader("api_access_token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"payload\": [\n    {\n      \"attribute_key\": \"country_code\",\n      \"filter_operator\": \"equal_to\",\n      \"values\": [\n        \"AE\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Contacts in the UAE
import Foundation

let headers = [
  "api_access_token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["payload": [
    [
      "attribute_key": "country_code",
      "filter_operator": "equal_to",
      "values": ["AE"]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://omni-channel.hams.ai/api/v1/accounts/1/developer/contacts/filter")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```