Skip to main content

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

FieldTypeRequiredDescription
fieldsarrayoptionalArray of field filter objects. See Field Filter Object below.
tagsarray of integersoptionalFilter contacts that have all of the specified tag IDs.
statusstringoptionalFilter by contact status. One of SUBSCRIBED, UNSUBSCRIBED, UNCONFIRMED, CLEANED, COMPLAINED.
pageintegeroptionalPage number (1-indexed). Defaults to 1.
limitintegeroptionalResults per page. Min 10, max 250.
sort_bystringoptionalField to sort by. One of created_at, updated_at. Defaults to created_at.
sort_orderstringoptionalSort direction. One of asc, desc. Defaults to asc.

Field Filter Object

FieldTypeRequiredDescription
merge_tagstringrequiredThe merge tag of the field to filter on (e.g. email_address, first_name).
operatorstringrequiredFilter operator. See Filter Operators below.
valueanyoptionalThe value to compare against. Not required for existence operators.

Filter Operators

OperatorDescription
EQUALSField value equals the given value.
NOT_EQUALSField value does not equal the given value.
CONTAINSField value contains the given string.
NOT_CONTAINSField value does not contain the given string.
EXISTSField has a value set.
GREATER_THANField value is greater than the given value.
LESS_THANField 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
}
}
}