Create a contact
SDK platic.clients.create()
Creates a contact in the workspace. If one with that phone number or email already exists, it updates their profile.
Example
curl https://api.platic.ai/v1/clients \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "phoneNumber": "5215512345678", "name": "Ana" }' await platic.clients.create({ phoneNumber: "5215512345678", name: "Ana" }); Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Full name of the contact |
phoneNumber | string | ✓¹ | Phone number in E.164 format without +. A Mexican number sent as 521… is stored and returned as 52…; the contact is found with either form |
firstname | string | — | Contact's first name |
lastname | string | — | Contact's last name |
email | string | ✓¹ | Contact's email. Stored in lowercase |
birthdate | string | — | Date of birth. Format: dd/mm/yyyy |
gender | enum | — | Gender: male or female |
company | string | — | Company name |
country | enum | — | Country of residence (ISO 3166-1 alpha-2 code) |
state | string | — | State of residence |
city | string | — | City of residence |
address | string | — | Full address |
postalCode | string | — | Postal code |
tags | array | — | Array of tags |
customFields | object | — | Custom fields (see Custom fields) |
owners | array | — | List of the emails of the users responsible for the contact |
¹ Send phoneNumber, email or both. An email contact may not have a phone number.
{
"name": "Ana",
"phoneNumber": "524491234567",
"email": "ana@example.com",
"tags": ["vip"],
"customFields": {
"plate": "ABC123",
"reception_id": "REC001"
}
} Select custom fields (select)
For a select field, send the id or label of an active option in customFields. The API stores that option's id.
{
"name": "Ana",
"phoneNumber": "524491234567",
"customFields": {
"sales_stage": "Contacted"
}
} - If the value does not match any active option of the field, the API answers
400. - To clear the value of a
select, sendnullor an empty string"".
Response
{
"status": "success",
"message": "Client created successfully",
"data": {
"id": "274fc73cb7d84a17955914fdc1a1f9d0",
"wasUpdated": false
}
} | Field | Type | Description |
|---|---|---|
data.id | string | The contact's ID |
data.wasUpdated | boolean | false means a new contact was created; true means a contact with that phone number or email already existed and was updated instead of creating a new one |
Errors
| Status | details.code | When it happens |
|---|---|---|
400 | INVALID_REQUEST | A field is not valid, neither phoneNumber nor email is sent (details.issues points at phoneNumber), the body carries an unknown field, or a custom field is not defined or a select value matches no active option (details.issues carries the ["customFields", "<fieldId>"] path) |
400 | INVALID_REQUEST | The credential covers several workspaces and ?workspace= is missing, or the supplied workspace is not authorized. details.available lists the available ones and details.requested shows the one you sent |
400 | INVALID_PHONE_NUMBER | The phone number is not valid |
401 | UNAUTHENTICATED | The credential is missing or invalid |
403 | FORBIDDEN | The credential does not have the Contacts module (Missing contacts permission), or the user's role is read-only |
403 | INSUFFICIENT_SCOPE | An OAuth token without the platica:write scope tried to write. details.requiredScope says which one is missing |
404 | WORKSPACE_NOT_FOUND | The credential does not carry any workspace |
409 | MULTIPLE_CONTACTS_MATCH | Two contacts have that email: use the ID. details.clientIds lists them |
409 | CONFLICT | The contact's version was not available. Try again |
502 | UPSTREAM_ERROR | The profile write could not be confirmed. Check the contact before retrying |
The general error format is in Errors.