List and search for contacts
This endpoint will let you list all of your contacts or search for a specific one given a search query.
Search fields
Each contact must have at least a first name and some contact details like a phone number or an email address.
Field | Description | Example |
---|---|---|
query | Search term to look for. | 2123334444 or Kate Smith |
results_per_page | Number of results returned per page. This value needs to be between 1 and 100. | 10 |
page_number | Get a result set from the given page. | 1 |
Invocation
- cURL
- Python
- NodeJS
curl --location 'https://api.p.2chat.io/open/contacts/search?query=augusto&results_per_page=30&page_number=0' \
--header 'Content-Type: application/json' \
--header 'X-User-API-Key: your_api_key_here'
import requests
import json
url = "https://api.p.2chat.io/open/contacts/search?query=augusto&results_per_page=30&page_number=0"
payload = ""
headers = {
'X-User-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://api.p.2chat.io/open/contacts/open/contacts/search?query=augusto&results_per_page=30&page_number=0',
headers: {
'X-User-API-Key': 'your_api_key_here'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Response
{
"success": true,
"page": 0,
"count": 2,
"contacts": [
{
"id": 566,
"uuid": "CON5dbf28a9-44f5-4ca2-9eae-fd33b124097a",
"first_name": "Augusto",
"last_name": "Gonzalez",
"channel_uuid": "WPNc568c832-606c-4d50-8092-fc51b5149d16",
"profile_pic_url": "https://2chat-user-data-dev.s3.amazonaws.com/...",
"details": [
{
"id": 566,
"value": "+595981222333",
"type": "WAPH",
"created_at": 1667767024,
"updated_at": 1670892336
}
]
},
{
"id": 978,
"uuid": "CONf3039b0c-67e6-4bef-a9e9-170f0fa7d805",
"first_name": "Carlo",
"last_name": "Saugusto",
"channel_uuid": null,
"profile_pic_url": null,
"details": [
{
"id": 976,
"value": "+595212223333",
"type": "WAPH",
"created_at": 1671460161
},
{
"id": 977,
"value": "carlos@test.tld",
"type": "E",
"created_at": 1671460161
}
]
}
]
}