Search Contacts
Search and filter contacts in your workspace with optional field filters, tag filters, status filter, sorting, and pagination.
Endpoint
POST https://api.campaignlark.com/v1/contacts/search
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
fields | array | optional | Array of field filter objects. See Field Filter Object below. |
tags | array of integers | optional | Filter contacts that have all of the specified tag IDs. |
status | string | optional | Filter by contact status. One of SUBSCRIBED, UNSUBSCRIBED, UNCONFIRMED, CLEANED, COMPLAINED. |
page | integer | optional | Page number (1-indexed). Defaults to 1. |
limit | integer | optional | Results per page. Min 10, max 250. |
sort_by | string | optional | Field to sort by. One of created_at, updated_at. Defaults to created_at. |
sort_order | string | optional | Sort direction. One of asc, desc. Defaults to asc. |
Field Filter Object
| Field | Type | Required | Description |
|---|---|---|---|
merge_tag | string | required | The merge tag of the field to filter on (e.g. email_address, first_name). |
operator | string | required | Filter operator. See Filter Operators below. |
value | any | optional | The value to compare against. Not required for existence operators. |
Filter Operators
| Operator | Description |
|---|---|
EQUALS | Field value equals the given value. |
NOT_EQUALS | Field value does not equal the given value. |
CONTAINS | Field value contains the given string. |
NOT_CONTAINS | Field value does not contain the given string. |
EXISTS | Field has a value set. |
GREATER_THAN | Field value is greater than the given value. |
LESS_THAN | Field value is less than the given value. |
Sample Request
POST https://api.campaignlark.com/v1/contacts/search
Content-Type: application/json
{
"fields": [
{
"merge_tag": "first_name",
"operator": "CONTAINS",
"value": "John"
}
],
"tags": [1, 3],
"status": "SUBSCRIBED",
"page": 1,
"limit": 50,
"sort_by": "created_at",
"sort_order": "desc"
}
Response
Success — 200 OK
{
"data": {
"contacts": [
{
"id": "64f1a2b3c4d5e6f7a8b9c0d1",
"status": "SUBSCRIBED",
"tags": [
{ "id": 1, "name": "newsletter" }
],
"data": {
"email_address": "joffrey@example.com",
"first_name": "Joffrey Baratheon"
},
"statistics": {
"total_opens": 5,
"total_clicks": 2,
"total_bounces": 0,
"total_delivered": 5
},
"last_opened_at": "2024-02-14T09:00:00Z",
"last_clicked_at": null,
"created_at": "2024-01-10T08:00:00Z",
"updated_at": "2024-02-14T09:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 50,
"total": 142
}
}
}