Contacts API
Use the Contacts API to create individual contacts, update their fields, or load a list in batches. Contact, list, and tag IDs are opaque values; copy them from DialerAI rather than constructing them.
The examples below assume the BASE_URL and HEADERS client from API authentication. Every request needs a bearer token, and creating or updating contacts requires an Editor role.
Create a contact
POST /contact/create requires a phone number, contact-list ID, and selected_tags. DialerAI enriches the primary phone number with timezone information where available.
payload = {
"contact_list_id": "ctl_example",
"phone_number": "+14155130870",
"first_name": "Joe",
"last_name": "Foo",
"selected_tags": [],
}
response = requests.post(f"{BASE_URL}/contact/create", json=payload, headers=HEADERS)
response.raise_for_status()
contact_id = response.json()["contact_id"]
Add alternative numbers
Set alternative_phone_number as a mapping with slots "1" through "10". Each entry requires phonenumber; label is optional.
payload["alternative_phone_number"] = {
"1": {"phonenumber": "+441234567890", "label": "Office"},
"2": {"phonenumber": "+12025550139", "label": "Mobile"},
}
Alternative numbers require ENABLE_ALTERNATIVE_PHONE_NUMBERS=True on the server. Retrieve a contact with GET /contact/get/{id} to inspect timezone enrichment. When using PUT /contact/update/{id}, send the complete alternative-number mapping you intend to retain because supplied values replace the existing mapping.
Bulk-create a list
POST /contact/bulk-create/{contact_list_id} accepts up to 1,000 contacts. Each result is returned independently, so duplicates do not fail the entire batch.
contacts = [
{"phone_number": "+14155130870", "first_name": "Alice", "selected_tags": []},
{"phone_number": "+14155130871", "first_name": "Bob", "selected_tags": []},
]
response = requests.post(
f"{BASE_URL}/contact/bulk-create/ctl_example", json=contacts, headers=HEADERS
)
response.raise_for_status()
for item in response.json():
print("Created" if item["success"] else "Skipped", item.get("contact_id") or item.get("reason"))
Validate numbers and required fields before submitting a batch. Retry only items that failed after checking the returned reason.
Related
- API authentication: obtaining the token these calls need.
- API overview: shared client setup and bulk-create details.
- Manage contacts · Contact lists: the same objects in the UI.
- Contact data quality: number formatting and timezone enrichment.
- Export your data: getting contacts back out.