Skip to main content

HTTP API

The default address is http://localhost:8080. The daemon serves plaintext HTTP; configure authentication, TLS, and rate limits at your deployment boundary when required.

Queue a Task

POST /queue persists a task and returns HTTP 200 with its ID. Completion is asynchronous.
type and data are required. data may be any JSON value supported by your handler. priority is an integer, default 50. Higher values are selected first when DAEMON_TASK_SELECTION=priority; the API does not enforce a 0–100 range. The task stores the daemon’s configured retry budget at enqueue time.

Get a Task

GET /api/tasks/{task_id} returns HTTP 200 or 404 if the task does not exist.
attempts starts at zero and increments when a retry is scheduled or the task is marked Failed, including a terminal failure. Successful completion does not increment it. Before execution, the handler request sets attempt = attempts + 1: an initial success therefore sends attempt: 1 but returns API attempts: 0; an initial terminal failure stores attempts: 1. Recovery can repeat an execution with the same request attempt, so neither field is a count of all handler executions.

List Recent Tasks

GET /api/tasks returns an array of up to 20 recent tasks with id, task_type, status, and created_at. This HTTP endpoint has no limit or status query filter.

Delete a Task

DELETE /api/tasks/{task_id} returns HTTP 204 with an empty body when deleted, or 404 when absent. Deleting a Processing task does not cancel an external action already executing in its handler.

Redrive a Failed Task

POST /api/tasks/{task_id}/redrive returns HTTP 200 with an empty body when a Failed task becomes Pending. It returns 404 for a missing task or a task that is not Failed. Redrive clears the last error and makes the task visible; it preserves its stored attempt count and retry budget.

Health

GET /health reads the exact current Pending count from storage:
Pending excludes Processing claims and includes retries waiting for visibility. This is a daemon/queue check, not handler readiness. If storage cannot be read, the current HTTP endpoint returns an unhealthy JSON response with a zero fallback count and HTTP 200; health clients must inspect status.

Metrics

GET /metrics exposes Prometheus metrics, for example:
GET /api/metrics returns JSON:
Counters describe this daemon process and reset on restart. Queue size is sampled once per second while workers run; it may lag recent mutations. /health performs a fresh count. Failed summary counts include terminal failures and timeouts across all task types; retry scheduling is excluded.

API Schema and Errors

Swagger UI is at /docs; its OpenAPI schema is at /api-docs/openapi.json. Malformed input or UUIDs return 400; missing tasks return 404; storage/internal failures return 500. These routes generally return empty error bodies rather than a JSON { "error": ... } object.