SendSMSby ZEXTELDocumentation
EN
Cabinet
Open MarkdownOpen in ChatGPTOpen in Claude
⋯ Page actions
Open MarkdownOpen in ChatGPTOpen in ClaudeOpen in CursorOpen in PerplexityOpen in Gemini (question is copied)Open in Microsoft CopilotOpen in IBM Bob (question is copied)

Sending

Event scenarios

An event of your system — an order is ready, a cart was abandoned, an outage — becomes an SMS with the text of a scenario you set up in the cabinet.

#How it works

  1. In the cabinet switch on an “on event” scenario and set up the text with {{name}} variables.
  2. On the scenario page, “Connect via API”, take its identifier (UUID).
  3. Your system sends an event: POST /v1/scenarios/{id}/events with a number (to) or a list of numbers (recipients) and the variable values.
  4. The state of the event: GET /v1/scenarios/{id}/events/{eventId}.
POST /v1/scenarios/{id}/events

cURL. The key is in the SENDSMS_API_KEY environment variable.

curl --max-time 30 --request POST \
  --url 'https://api.sendsms.to/v1/scenarios/SCENARIO_ID/events' \
  --header "X-API-Key: $SENDSMS_API_KEY" \
  --header "Idempotency-Key: $(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)" \
  --header 'Content-Type: application/json' \
  --data '{
  "to": "994XXXXXXXXX",
  "variables": {
    "order_id": "A-10492",
    "place": "12 Nizami St"
  }
}'
202 Response
{
  "eventId": "00000000-0000-0000-0000-000000000011",
  "status": "queued",
  "messageId": "00000000-0000-0000-0000-000000000012"
}

202: status: queued — the SMS went the same way as POST /v1/messages; keep eventId to ask for the event state. All fields and responses — on the method page →

#One number or a list

  • to — one SMS goes the same way as POST /v1/messages: channel, sender, funds and stop list are checked the same; the answer carries messageId.
  • recipients — the event becomes a normal campaign of the scenario with a check and a report; the answer carries the state of the run.
  • Send either to or recipients, not both.

#Repeats and quiet hours

  • Idempotency-Key is required: the same key with the same body returns the original answer with duplicate: true and sends nothing again; the same key with another body gives 422 idempotency_key_reused.
  • During quiet hours an event waits for their end (status: scheduled, sendAt) unless the scenario sends events at once.
  • A promotional scenario sends only to numbers that agreed to advertising, otherwise 422 consent_required.
  • A paused scenario answers 409 scenario_not_active.

The list of scenarios is not given out through the API: take the identifier in the cabinet. The key needs the messages.send permission.

GET /v1/scenarios/{id}/events/{eventId}

cURL. The key is in the SENDSMS_API_KEY environment variable.

curl --max-time 30 --request GET \
  --url 'https://api.sendsms.to/v1/scenarios/SCENARIO_ID/events/EVENT_ID' \
  --header "X-API-Key: $SENDSMS_API_KEY"
200 Response
{
  "eventId": "00000000-0000-0000-0000-000000000011",
  "status": "sent",
  "messageId": "00000000-0000-0000-0000-000000000012"
}

status: sent — the event SMS is sent; its status from now on — by messageId. All fields and responses — on the method page →

Type to search