Automation rules API
Rules are the synced entity rule, personal like a label: name (content, encrypted for an encrypted account), enabled, trigger, condition, actions, steps (each one whole value), position, created_at, deleted_at.
Implementation notes
Rules (OpenSpec automation-rules; guide: automations.md) are the synced entity rule, personal like a label: name (content, encrypted for an encrypted account), enabled, trigger, condition, actions, steps (each one whole value), position, created_at, deleted_at. The app calls a rule a routine: a rule with steps: null is one Change tasks step with its actions; a routine of more than one step keeps them in steps (OpenSpec routines-engine, see Routines). Devices write them through /api/v1/sync; the REST routes below add id checks. The server runs them; their state (run log, watermarks, pauses) is server data, never operations. Every route answers 403 demo_restricted on the public demo.
- GET
/api/v1/me/rules - PUT
/api/v1/me/rules/paused - GET
/api/v1/rules - POST
/api/v1/rules - GET
/api/v1/rules/{id} - PATCH
/api/v1/rules/{id} - DELETE
/api/v1/rules/{id} - GET
/api/v1/rules/{id}/runs - POST
/api/v1/rules/{id}/test - GET
/api/v1/settings/automations - PUT
/api/v1/settings/automations
GET /api/v1/me/rules
List me rules · Token or session
{enabled, paused, rules: {id: {last_run, runs_7d, paused_reason}}}
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
paused required | boolean | |
rules | object |
PUT /api/v1/me/rules/paused
Update me rules paused · Token or session
{paused} → {enabled, paused}: pause or resume all your rules
| Field | Type | Description |
|---|---|---|
paused | boolean | null |
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
paused required | boolean |
GET /api/v1/rules
List rules · Token or session
{rules: [...]}
POST /api/v1/rules
Create a rule · Token or session
{name, trigger, condition?, actions?, steps?, enabled?, workspace_id?} → 201 (a rule needs actions or steps); ids are resolved (live labels, projects, sections of that project, your webhooks), a project action into a shared project is refused (400 invalid_input), a comment action on an encrypted account answers 409 encryption_enabled, a 51st rule 409 limit_reached
| Field | Type | Description |
|---|---|---|
reused | string |
| Field | Type | Description |
|---|---|---|
reused | string |
GET /api/v1/rules/{id}
Get a rule · Token or session
like every collection
| Field | Type | Description |
|---|---|---|
id required | string | path |
PATCH /api/v1/rules/{id}
Update a rule · Token or session
like every collection
| Field | Type | Description |
|---|---|---|
id required | string | path |
DELETE /api/v1/rules/{id}
Delete a rule · Token or session
like every collection
| Field | Type | Description |
|---|---|---|
id required | string | path |
GET /api/v1/rules/{id}/runs
List rule runs · Token or session
{runs: [...]}, newest first, at most 100: id, rule_id, occurrence (the run key), task_id, at, outcome (pending, applied, already_matched, skipped, stopped, failed, partial), reason, changes ([{task_id, fields}]), depth; another account's rule answers 404 not_found
| Field | Type | Description |
|---|---|---|
id required | string | path |
| Field | Type | Description |
|---|---|---|
runs required | array of object | |
runs[].ai_auto | boolean | |
runs[].at | number | |
runs[].blocks | array of object | |
runs[].blocks[].date | string | |
runs[].blocks[].from | string | |
runs[].blocks[].ids | array of string | |
runs[].blocks[].kind required | string | |
runs[].blocks[].span | string | |
runs[].blocks[].to | string | |
runs[].changes | string | |
runs[].depth | number | |
runs[].device_id | string | |
runs[].duration_ms | number | |
runs[].failed_step | number | |
runs[].id | number | |
runs[].note_id | string | |
runs[].occurrence | string | |
runs[].outcome | string | |
runs[].project_id | string | |
runs[].proposal | object | null | |
runs[].proposal.applied required | number | |
runs[].proposal.created_at required | number | |
runs[].proposal.encrypted required | boolean | |
runs[].proposal.envelope | string | |
runs[].proposal.expires_at required | number | |
runs[].proposal.id required | string | |
runs[].proposal.items required | number | |
runs[].proposal.list | array of object | |
runs[].proposal.rule_id required | string | |
runs[].proposal.run_id required | string | |
runs[].proposal.skipped required | number | |
runs[].proposal.state required | string | |
runs[].reason | string | |
runs[].rule_id | string | |
runs[].run_as | string | |
runs[].run_id | string | |
runs[].source | string | |
runs[].steps | array of object | |
runs[].steps[].duration_ms required | number | |
runs[].steps[].error | string | |
runs[].steps[].ids required | array of string | |
runs[].steps[].index required | number | |
runs[].steps[].items required | number | |
runs[].steps[].kind required | string | |
runs[].steps[].output required | string | |
runs[].steps[].status required | string | |
runs[].steps[].step_id required | string | |
runs[].steps[].tokens | number | |
runs[].steps_count | number | |
runs[].task_id | string | |
runs[].test | boolean | |
runs[].tokens | number | |
runs[].undone_at | number | null | |
runs[].writes | number |
POST /api/v1/rules/{id}/test
Rule test · Token or session
{task_id} → {matches, changes, skipped, steps, writes}: the condition and the planned changes on one task now, and each step's plan; nothing is written. task_id may be left out for a routine that does not read the trigger's task
| Field | Type | Description |
|---|---|---|
id required | string | path |
| Field | Type | Description |
|---|---|---|
task_id required | string |
| Field | Type | Description |
|---|---|---|
changes required | object | |
matches required | boolean | |
skipped required | array of string | |
steps required | array of object | |
steps[].changes | array of object | |
steps[].changes[].base | object | |
steps[].changes[].create | boolean | |
steps[].changes[].entity required | string | |
steps[].changes[].entityId required | string | |
steps[].changes[].patch required | object | |
steps[].duration_ms required | number | |
steps[].error | string | |
steps[].estimate | number | |
steps[].ids required | array of string | |
steps[].index required | number | |
steps[].items required | number | |
steps[].kind required | string | |
steps[].output required | string | |
steps[].preview | string | number | array of string | object | array of object | A preview of the step's output, by its type: text and a date are a string, lines a list of strings, a number a number, a task or a note {id, title}, a project {id, name}, tasks or notes a list of {id, title}. |
steps[].status required | string | |
steps[].step_id required | string | |
steps[].tokens | number | |
steps[].warning | object | null | |
steps[].warning.kind required | string | |
steps[].warning.message required | string | |
steps[].warning.reason required | string | |
steps[].warning.setting | string | |
steps[].warning.step required | string | |
writes required | number |
GET /api/v1/settings/automations
List settings automations · Token or session
{enabled} → {enabled, locked, locked_by}; 409 set_by_environment while OPENTODO_AUTOMATIONS is set; a change is recorded as settings.changed (automations.enabled)
Only the server's owner.
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
locked required | boolean | |
locked_by required | string |
PUT /api/v1/settings/automations
Update settings automations · Token or session
{enabled} → {enabled, locked, locked_by}; 409 set_by_environment while OPENTODO_AUTOMATIONS is set; a change is recorded as settings.changed (automations.enabled)
Only the server's owner.
| Field | Type | Description |
|---|---|---|
enabled required | boolean |
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
locked required | boolean | |
locked_by required | string |