Search for customer
curl --request POST \
--url https://api.fabric.inc/v3/customers/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"match": {
"createdAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"updatedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"deletedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"additionalAttributes": {
"op": "IN",
"key": "gps",
"value": "beach"
},
"isDeleted": false
},
"sort": "+firstName,-createdAt",
"offset": 0,
"limit": 10
}
'import requests
url = "https://api.fabric.inc/v3/customers/search"
payload = {
"match": {
"createdAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"updatedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"deletedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"additionalAttributes": {
"op": "IN",
"key": "gps",
"value": "beach"
},
"isDeleted": False
},
"sort": "+firstName,-createdAt",
"offset": 0,
"limit": 10
}
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({
match: {
createdAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
updatedAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
deletedAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
additionalAttributes: {op: 'IN', key: 'gps', value: 'beach'},
isDeleted: false
},
sort: '+firstName,-createdAt',
offset: 0,
limit: 10
})
};
fetch('https://api.fabric.inc/v3/customers/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_URL => "https://api.fabric.inc/v3/customers/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([
'match' => [
'createdAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'updatedAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'deletedAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'additionalAttributes' => [
'op' => 'IN',
'key' => 'gps',
'value' => 'beach'
],
'isDeleted' => false
],
'sort' => '+firstName,-createdAt',
'offset' => 0,
'limit' => 10
]),
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 := "https://api.fabric.inc/v3/customers/search"
payload := strings.NewReader("{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\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("https://api.fabric.inc/v3/customers/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/customers/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\n}"
response = http.request(request)
puts response.read_body{
"query": {
"offset": 0,
"limit": 20,
"count": 100
},
"data": [
{
"id": "61df41892bf06d00092d0d8a",
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"status": "ACTIVE",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"middleName": "user"
},
"deletedAt": "2023-08-30T23:20:42.822Z"
}
]
}Customer Profile
Search for customer
Using this endpoint, you can search for customers based on filter conditions. By specifying offset and limit, you can narrow down your search results. In addition, using the isDelete property in the request body, you can filter for either deleted or non-deleted customers.
POST
/
customers
/
search
Search for customer
curl --request POST \
--url https://api.fabric.inc/v3/customers/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"match": {
"createdAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"updatedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"deletedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"additionalAttributes": {
"op": "IN",
"key": "gps",
"value": "beach"
},
"isDeleted": false
},
"sort": "+firstName,-createdAt",
"offset": 0,
"limit": 10
}
'import requests
url = "https://api.fabric.inc/v3/customers/search"
payload = {
"match": {
"createdAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"updatedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"deletedAt": {
"op": "LTE",
"value": "2023-08-30T23:20:42.822Z"
},
"additionalAttributes": {
"op": "IN",
"key": "gps",
"value": "beach"
},
"isDeleted": False
},
"sort": "+firstName,-createdAt",
"offset": 0,
"limit": 10
}
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({
match: {
createdAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
updatedAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
deletedAt: {op: 'LTE', value: '2023-08-30T23:20:42.822Z'},
additionalAttributes: {op: 'IN', key: 'gps', value: 'beach'},
isDeleted: false
},
sort: '+firstName,-createdAt',
offset: 0,
limit: 10
})
};
fetch('https://api.fabric.inc/v3/customers/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_URL => "https://api.fabric.inc/v3/customers/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([
'match' => [
'createdAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'updatedAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'deletedAt' => [
'op' => 'LTE',
'value' => '2023-08-30T23:20:42.822Z'
],
'additionalAttributes' => [
'op' => 'IN',
'key' => 'gps',
'value' => 'beach'
],
'isDeleted' => false
],
'sort' => '+firstName,-createdAt',
'offset' => 0,
'limit' => 10
]),
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 := "https://api.fabric.inc/v3/customers/search"
payload := strings.NewReader("{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\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("https://api.fabric.inc/v3/customers/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/customers/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"match\": {\n \"createdAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"updatedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"deletedAt\": {\n \"op\": \"LTE\",\n \"value\": \"2023-08-30T23:20:42.822Z\"\n },\n \"additionalAttributes\": {\n \"op\": \"IN\",\n \"key\": \"gps\",\n \"value\": \"beach\"\n },\n \"isDeleted\": false\n },\n \"sort\": \"+firstName,-createdAt\",\n \"offset\": 0,\n \"limit\": 10\n}"
response = http.request(request)
puts response.read_body{
"query": {
"offset": 0,
"limit": 20,
"count": 100
},
"data": [
{
"id": "61df41892bf06d00092d0d8a",
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"status": "ACTIVE",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"middleName": "user"
},
"deletedAt": "2023-08-30T23:20:42.822Z"
}
]
}Headers
A header used by fabric to identify the tenant making the request. You must include tenant id in the authentication header for an API request to access any of fabric’s endpoints. You can retrieve the tenant id , which is also called account id, from Copilot. This header is required.
Example:
"517fa9dfd42d8b00g1o3k312"
Body
application/json
A sample request to search for customers.
The criteria to search for customers.
Was this page helpful?
