# Automation

An automation: a flow of steps that starts on a trigger, such as a work item being created, a schedule or a person starting it by hand, and runs with the permissions of the person who made it, its owner. It belongs to the whole organisation, to every project or customer, or to one project or customer. The flow itself is the automation's current version.

## Used by
- GET /api/v2/automations: List automations (AutomationList)
- POST /api/v2/automations: Create an automation (Automation)
- GET /api/v2/automations/{automation}: Read an automation (Automation)
- PATCH /api/v2/automations/{automation}: Update an automation (Automation)
- POST /api/v2/automations/{automation}/actions/activate: Switch an automation on (Automation)
- POST /api/v2/automations/{automation}/actions/deactivate: Switch an automation off (Automation)
- POST /api/v2/automations/{automation}/actions/duplicate: Copy an automation (Automation)
- POST /api/v2/automations/{automation}/actions/restore: Restore a deleted automation (Automation)
- POST /api/v2/automations/{automation}/actions/rotate-webhook-secret: Set a new secret for an automation's webhook (Automation)

## Automation fields
- id (integer, required): Unique identifier.
- name (string ≤ 255, required): Name as shown in the automations list.
- description (string or null, required, multiline): What the automation is for, in its makers' words.
- context_type (string or null, required): What the automation belongs to. `null` is the whole organisation. With a type, `context_id` names the one project or customer, or is `null` for every one of them. The scope decides which permissions apply: `automations`, `project_automations` or `customer_automations`.
- context_id (integer or null, required): The one project or customer the automation belongs to. `null` with a `context_type` means every project or every customer.
- owner_id (integer or null, required): The person who made the automation. Its runs use their permissions, so a step they may not do is refused when the flow is saved. `null` once that user is gone. It is whoever creates the automation and never changes, except for plnnrly support's own account, which must name a real person here when it creates or changes one.
- owner_requires_replacement (boolean, required): Whether the owner is plnnrly support's own account. Such an automation cannot be saved or switched on until a real person is named as its owner.
- is_active (boolean, required, server-assigned): Whether the automation is switched on. A new automation is always off.
- is_runnable (boolean, required): Whether triggers start runs right now: switched on, not paused and not deleted.
- paused_reason (string or null, required): Why plnnrly paused the automation, such as a step that kept failing. `null` while it is not paused. Switching it on again clears it. Never names record data.
- current_version_id (integer or null, required): The version whose flow runs. `null` until a flow is first saved.
- trigger_type (string or null ≤ 255, required, server-assigned): The step type of the flow's trigger, such as `trigger.record_created`, taken from the current version. See `GET /api/v2/automation-node-types`.
- trigger_record_type (string or null ≤ 255, required, server-assigned): The record type the trigger starts on, such as `work_item`, or `null` for a trigger without a record, such as a schedule.
- trigger_events (array of string, required): The record events the trigger starts on. Empty for a trigger that does not start on record events, such as a schedule or a date being reached.
- next_run_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When a schedule trigger next starts a run. `null` for other triggers.
- last_run_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When the automation last started a run.
- runs_count (integer, required): How many live runs the automation has started, as counted for the organisation's usage. Test runs and runs that were skipped are not counted.
- template_key (string or null ≤ 100, required): The template the automation was made from, `null` when it was built from scratch. See `GET /api/v2/automation-templates`. Send it on create to start from that template: its flow is saved as version 1, with the answers in `template_answers` in their places.
- manual_inputs (array of object, required, detail only): What a person fills in when they start the automation by hand, as its trigger declares it. Empty for an automation that is not started by hand.
  - name (string ≤ 40, required): The input's name; steps read it as `{{ input.<name> }}`.
  - type (string ≤ 20, required): `text`, `number`, `date`, `boolean` or `record`.
  - required (boolean, required): Whether a run cannot start without it.
  - record_type (string or null ≤ 255, optional): For a `record` input, the record type it takes, such as `customer`.
- webhook_url (string or null, required): The address other systems send requests to, for an automation whose trigger receives webhooks; `null` otherwise. Requests must also prove they know the automation's secret, which this API never returns.
- updated_by_id (integer or null, required): Who last saved the automation's flow or settings.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Creation timestamp.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync.
- deleted_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): Soft-delete timestamp, `null` while live. A deleted automation starts no runs.
- owner (Ref or UserSummary or null, required): The person who made the automation.
- updated_by (Ref or UserSummary or null, required): Who last saved the automation.
- current_version (Ref or AutomationVersionSummary or null, required): The version whose flow runs.
- versions_count (integer ≥ 0, required): Number of saved versions of the flow.
- links (AutomationLinks, required)
  - self (url, required): The canonical URI of this record.
  - versions (url, required): Every saved version of the flow, newest first.
  - runs (url, required): The automation's runs, newest first.

Only on `?view=detail`: manual_inputs

## Variants

### AutomationList

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

28 fields.
Omits: manual_inputs

### AutomationSummary

The embedded form: what you get when another resource carries this one and you did not `include` it.

2 fields.
Omits: description, context_type, context_id, owner_id, owner_requires_replacement, is_active, is_runnable, paused_reason, current_version_id, trigger_type, trigger_record_type, trigger_events, next_run_at, last_run_at, runs_count, template_key, manual_inputs, webhook_url, updated_by_id, created_at, updated_at, deleted_at, owner, updated_by, current_version, versions_count, links

### AutomationLinks

The `links` object on this resource.

Keys: self, versions, runs

## Columns deliberately not published
- builder_sample: The example record and request the builder's editors share, which hold record data.
- scanned_until: How far a date trigger has looked for dates that were reached: internal state.
- webhook_secret: Never readable over the API; only the builder shows it to its editors.
- webhook_token: Published only inside `webhook_url`.

## Example
```json
{
  "id": 1,
  "name": "Tell assignees about urgent work",
  "description": "…",
  "context_type": "project",
  "context_id": null,
  "owner_id": 1,
  "owner_requires_replacement": false,
  "is_active": false,
  "is_runnable": false,
  "paused_reason": "…",
  "current_version_id": 1,
  "trigger_type": "…",
  "trigger_record_type": "…",
  "trigger_events": [
    "created"
  ],
  "next_run_at": "2026-03-04T09:15:00Z",
  "last_run_at": "2026-03-04T09:15:00Z",
  "runs_count": 1,
  "template_key": "…",
  "manual_inputs": [
    {
      "name": "…",
      "type": "…",
      "required": false,
      "…": "1 optional field left out"
    }
  ],
  "webhook_url": "…",
  "updated_by_id": 1,
  "created_at": "2026-03-04T09:15:00Z",
  "updated_at": "2026-03-04T09:15:00Z",
  "deleted_at": "2026-03-04T09:15:00Z",
  "owner": null,
  "updated_by": null,
  "current_version": null,
  "versions_count": 1,
  "links": {
    "self": "https://<your-url>/api/v2/work-items/1",
    "versions": "https://<your-url>/api/v2/work-items/1",
    "runs": "https://<your-url>/api/v2/work-items/1"
  }
}
```
