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

Send a survey trigger

Asks Sayvara to send one survey invitation to one contact after something happened, such as a delivered order or a finished visit.

Updated

POST /v1/triggers

Asks Sayvara to send one survey invitation to one contact after something happened, such as a delivered order or a finished visit. The contact is found by phone number (else email) or added.

The answer 202 means the invitation is queued. Consent, opt-out, contact frequency, send hours and plan limits are still checked before anything is sent, so a queued invitation may not be sent.

Send an Idempotency-Key header so a retried call never sends a second survey.

Property Value
Authentication API key or OAuth access token: Authorization: Bearer ...
Scope events.write
Success 202 Accepted

Headers

Header Required Description
Idempotency-Key No 8 to 128 visible ASCII characters, unique per event. A repeat with the same body answers replayed: true and queues nothing.

Request body

Content type: application/json.

Field Type Required Description
event string Yes What happened in your system, in lower case with dots, for example order.delivered or visit.completed. Kept on the invitation. At most 64 characters. Pattern ^[a-z][a-z0-9_]*(\.[a-z0-9_]+){0,3}$.
contact object Yes Who should get the survey. Send a phone number, an email address, or both.
contact.phone string No Mobile number in E.164 format, for example +966512345678. Pattern ^\+[1-9]\d{7,14}$.
contact.email string (email) No Email address. At most 254 characters.
contact.lang enum No Survey language for a new contact. One of ar, en.
reference string Yes Your own reference, such as an order number or visit id. It can be shown to the customer in the invitation. 1 to 64 characters.
occurredAt string (date-time) Yes When it happened, ISO 8601 with a time zone offset.
surveyId string (uuid) No The survey to send. Leave it out when your organisation has exactly one live survey.
orgUnitId string (uuid) No The branch or team the event belongs to.
kind enum No The kind of moment. One of call, visit, order, ticket. Default "visit".
{
  "event": "order.delivered",
  "contact": {
    "phone": "+966512345678",
    "email": "customer@example.com",
    "lang": "ar"
  },
  "reference": "ORD-10045",
  "occurredAt": "2026-11-01T09:30:00.000Z",
  "surveyId": "3f6c1a2e-8b4d-4c7a-9e21-5d0b7f3a9c10",
  "orgUnitId": "a7d1c3e9-2f4b-4a6c-8e0d-9b5f1c2a3e47",
  "kind": "order"
}

Response

202 Accepted

Field Type Description
invitationId string (uuid) The id of the queued invitation. With an Idempotency-Key, the same key always gives the same id.
status "queued" Always queued: the invitation waits for its send checks.
replayed boolean true when this Idempotency-Key was used before with the same body. Nothing new was queued.
{
  "invitationId": "3f6c1a2e-8b4d-4c7a-9e21-5d0b7f3a9c10",
  "status": "queued",
  "replayed": false
}

Errors

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

Status Code Meaning
400 VALIDATION_FAILED The body does not match the schema. details lists each field.
400 BAD_IDEMPOTENCY_KEY The Idempotency-Key is not 8 to 128 visible ASCII characters.
400 SURVEY_REQUIRED Several surveys are live: send surveyId.
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.
404 SURVEY_NOT_LIVE No live survey has this surveyId.
404 ORG_UNIT_NOT_FOUND No branch or team has this orgUnitId.
409 NO_LIVE_SURVEY Your organisation has no live survey.
422 IDEMPOTENCY_KEY_REUSED This Idempotency-Key was already used with a different body.
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/triggers" \
  -H "Authorization: Bearer $SAYVARA_API_KEY" \
  -H "Idempotency-Key: order-10045-delivered" \
  -H "Content-Type: application/json" \
  -d '{
  "event": "order.delivered",
  "contact": {
    "phone": "+966512345678",
    "email": "customer@example.com",
    "lang": "ar"
  },
  "reference": "ORD-10045",
  "occurredAt": "2026-11-01T09:30:00.000Z",
  "surveyId": "3f6c1a2e-8b4d-4c7a-9e21-5d0b7f3a9c10",
  "orgUnitId": "a7d1c3e9-2f4b-4a6c-8e0d-9b5f1c2a3e47",
  "kind": "order"
}'