# POST /api/v2/automation-runs

Start an automation by hand

- MCP id: automation-runs.store
- Scope: api:write:automations
- Scope: api:write:project_automations
- Scope: api:write:customer_automations
- Permission: automations::run
- Needs the automations feature on your organisation
- Rate cost: 1 unit, write bucket. A write costs the same whatever `view` you ask for.
- Cache-Control: private, no-store

Starts a run of an automation whose trigger is started by hand, as you, and answers `201` with the run and its `Location`, whatever happens next: it is usually `pending` until a worker picks it up, and `throttled` or `skipped` when a limit or a state stops it.

For an automation that runs on a record, send `record_id`, its key as a string such as `"42"` or a work item's issue key: a record you may see that lies where the automation applies. For an automation of every project or customer, `context_id` names the one it runs in. `inputs` holds what its trigger asks for, by name (`manual_inputs` on the automation lists them); each is checked, and a name it does not ask for is refused. An automation that is off, paused or deleted answers `409` `not_runnable`, one not started by hand `409` `not_manual`. Over MCP the user must agree first (`confirm: true`); over HTTP send an `Idempotency-Key` so a retry does not start a second run. The declared permission is `automations::run`; for a project or customer automation, the `project_automations` or `customer_automations` permission of the same action applies instead.

## Parameters
- view (string, optional): Which field set to render.
- X-Request-Id (header, optional): A correlation id of your own. It is recorded in our logs next to the server's request id but never returned: the response header always carries the server's id. A value that does not match the pattern is discarded silently, never rejected.
- Idempotency-Key (header, optional): A caller-chosen key that makes this POST safe to retry. Replaying it returns the original response with Idempotency-Replayed: true.

## Request body
- automation_id (integer → Automation.id, required): The automation that ran.
- record_id (string or null ≤ 255, optional): The key of that record. Shown to every reader, as the run page shows it.
- context_id (integer or null, optional): For an automation of every project or customer, the one the run happened in.
- inputs (object, optional): What the person who started it filled in, by input name. `null` when `reveals_data` is false.

Unknown keys are refused with `422` validation-failed, naming the key.

## Response 201
- 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.

## Errors
- 403 forbidden-by-policy | insufficient-permission | insufficient-token-scope: Forbidden.
- 409 idempotency-key-in-flight | idempotency-key-reused | state-conflict: Conflict.
- 415 unsupported-media-type: Unsupported media type.
- 422 unprocessable-relationship | validation-failed: Unprocessable content.
- 400 idempotency-key-required | invalid-cursor | invalid-query-parameter | malformed-request | unsupported-parameter: Bad request.
- 401 token-expired | unauthenticated: Unauthenticated.
- 404 endpoint-not-found | resource-not-found: Not found.
- 406 not-acceptable: Not acceptable.
- 429 rate-limit-exceeded: Too many requests.
- 500 internal-error: Server error.
- 503 tenant-unavailable: Service unavailable.

## Example
```bash
curl -X POST \
  'https://<your-url>/api/v2/automation-runs' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: <key>' \
  -d '{
    "automation_id": 1,
    "inputs": {
      "client": "Acme",
      "amount": 1200
    }
  }'
```
