5 minutes to help shape OpenTodo. Anonymous, no account. Take the survey

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

List me rules · Token or session

{enabled, paused, rules: {id: {last_run, runs_7d, paused_reason}}}

Response 200
FieldTypeDescription
enabled requiredboolean
paused requiredboolean
rulesobject

PUT /api/v1/me/rules/paused

Update me rules paused · Token or session

{paused} → {enabled, paused}: pause or resume all your rules

Request body
FieldTypeDescription
pausedboolean | null
Response 200
FieldTypeDescription
enabled requiredboolean
paused requiredboolean

GET /api/v1/rules

List rules · Token or session

{rules: [...]}

Response 200: OK

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

Response 200
FieldTypeDescription
reusedstring
Response 201
FieldTypeDescription
reusedstring

GET /api/v1/rules/{id}

Get a rule · Token or session

like every collection

Path parameters
FieldTypeDescription
id requiredstringpath

Response 200: OK

PATCH /api/v1/rules/{id}

Update a rule · Token or session

like every collection

Path parameters
FieldTypeDescription
id requiredstringpath

Response 200: OK

DELETE /api/v1/rules/{id}

Delete a rule · Token or session

like every collection

Path parameters
FieldTypeDescription
id requiredstringpath

Response 200: OK

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

Path parameters
FieldTypeDescription
id requiredstringpath
Response 200
FieldTypeDescription
runs requiredarray of object
runs[].ai_autoboolean
runs[].atnumber
runs[].blocksarray of object
runs[].blocks[].datestring
runs[].blocks[].fromstring
runs[].blocks[].idsarray of string
runs[].blocks[].kind requiredstring
runs[].blocks[].spanstring
runs[].blocks[].tostring
runs[].changesstring
runs[].depthnumber
runs[].device_idstring
runs[].duration_msnumber
runs[].failed_stepnumber
runs[].idnumber
runs[].note_idstring
runs[].occurrencestring
runs[].outcomestring
runs[].project_idstring
runs[].proposalobject | null
runs[].proposal.applied requirednumber
runs[].proposal.created_at requirednumber
runs[].proposal.encrypted requiredboolean
runs[].proposal.envelopestring
runs[].proposal.expires_at requirednumber
runs[].proposal.id requiredstring
runs[].proposal.items requirednumber
runs[].proposal.listarray of object
runs[].proposal.rule_id requiredstring
runs[].proposal.run_id requiredstring
runs[].proposal.skipped requirednumber
runs[].proposal.state requiredstring
runs[].reasonstring
runs[].rule_idstring
runs[].run_asstring
runs[].run_idstring
runs[].sourcestring
runs[].stepsarray of object
runs[].steps[].duration_ms requirednumber
runs[].steps[].errorstring
runs[].steps[].ids requiredarray of string
runs[].steps[].index requirednumber
runs[].steps[].items requirednumber
runs[].steps[].kind requiredstring
runs[].steps[].output requiredstring
runs[].steps[].status requiredstring
runs[].steps[].step_id requiredstring
runs[].steps[].tokensnumber
runs[].steps_countnumber
runs[].task_idstring
runs[].testboolean
runs[].tokensnumber
runs[].undone_atnumber | null
runs[].writesnumber

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

Path parameters
FieldTypeDescription
id requiredstringpath
Request body
FieldTypeDescription
task_id requiredstring
Response 200
FieldTypeDescription
changes requiredobject
matches requiredboolean
skipped requiredarray of string
steps requiredarray of object
steps[].changesarray of object
steps[].changes[].baseobject
steps[].changes[].createboolean
steps[].changes[].entity requiredstring
steps[].changes[].entityId requiredstring
steps[].changes[].patch requiredobject
steps[].duration_ms requirednumber
steps[].errorstring
steps[].estimatenumber
steps[].ids requiredarray of string
steps[].index requirednumber
steps[].items requirednumber
steps[].kind requiredstring
steps[].output requiredstring
steps[].previewstring | number | array of string | object | array of objectA 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 requiredstring
steps[].step_id requiredstring
steps[].tokensnumber
steps[].warningobject | null
steps[].warning.kind requiredstring
steps[].warning.message requiredstring
steps[].warning.reason requiredstring
steps[].warning.settingstring
steps[].warning.step requiredstring
writes requirednumber

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.

Response 200
FieldTypeDescription
enabled requiredboolean
locked requiredboolean
locked_by requiredstring

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.

Request body
FieldTypeDescription
enabled requiredboolean
Response 200
FieldTypeDescription
enabled requiredboolean
locked requiredboolean
locked_by requiredstring

This group in the HTTP API guide