Search contacts
curl --request POST \
--url http://localhost:8080/contacts/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": {
"or": [
{
"and": [
{
"type": "all_contacts"
}
]
}
]
},
"cursor": "<string>"
}
'import requests
url = "http://localhost:8080/contacts/search"
payload = {
"filter": { "or": [{ "and": [{ "type": "all_contacts" }] }] },
"cursor": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filter: {or: [{and: [{type: 'all_contacts'}]}]}, cursor: '<string>'})
};
fetch('http://localhost:8080/contacts/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/contacts/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filter' => [
'or' => [
[
'and' => [
[
'type' => 'all_contacts'
]
]
]
]
],
'cursor' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/contacts/search"
payload := strings.NewReader("{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/contacts/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/contacts/search")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"primary_external_id": "<string>",
"email": "[email protected]",
"phone_number": "<string>",
"name": "<string>",
"custom_data": {},
"non_verified_custom_data": {},
"created_at": "<string>",
"updated_at": "<string>"
}
],
"next": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Contacts
Search contacts
Search contacts by email, phone number, custom data, and more. Use when your application needs to find a contact without already holding its contact ID.
POST
/
contacts
/
search
Search contacts
curl --request POST \
--url http://localhost:8080/contacts/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": {
"or": [
{
"and": [
{
"type": "all_contacts"
}
]
}
]
},
"cursor": "<string>"
}
'import requests
url = "http://localhost:8080/contacts/search"
payload = {
"filter": { "or": [{ "and": [{ "type": "all_contacts" }] }] },
"cursor": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filter: {or: [{and: [{type: 'all_contacts'}]}]}, cursor: '<string>'})
};
fetch('http://localhost:8080/contacts/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/contacts/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filter' => [
'or' => [
[
'and' => [
[
'type' => 'all_contacts'
]
]
]
]
],
'cursor' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/contacts/search"
payload := strings.NewReader("{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/contacts/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/contacts/search")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filter\": {\n \"or\": [\n {\n \"and\": [\n {\n \"type\": \"all_contacts\"\n }\n ]\n }\n ]\n },\n \"cursor\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"primary_external_id": "<string>",
"email": "[email protected]",
"phone_number": "<string>",
"name": "<string>",
"custom_data": {},
"non_verified_custom_data": {},
"created_at": "<string>",
"updated_at": "<string>"
}
],
"next": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}The
filter is a list of or groups, each holding and rules. A contact matches when every rule in at least one group matches it.
{
"filter": {
"or": [
{ "and": [{ "type": "contacts_email_in", "email_in": ["[email protected]"] }] },
{ "and": [{ "type": "contacts_phone_number_in", "phone_number_in": ["+966500000000"] }] },
{ "and": [{ "type": "contacts_attributes_in", "attributes": [{ "merchant_id": "12345" }] }] }
]
}
}
Matching rules
contacts_email_inmatches the full address and ignores letter case.contacts_phone_number_incompares digits only, so+, spaces, and dashes don’t affect the match.- In email and phone values,
*turns the entry into a partial match:*@open.cxfinds every address containing@open.cx. contacts_attributes_inmatches custom data on an exact key and value. Each object inattributesis one alternative; a contact matches when it carries every key-value pair of any one object.
Pagination
Each page returns up to 250 contacts. When more results exist, the response carries anext value; send it as cursor in the next request with the same filter. next is null on the last page.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Was this page helpful?