# Scenario event

https://docs.sendsms.to/en/api/scenario-event/

`POST /v1/scenarios/{id}/events`

An event from your system (order ready, delivery status, abandoned cart, outage) becomes an SMS with the text of the scenario. One number (to): the SMS goes through the same handler as POST /v1/messages — channel, sender, tariff, funds and stop list checks included. A list (recipients): the event becomes a normal campaign of the scenario with the check and a report. In the quiet hours an event waits for their end unless the scenario sends events at once. A promotional scenario sends only to numbers that agreed to advertising (422 consent_required). 202 means accepted for processing, not delivered.

Required permission: messages.send

## Parameters

- `id` (path, required): Scenario ID from the cabinet: Scenarios → the scenario → API connection.
- `Idempotency-Key` (header, required): Required. Your own stable key per event, scoped to the scenario. The same key with the same body returns the original answer with duplicate:true and sends nothing again; the same key with another body returns 422 idempotency_key_reused. A timeout does not prove rejection: repeat with the same key. A header sent empty (or only spaces) is refused with 400 invalid_idempotency_key.
- `X-Dry-Run` (header, optional): Optional. true — a trial request: every check of the real request is made (key, IP allowlist, permission, account, fields, sender, template, parts, price, funds), but nothing is executed — no message, no reservation, no queue, no data change, the Idempotency-Key is not taken. The answer has the real status and structure plus dryRun: true; identifiers in it are conditional (zero UUID). Refusals are the real ones. Any other value — 400 invalid_dry_run. Trial requests have their own, lower rate limit.

## Request body

| Field | Type | Description |
| --- | --- | --- |
| `to` | string | optional. Recipient number in international format (digits, an optional +). Send either to or recipients, not both. |
| `recipients` | array<string> | optional. List of recipient numbers for a scenario that accepts lists (for example an outage notice). The limit per event is set by SendSMS; repeated numbers count once. |
| `variables` | object | optional. Values of the scenario text variables {{name}}: up to 30 values, each up to 500 characters. Every variable of the text must be filled. |

## Request example

```bash
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"
  }
}'
```

## Responses

### HTTP 202 — Successful result

```json
{
  "eventId": "00000000-0000-0000-0000-000000000011",
  "status": "queued",
  "messageId": "00000000-0000-0000-0000-000000000012"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `eventId` | string · uuid | required. Event identifier generated by SendSMS. Keep it to read the event later. |
| `status` | string | required. queued — the SMS was accepted by the same handler as POST /v1/messages (messageId); scheduled — it waits for the end of the quiet hours (sendAt); accepted — a list event that becomes a normal campaign of the scenario; refused — not sent (error explains why). |
| `messageId` | string | null · uuid | optional. Message identifier for GET /v1/messages/{id} (one-number events). |
| `sendAt` | string | null · date-time | optional. When a waiting event will be sent (the end of the quiet hours). |
| `recipients` | integer | optional. Number of distinct recipients of a list event. |
| `duplicate` | boolean | optional. true — a repeat of an event already accepted with this Idempotency-Key; nothing was sent again. |
| `campaignId` | string | null · uuid | optional. A list event: the campaign of the scenario run made from it. |
| `runState` | string | null | optional. A list event: the state of that run (preparing, review, scheduled, done, failed…). |
| `reasonCode` | string | null | optional. Why the event or its run did not go out, when it did not. |
| `dryRun` | boolean | optional. Present only in the answer to a trial request (X-Dry-Run: true): nothing was executed; identifiers in this answer are conditional. |

### HTTP 400 — Invalid input: no Idempotency-Key, both or neither of to and recipients, a wrong number, a list sent to a one-number scenario or the reverse.

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 401 — Invalid or revoked API key

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 402 — Insufficient available funds or credit

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 403 — Insufficient key permissions or account/channel policy; or the request came from an IP address not allowed for this key (ip_not_allowed)

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 404 — Resource unavailable to this account

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 409 — Conflict: the scenario is paused (scenario_not_active), or the first request with this key is still in progress (idempotency_in_progress, retryable).

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 413 — More numbers in the list than allowed per event.

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 422 — Validation failure: a text variable is missing (template_variables_missing), the key was used for another event (idempotency_key_reused), no consent to advertising (consent_required).

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 429 — Rate limit

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |

### HTTP 503 — Temporarily unavailable

```json
{
  "error": "string"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | required. Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
| `message` | string | optional. Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
| `code` | string | optional. Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
| `statusCode` | integer | optional. Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
