Automations
Scenario run finished
automation.run.finishedFires once, when a scenario run first moves into a final status: completed, stopped, handed off to another scenario, cancelled or failed. Test runs and dry runs do not send the event. The event carries run metadata only: no scenario variables, message texts or error texts. If you need the collected data (for example the customer answers from the "Ask and save" block), send it from the scenario with the "Send webhook" step on the "Collected" branch. A run without a channel is not delivered to an integration bound to a channel list. The event is not broadcast over WebSocket. The platform sends the event once per run, but a delivery can be repeated (retries), so use `data.run.id` as the deduplication key on the receiving side.
HTTP request
AISAR sends a signed POST request to your webhook_url:
POST {webhook_url}
Content-Type: application/json
X-AISAR-Signature: sha256=...
{
"event": "automation.run.finished",
"event_id": "evt_01JXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2026-11-15T10:05:12.000000Z",
"company_id": 1,
"data": {
"run": {
"id": "01JXXXXXXXXXXXXXXXXXXXXXXX",
"automation_id": "5",
"automation_name": "Сбор заявки",
"version_id": "12",
"status": "success",
"outcome": "completed",
"exit_reason": null,
"error_code": null,
"contact_id": 301,
"conversation_id": 8841,
"channel_id": 17,
"started_at": "2026-11-15T10:00:03.000000Z",
"finished_at": "2026-11-15T10:05:12.000000Z",
"duration_ms": 309000,
"next_run_id": null
}
}
}The X-AISAR-Signature header carries an HMAC-SHA256 signature of the request body — use it to verify the request came from AISAR.
Example payload
{
"event": "automation.run.finished",
"event_id": "evt_01JXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2026-11-15T10:05:12.000000Z",
"company_id": 1,
"data": {
"run": {
"id": "01JXXXXXXXXXXXXXXXXXXXXXXX",
"automation_id": "5",
"automation_name": "Сбор заявки",
"version_id": "12",
"status": "success",
"outcome": "completed",
"exit_reason": null,
"error_code": null,
"contact_id": 301,
"conversation_id": 8841,
"channel_id": 17,
"started_at": "2026-11-15T10:00:03.000000Z",
"finished_at": "2026-11-15T10:05:12.000000Z",
"duration_ms": 309000,
"next_run_id": null
}
}
}Payload fields
| Field | Type | Description |
|---|---|---|
run.id | string | Run ID. Use it as the deduplication key |
run.automation_id | string | Scenario ID |
run.automation_name | string|null | Scenario name at the moment the event is sent |
run.version_id | string|null | ID of the scenario version the run used |
run.status | string | Final run status, for example `success`, `goal_reached`, `cancelled`, `failed`, `error` |
run.outcome | string | Normalized result: `completed` (normal finish), `goal_reached` (the scenario goal was reached), `stopped` (stopped by the "Stop" block), `handed_off` (handed to another scenario or restarted), `cancelled` (cancelled, for example the scenario was switched off), `failed` (an error) |
run.exit_reason | string|null | Run exit reason code (for example `stopped`, `handoff`, `restarted`), if any |
run.error_code | string|null | Set only when `outcome=failed`, a value from a closed list: `wake_failed` (the run could not continue after a wait), `flow_limit` (loop protection fired), `handoff_dispatch_failed` (the hand-off to another scenario failed), `no_version` (the scenario has no version to run), `job_failed` (any other failure). The event carries no error text |
run.contact_id | integer|null | Run contact ID |
run.conversation_id | integer|null | ID of the conversation the run started from; `null` if the run is not tied to one |
run.channel_id | integer|null | Run channel ID; `null` if there is none |
run.started_at | string|null | Run start (ISO 8601) |
run.finished_at | string|null | Run end (ISO 8601) |
run.duration_ms | integer|null | Run duration in milliseconds, including waits |
run.next_run_id | string|null | ID of the next run on a hand-off to another scenario, otherwise `null` |