Contacts API
List, search, create, update and delete contacts, and keep ZAPGEN in sync with your CRM or store using upsert by phone number.
Contacts are the people you message. Each one has a phone number (unique in your organization), a name, optional email and address, your custom fields and any number of groups.
POST /api/contacts/upsert finds the contact by phone number, creates it if it's new, and only changes the fields you send. You don't need to store ZAPGEN's IDs or check whether a contact exists first.
The contact object#
{
"uuid": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"first_name": "Sara",
"last_name": "Ahmed",
"full_name": "Sara Ahmed",
"phone": "+971501234567",
"formatted_phone_number": "+971 50 123 4567",
"email": "[email protected]",
"address": "{\"street\":\"Cluster D\",\"city\":\"Dubai\",\"state\":null,\"zip\":null,\"country\":\"UAE\"}",
"metadata": "{\"Membership\":\"Gold\",\"Birthday\":\"1992-04-18\"}",
"is_subscribed": 1,
"is_favorite": 0,
"unread_messages": 2,
"latest_chat_created_at": "2026-11-12 09:41:07",
"created_at": "2026-10-03 14:20:11",
"updated_at": "2026-11-12 09:41:07"
}| Field | Description |
|---|---|
uuid | The contact's ID. Use it in /api/contacts/{uuid}. |
first_name, last_name, full_name | The contact's name. |
phone | The number in E.164 format. |
formatted_phone_number | The number formatted for display. |
email | Email address, or null. |
address | A JSON string with street, city, state, zip and country. Parse it before use. |
metadata | A JSON string with your custom field values, keyed by field name. Parse it before use. |
is_subscribed | 1 if the contact receives marketing messages, 0 if not. |
is_favorite | 1 if someone in your team starred the contact. |
unread_messages | Messages from this contact nobody has read yet. |
latest_chat_created_at | Time of the latest message with this contact (UTC). |
created_at, updated_at | UTC, YYYY-MM-DD HH:MM:SS. |
The API returns a few more internal fields. Don't rely on them. Groups aren't included in the contact object.
List contacts#
https://app.zapgen.ae/api/contactsReturns your contacts, oldest first, paginated.
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | No | Page number, from 1. |
per_page | integer | No | Contacts per page, 1–100. Default 10. |
phone | string | No | Return only the contact with this number. +971501234567, 00971501234567 and 971501234567 all match. |
search | string | No | Contacts whose first name, last name, phone or email contains this text. |
curl "https://app.zapgen.ae/api/contacts?phone=%2B971501234567" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"const url = new URL('https://app.zapgen.ae/api/contacts');
url.searchParams.set('phone', '+971501234567');
const res = await fetch(url, {
headers: { Authorization: 'Bearer YOUR_API_KEY', Accept: 'application/json' }
});
const { data } = await res.json();
const contact = data[0] ?? null;$query = http_build_query(['phone' => '+971501234567']);
$ch = curl_init('https://app.zapgen.ae/api/contacts?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Accept: application/json'],
]);
$contacts = json_decode(curl_exec($ch), true)['data'];import requests
res = requests.get(
"https://app.zapgen.ae/api/contacts",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
params={"phone": "+971501234567"},
)
contacts = res.json()["data"]{
"data": [
{
"uuid": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"first_name": "Sara",
"last_name": "Ahmed",
"phone": "+971501234567",
"email": "[email protected]",
"is_subscribed": 1,
"created_at": "2026-10-03 14:20:11"
}
],
"links": { "first": "…", "last": "…", "prev": null, "next": null },
"meta": { "current_page": 1, "last_page": 1, "per_page": 10, "total": 1 }
}No match gives an empty data array, not an error. To get one contact, filter by phone: there's no endpoint that fetches a contact by its uuid yet.
Create a contact#
https://app.zapgen.ae/api/contacts| Name | Type | Required | Description |
|---|---|---|---|
first_name | string | Yes | First name. |
phone | string | Yes | Number with country code. Must not already belong to a contact. |
last_name | string | No | Last name. |
email | string | No | Email address. |
street, city, state, zip, country | string | No | Address. |
metadata | object | No | Custom field values keyed by field name, e.g. {"Membership": "Gold"}. |
is_subscribed | boolean | No | Whether the contact receives marketing messages. |
group | array | No | Group uuids to add the contact to. |
file | file | No | Profile photo (JPG, PNG, GIF or WebP, up to 5 MB). Send the request as multipart/form-data to include it. |
curl -X POST https://app.zapgen.ae/api/contacts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"first_name": "Sara",
"last_name": "Ahmed",
"phone": "+971501234567",
"email": "[email protected]",
"city": "Dubai",
"metadata": { "Membership": "Gold" },
"group": ["9a3c1e7b-5d2f-4b8a-9c6e-1f0d2b3a4c5d"]
}'const res = await fetch('https://app.zapgen.ae/api/contacts', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
first_name: 'Sara',
last_name: 'Ahmed',
phone: '+971501234567',
email: '[email protected]',
city: 'Dubai',
metadata: { Membership: 'Gold' },
group: ['9a3c1e7b-5d2f-4b8a-9c6e-1f0d2b3a4c5d']
})
});
const { id } = await res.json();$ch = curl_init('https://app.zapgen.ae/api/contacts');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'Sara',
'last_name' => 'Ahmed',
'phone' => '+971501234567',
'email' => '[email protected]',
'city' => 'Dubai',
'metadata' => ['Membership' => 'Gold'],
'group' => ['9a3c1e7b-5d2f-4b8a-9c6e-1f0d2b3a4c5d'],
]),
]);
$contactUuid = json_decode(curl_exec($ch), true)['id'];import requests
res = requests.post(
"https://app.zapgen.ae/api/contacts",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
json={
"first_name": "Sara",
"last_name": "Ahmed",
"phone": "+971501234567",
"email": "[email protected]",
"city": "Dubai",
"metadata": {"Membership": "Gold"},
"group": ["9a3c1e7b-5d2f-4b8a-9c6e-1f0d2b3a4c5d"],
},
)
contact_uuid = res.json()["id"]{
"statusCode": 200,
"id": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"message": "Request processed successfully"
}id is the new contact's uuid. A number that's already a contact gives a 400 with "phone": ["This phone number already exists"].
Create or update by phone (upsert)#
https://app.zapgen.ae/api/contacts/upsertFinds the contact by phone number. If there isn't one, it creates it. If there is, it updates only the fields you send and leaves the rest as they are.
| Name | Type | Required | Description |
|---|---|---|---|
phone | string | Yes | Number with country code. Used to find the contact. |
first_name | string | When creating | First name. Required only if the contact doesn't exist yet. |
last_name | string or null | No | Last name. null clears it. |
email | string or null | No | A valid email address. null clears it. |
street, city, state, zip, country | string | No | Address. Only the parts you send change. |
metadata | object | No | Custom field values keyed by field name. |
metadata_mode | string | No | merge (default) adds your values to the existing ones. replace replaces all custom field values with yours. |
is_subscribed | boolean | No | Whether the contact receives marketing messages. |
group | array | No | Group uuids. Replaces the contact's groups with this list. Unknown uuids are ignored. |
curl -X POST https://app.zapgen.ae/api/contacts/upsert \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"phone": "+971501234567",
"first_name": "Sara",
"email": "[email protected]",
"metadata": { "Last order": "#4421" }
}'const res = await fetch('https://app.zapgen.ae/api/contacts/upsert', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
phone: '+971501234567',
first_name: 'Sara',
email: '[email protected]',
metadata: { 'Last order': '#4421' }
})
});
const { created, contact } = await res.json();$ch = curl_init('https://app.zapgen.ae/api/contacts/upsert');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'phone' => '+971501234567',
'first_name' => 'Sara',
'email' => '[email protected]',
'metadata' => ['Last order' => '#4421'],
]),
]);
$result = json_decode(curl_exec($ch), true);import requests
res = requests.post(
"https://app.zapgen.ae/api/contacts/upsert",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
json={
"phone": "+971501234567",
"first_name": "Sara",
"email": "[email protected]",
"metadata": {"Last order": "#4421"},
},
)
result = res.json(){
"statusCode": 200,
"message": "Request processed successfully",
"created": false,
"id": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"contact": {
"uuid": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"first_name": "Sara",
"last_name": "Ahmed",
"phone": "+971501234567",
"email": "[email protected]",
"is_subscribed": 1
}
}created is true when a new contact was made. Without first_name for a new number you get a 400: "first_name": ["The first name field is required when creating a contact."].
Replace a contact#
https://app.zapgen.ae/api/contacts/{uuid}Replaces a contact's details. Takes the same fields as Create a contact, but first_name and phone are optional.
last_name, email, the address and metadata are set to exactly what you send, so a field you leave out is cleared. first_name, phone, is_subscribed and group are only changed when you send them. To change just one or two fields, use upsert instead.
curl -X PUT https://app.zapgen.ae/api/contacts/4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"first_name": "Sara",
"last_name": "Ahmed",
"email": "[email protected]",
"city": "Abu Dhabi",
"metadata": { "Membership": "Platinum" }
}'const uuid = '4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63';
const res = await fetch(`https://app.zapgen.ae/api/contacts/${uuid}`, {
method: 'PUT',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
first_name: 'Sara',
last_name: 'Ahmed',
email: '[email protected]',
city: 'Abu Dhabi',
metadata: { Membership: 'Platinum' }
})
});$uuid = '4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63';
$ch = curl_init("https://app.zapgen.ae/api/contacts/$uuid");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'Sara',
'last_name' => 'Ahmed',
'email' => '[email protected]',
'city' => 'Abu Dhabi',
'metadata' => ['Membership' => 'Platinum'],
]),
]);
$result = json_decode(curl_exec($ch), true);import requests
uuid = "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63"
res = requests.put(
f"https://app.zapgen.ae/api/contacts/{uuid}",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
json={
"first_name": "Sara",
"last_name": "Ahmed",
"email": "[email protected]",
"city": "Abu Dhabi",
"metadata": {"Membership": "Platinum"},
},
){
"statusCode": 200,
"id": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"message": "Request processed successfully"
}An unknown uuid returns 404 with Contact not found.
Delete a contact#
https://app.zapgen.ae/api/contacts/{uuid}Deletes the contact from your organization.
curl -X DELETE https://app.zapgen.ae/api/contacts/4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"const uuid = '4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63';
await fetch(`https://app.zapgen.ae/api/contacts/${uuid}`, {
method: 'DELETE',
headers: { Authorization: 'Bearer YOUR_API_KEY', Accept: 'application/json' }
});$uuid = '4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63';
$ch = curl_init("https://app.zapgen.ae/api/contacts/$uuid");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Accept: application/json'],
]);
$result = json_decode(curl_exec($ch), true);import requests
uuid = "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63"
res = requests.delete(
f"https://app.zapgen.ae/api/contacts/{uuid}",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
){
"statusCode": 200,
"id": "4d1f7a3e-9b2c-4c41-8f0e-2a7d5c9b1e63",
"message": "Request processed successfully"
}An unknown or already deleted uuid returns 404 with Contact not found.
Errors#
| Status | When |
|---|---|
400 | A required field is missing, the phone number isn't valid, or (on create) it already belongs to a contact. |
401 | The API key is missing or wrong. |
403 | Your subscription has ended. Creating and changing contacts stops; listing and deleting still work. |
404 | No contact with that uuid in your organization. |
Good to know#
- Changes made through the API send
contact.created,contact.updatedandcontact.deletedwebhooks, like changes made in the app. - Contacts that ZAPGEN creates by itself, when a new number messages you or when you send to a new number, don't send
contact.created. Watchmessage.receivedfor those. - Contacts imported from Excel in the app don't send
contact.createdeither.