Help centre
العربية Back to sayvara.com

Add or update a contact

Adds a contact, or finds the one with this phone number (else email) and fills in only its empty fields.

Updated

POST /v1/automation/actions/contacts

Adds a contact, or finds the one with this phone number (else email) and fills in only its empty fields. It never overwrites a value that is already set. Send a phone number, an email address, or both.

Property Value
Authentication API key or OAuth access token: Authorization: Bearer ...
Scope contacts.write
Success 200 OK

Request body

Content type: application/json.

Field Type Required Description
phone string No Mobile number in E.164 format. Pattern ^\+[1-9]\d{6,14}$.
email string (email) No Email address. At most 254 characters.
lang enum No Preferred language. One of ar, en.
name string No The contact's name. At most 200 characters.
externalRef string No Your own id for the contact. 1 to 200 characters.
{
  "phone": "+966512345678",
  "email": "customer@example.com",
  "lang": "ar",
  "name": "Sara Ahmed",
  "externalRef": "CRM-55102"
}

Response

200 OK

Field Type Description
contactId string (uuid) The contact's id.
created boolean true when a new contact was made, false when an existing one was found.
{
  "contactId": "3f6c1a2e-8b4d-4c7a-9e21-5d0b7f3a9c10",
  "created": false
}

Errors

Errors have the body { "code": "...", "message": "...", "requestId": "..." }. See Errors.

Status Code Meaning
400 VALIDATION_FAILED The body does not match the schema, or it has neither phone nor email.
401 INVALID_API_KEY The API key or access token is missing, wrong, revoked or expired.
403 ENTITLEMENT_REQUIRED The trial has ended: the organisation is read-only until a plan is chosen.
403 API_KEY_SCOPE The key or token does not hold the scope this operation needs.
403 IP_NOT_ALLOWED An OAuth access token was used from an address outside its client's allow-list.
403 ENTITLEMENT_REQUIRED Your plan does not include API access.
429 RATE_LIMITED Too many requests. Wait for the number of seconds in the Retry-After header.

Example request

curl -X POST "https://api.sayvara.com/v1/automation/actions/contacts" \
  -H "Authorization: Bearer $SAYVARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "phone": "+966512345678",
  "email": "customer@example.com",
  "lang": "ar",
  "name": "Sara Ahmed",
  "externalRef": "CRM-55102"
}'