Skip to main content

Tasks API

Create, monitor, cancel, and retry tasks in the queue.

Create Task

POST /api/tasks
Content-Type: application/json
{
"taskType": "file_change",
"documentId": "doc-abc-123",
"instanceId": "inst-xyz-789",
"priority": "NORMAL",
"payload": {
"prompt": "Rewrite the introduction paragraph to be more concise"
}
}

Response:

{
"id": "task-456",
"taskType": "file_change",
"state": "QUEUED",
"priority": "NORMAL",
"documentId": "doc-abc-123",
"createdAt": "2026-03-18T10:30:00Z"
}

List Tasks

GET /api/tasks
GET /api/tasks?state=RUNNING
GET /api/tasks?documentId=doc-abc-123
GET /api/tasks?priority=HIGH

Response:

[
{
"id": "task-456",
"taskType": "file_change",
"state": "RUNNING",
"priority": "NORMAL",
"documentId": "doc-abc-123",
"workerId": "worker-1",
"startedAt": "2026-03-18T10:30:02Z",
"retries": 0,
"maxRetries": 3
}
]

Cancel Task

POST /api/tasks/{id}/cancel

Response:

{
"id": "task-456",
"state": "CANCELLED",
"cancelledAt": "2026-03-18T10:31:00Z"
}

Retry Task

Retry a failed task. Resets the state to QUEUED.

POST /api/tasks/{id}/retry

Task Types

TypeDescription
file_changeModify a document via agent harness
content_generateGenerate new content
hookAutomated hook execution
prettyFormat/normalize a document
batch_editParent task with child edits

Priority Levels

PriorityValueUse Case
CRITICAL4System operations
HIGH3User-initiated actions
NORMAL2Standard operations
LOW1Background tasks