# AutomationRun

One run of an automation: what started it, how it went and when. What its steps worked with is shown only to whoever may see the run's record, or, for a run without a record, whoever may change the automation: `reveals_data` says which, and everything else is left out or told without data.

## Used by
- GET /api/v2/automation-runs: List automation runs (AutomationRunList)
- POST /api/v2/automation-runs: Start an automation by hand (AutomationRun)
- GET /api/v2/automation-runs/{automation_run}: Read an automation run (AutomationRun)
- POST /api/v2/automation-runs/{automation_run}/actions/cancel: Cancel a waiting automation run (AutomationRun)

## AutomationRun fields
- id (integer, required): Unique identifier.
- uuid (string ≤ 36, required): The run's public id, which a webhook's answer hands the sender. Reads the same as `id` in the path.
- automation_id (integer, required): The automation that ran.
- automation_version_id (integer or null, required): The version of the flow the run started with. `null` once that version is gone.
- status (string, required): `pending` until a worker picks it up, `running`, `waiting` (such as at a Wait step), and finally `completed`, `failed`, `halted` (a step stopped it), `skipped` (not started, such as while switched off) or `throttled` (over a limit).
- mode (string, required): `live` for a run its trigger started, `test` for one an editor started to try the flow out.
- trigger_kind (string ≤ 20, required): What started it: `record` (a record event), `schedule`, `date`, `manual`, `webhook` or `automation` (a step of another automation).
- trigger_event (string or null, required): For a run a record event started, which event.
- record_type (string or null ≤ 255, required): The record type the run started on, such as `work_item`; `null` without a record.
- record_id (string or null ≤ 255, required): The key of that record. Shown to every reader, as the run page shows it.
- record_title (string or null, required): The record's title, only when the reader may see the record.
- context_id (integer or null, required): For an automation of every project or customer, the one the run happened in.
- parent_run_id (integer or null, required): The run of another automation whose step started this one, when the reader may see that automation.
- triggered_by_id (integer or null, required): Who started it, by hand or with the change that set it off.
- run_as_id (integer or null, required): Whose permissions its steps used: the automation's owner, or the editor for a test.
- attempts (integer, required): How often a worker took the run up, retries included.
- started_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When the first step began.
- finished_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When it ended; `null` while it is not finished.
- duration_ms (integer or null, required): How long it ran, in milliseconds.
- resume_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): While it waits, when it carries on at the latest.
- failure_reason (string or null, required): Why it failed, halted or was skipped. Record data appears in it only when `reveals_data` is true.
- reveals_data (boolean, required): Whether you may see what the run worked with: for a run on a record, whether you may see that record; otherwise, whether you may change the automation. Without it, `inputs`, `changes` and the steps' `input` and `output` are empty and messages carry no record data.
- inputs (object or null, required, detail only): What the person who started it filled in, by input name. `null` when `reveals_data` is false.
- changes (object, required, detail only): For a run a change started, the fields that changed, each `{label, old, new}`, without the fields you may not read. Empty unless you may see the record.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): When the run was started.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync.
- automation (Ref or AutomationSummary, required): The automation that ran.
- version (Ref or AutomationVersionSummary or null, required): The version of the flow the run started with.
- triggered_by (Ref or UserSummary or null, required): Who started it.
- run_as (Ref or UserSummary or null, required): Whose permissions its steps used.
- steps_count (integer ≥ 0, required): How many step executions the run recorded.
- links (AutomationRunLinks, required)
  - self (url, required): The canonical URI of this record.
  - steps (url, required): What each step of the run did.

Only on `?view=detail`: inputs, changes

## Variants

### AutomationRunList

What a collection returns, and what `?view=summary` returns on a single record.

30 fields.
Omits: inputs, changes

### AutomationRunLinks

The `links` object on this resource.

Keys: self, steps

## Columns deliberately not published
- awaiting_run_id: Names a run of another automation, which the reader may not be allowed to see.
- causation: Which automations led to the run: internal bookkeeping against loops.
- counted_at: When the run was counted for usage: internal bookkeeping.
- trigger: Holds a snapshot of the record's fields; published as `trigger_kind`, `record_type`, `record_id`, `context_id`, `inputs` and `changes`, each as the reader may see it.

## Example
```json
{
  "id": 1,
  "uuid": "…",
  "automation_id": 1,
  "automation_version_id": 1,
  "status": "pending",
  "mode": "live",
  "trigger_kind": "…",
  "trigger_event": "created",
  "record_type": "…",
  "record_id": "…",
  "record_title": "…",
  "context_id": 1,
  "parent_run_id": 1,
  "triggered_by_id": 1,
  "run_as_id": 1,
  "attempts": 1,
  "started_at": "2026-03-04T09:15:00Z",
  "finished_at": "2026-03-04T09:15:00Z",
  "duration_ms": 1,
  "resume_at": "2026-03-04T09:15:00Z",
  "failure_reason": "…",
  "reveals_data": false,
  "inputs": {},
  "changes": {},
  "created_at": "2026-03-04T09:15:00Z",
  "updated_at": "2026-03-04T09:15:00Z",
  "automation": {
    "id": 1
  },
  "version": null,
  "triggered_by": null,
  "run_as": null,
  "steps_count": 1,
  "links": {
    "self": "https://<your-url>/api/v2/work-items/1",
    "steps": "https://<your-url>/api/v2/work-items/1"
  }
}
```
