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

await platic.clients.create({ phoneNumber: "5215512345678", name: "Ana" });

Request body

FieldTypeRequiredDescription
namestring✓Full name of the contact
phoneNumberstring✓¹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
firstnamestring—Contact's first name
lastnamestring—Contact's last name
emailstring✓¹Contact's email. Stored in lowercase
birthdatestring—Date of birth. Format: dd/mm/yyyy
genderenum—Gender: male or female
companystring—Company name
countryenum—Country of residence (ISO 3166-1 alpha-2 code)
statestring—State of residence
citystring—City of residence
addressstring—Full address
postalCodestring—Postal code
tagsarray—Array of tags
customFieldsobject—Custom fields (see Custom fields)
ownersarray—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, send null or an empty string "".

Response

{
  "status": "success",
  "message": "Client created successfully",
  "data": {
    "id": "274fc73cb7d84a17955914fdc1a1f9d0",
    "wasUpdated": false
  }
}
FieldTypeDescription
data.idstringThe contact's ID
data.wasUpdatedbooleanfalse 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

Statusdetails.codeWhen it happens
400INVALID_REQUESTA 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)
400INVALID_REQUESTThe 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
400INVALID_PHONE_NUMBERThe phone number is not valid
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENThe credential does not have the Contacts module (Missing contacts permission), or the user's role is read-only
403INSUFFICIENT_SCOPEAn OAuth token without the platica:write scope tried to write. details.requiredScope says which one is missing
404WORKSPACE_NOT_FOUNDThe credential does not carry any workspace
409MULTIPLE_CONTACTS_MATCHTwo contacts have that email: use the ID. details.clientIds lists them
409CONFLICTThe contact's version was not available. Try again
502UPSTREAM_ERRORThe profile write could not be confirmed. Check the contact before retrying

The general error format is in Errors.