# Automations

Create and manage workflow automations. Includes sub-resources for triggers, actions, and execution runs. Supports enable/disable and manual triggering.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### GET /automations

List all automations for the company.

**Scopes:** `automations:read` — [full detail](./automations/get-automations.md)

### GET /automations/:id

Retrieve an automation with its triggers and actions.

**Scopes:** `automations:read` — [full detail](./automations/get-automations-id.md)

### POST /automations

Create a new automation. name and trigger_type are required. For stage_changed automations, pass stage_id directly on the automation -- this is the single source of truth for stage matching (do not use automations_triggers for stage_changed). Note: trigger_type "form_submitted" is deprecated and rejected -- use "form_completed" instead.

**Scopes:** `automations:write` — [full detail](./automations/post-automations.md)

### PATCH /automations/:id

Update an automation. Same writable fields as POST, including conditions. Pass conditions: null to remove all conditions from an automation.

**Scopes:** `automations:write` — [full detail](./automations/patch-automations-id.md)

### DELETE /automations/:id

Delete an automation and all its triggers/actions.

**Scopes:** `automations:write` — [full detail](./automations/delete-automations-id.md)

### POST /automations/:id/enable

Enable an automation.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-enable.md)

### POST /automations/:id/disable

Disable an automation.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-disable.md)

### POST /automations/:id/trigger

Manually trigger an automation with optional test data. Returns a normalized run response with inline action_results[].

**Scopes:** `automations:trigger` — [full detail](./automations/post-automations-id-trigger.md)

### GET /automations/:id/runs

List execution runs for an automation. Run status values: completed, failed, running, skipped. Status "skipped" means conditions were evaluated but not met -- the automation did not execute any actions.

**Scopes:** `automations:read` — [full detail](./automations/get-automations-id-runs.md)

### GET /automations/runs/:runId

Get details of a specific run. Returns normalized shape: run_id, status, actions_total, actions_executed, actions_failed, actions_skipped, action_results[] (per-step outcomes with action_type, status, request, response, error, duration_ms), truncated flag.

**Scopes:** `automations:read` — [full detail](./automations/get-automations-runs-runId.md)

### GET /automations/:id/triggers

List triggers for an automation.

**Scopes:** `automations:read` — [full detail](./automations/get-automations-id-triggers.md)

### POST /automations/:id/triggers

Add a trigger to an automation. source_type auto-populates from the parent automation trigger_type when omitted -- you only need to pass source_type to override the default. For stage_changed automations, use update_automation with stage_id instead -- adding a trigger row for stage_changed is rejected with a 400.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-triggers.md)

### PATCH /automations/:id/triggers/:triggerId

Update a trigger.

**Scopes:** `automations:write` — [full detail](./automations/patch-automations-id-triggers-triggerId.md)

### DELETE /automations/:id/triggers/:triggerId

Delete a trigger from an automation.

**Scopes:** `automations:write` — [full detail](./automations/delete-automations-id-triggers-triggerId.md)

### GET /automations/:id/actions

List actions for an automation, ordered by sequence.

**Scopes:** `automations:read` — [full detail](./automations/get-automations-id-actions.md)

### POST /automations/:id/actions

Add an action to an automation. action_type and sequence are required.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-actions.md)

### POST /automations/:id/actions/reorder

Reorder actions within an automation.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-actions-reorder.md)

### PATCH /automations/:id/actions/:actionId

Update an action.

**Scopes:** `automations:write` — [full detail](./automations/patch-automations-id-actions-actionId.md)

### DELETE /automations/:id/actions/:actionId

Delete an action from an automation.

**Scopes:** `automations:write` — [full detail](./automations/delete-automations-id-actions-actionId.md)

### POST /automations/:id/actions/:actionId/execute

Execute a single action in isolation, skipping all other actions in the chain. Reuses the full executor pipeline: variable substitution, recipient resolution, business-hours scheduling. Use for testing one action against real config (e.g. voice_outbound_call dialling a number) or retrying a single failing step without re-firing the entire automation. Cost is the same as the underlying action (e.g. voice_agent_minute credits for voice_outbound_call). Requires automations-trigger:trigger scope.

**Scopes:** `automations:write` — [full detail](./automations/post-automations-id-actions-actionId-execute.md)
