Skip to content
AISARAISAR
Automations

Automations

Scenario run finished

automation.run.finished

Fires 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:

http
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

json
{
  "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

FieldTypeDescription
run.idstringRun ID. Use it as the deduplication key
run.automation_idstringScenario ID
run.automation_namestring|nullScenario name at the moment the event is sent
run.version_idstring|nullID of the scenario version the run used
run.statusstringFinal run status, for example `success`, `goal_reached`, `cancelled`, `failed`, `error`
run.outcomestringNormalized 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_reasonstring|nullRun exit reason code (for example `stopped`, `handoff`, `restarted`), if any
run.error_codestring|nullSet 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_idinteger|nullRun contact ID
run.conversation_idinteger|nullID of the conversation the run started from; `null` if the run is not tied to one
run.channel_idinteger|nullRun channel ID; `null` if there is none
run.started_atstring|nullRun start (ISO 8601)
run.finished_atstring|nullRun end (ISO 8601)
run.duration_msinteger|nullRun duration in milliseconds, including waits
run.next_run_idstring|nullID of the next run on a hand-off to another scenario, otherwise `null`