Python
Contacts
Create or Update Contact
Insert a new contact or update an existing one based on email or phone
POST
Python
How Matching Works
The endpoint matches contacts in this order:Match by email
If
email is provided, searches for an existing contact with the same email in your company.Need to update a contact’s email? Prefer Update by ID for a
deterministic update. Upsert only avoids creating a new record if a phone number is also provided and matches an
existing contact.
Custom Fields
Store additional data using thecustomFields object. Fields are flexible key-value pairs:
Marketing Consent
Control channel-specific marketing consent when creating or updating a contact:| Field | Type | Description |
|---|---|---|
email | boolean | Email marketing opt-in (true) or opt-out (false) |
whatsapp | boolean | WhatsApp marketing opt-in (true) or opt-out (false) |
Both fields are optional. Omitting a channel leaves its current consent status unchanged. Setting
true opts the
contact in, false opts them out.Phone Numbers
For WhatsApp messaging, include a phone number in E.164 format:- Include country code (e.g.,
+39for Italy,+1for US) - No spaces, dashes, or parentheses
- Example:
+12025551234(US),+393391234567(Italy)
Common Errors
| Error | Cause | Solution |
|---|---|---|
validation_error | Invalid email format | Check email address format |
invalid_phone_number | Phone not in E.164 format | Add country code, remove spaces |
rate_limit_exceeded | Too many requests | Implement rate limiting, use batching |
unauthorized | Invalid API key | Verify API key in Authorization header |
Related Endpoints
- Get Contact by Email: Look up a contact by email
- Update Contact by ID: Update a specific contact by ID
- Delete Contact: Soft-delete a contact
- Custom Fields: Manage custom field definitions
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Response
Successful response
Example:
"12345"