Skip to content
Get started
Get started
View Markdown

HTTP API: Jobs

HTTP Job Lifecycle

Push single or bulk jobs, pull work, update progress, and ACK or FAIL over REST

admit POST /jobs & /bulk enqueue payload claim GET Pull / Batch optional lock token settle LOG Progress & Lock extend + addLog END /ack or /fail settle or DLQ Consistent { "ok": true, ... } envelopes across all /queues/:q/jobs and /jobs/:id routes
30 job endpoints: enqueue with priority, delay, dedup, or groups, pull statelessly or with lock tokens, append logs, and inspect results.

All 30 job endpoints under /queues/:queue/jobs* and /jobs/*. See HTTP API Overview for auth, envelopes, validation, and rate limits.

POST /queues/:queue/jobs

curl -X POST http://localhost:6790/queues/emails/jobs \
-H "Content-Type: application/json" \
-d '{"data": {"to": "user@test.com"}, "priority": 10, "delay": 5000}'

All request body fields are optional:

FieldTypeDefaultDescription
dataany-JSON-serializable payload (max 10 * 1024 * 1024 JSON chars).
namestring"default"Top-level job.name.
prioritynumber0Higher runs first. With groupId, integer 0..2097151 (ascending group priority).
delaynumber0Delay in ms before ready. Negative values make the job ready immediately.
maxAttemptsnumber3Max attempts before DLQ (attempts accepted as alias; cap 2,147,483,647).
backoffnumber | object1000Base delay in ms, or { "type": "fixed" | "exponential", "delay": ms, "maxDelay": ms } (maxDelay 0 to 1 day, default 1h).
ttlnumber-Time-to-live from creation in ms (>= 0).
timeoutnumber-Active processing timeout in ms (0 = none).
uniqueKeystring-Per-queue deduplication key; returns 200 with the existing job id on match.
jobIdstring-Custom ID (broker-wide; namespace-wide on PostgreSQL). See Custom-ID limits.
tagsstring[][]Metadata tags.
groupIdstring-Job-group ID (FIFO ties + round-robin across groups).
lifobooleanfalseLast-in-first-out within the same priority.
removeOnCompletebooleanfalseDelete job immediately after completion.
removeOnFailbooleanfalseDelete job after terminal failure.
durablebooleanfalseSQLite: bypass the 10ms write buffer and commit synchronously.
dependsOnstring[][]Prerequisite job IDs; enters waiting-children until all complete.
repeatobject-{ every, limit } or { pattern, tz?, startDate?, endDate?, immediately? }.

Unknown keys are ignored. For extended TCP PUSH fields (stallTimeout, timestamp, keepLogs, stackTraceLimit, sizeLimit, dedup, debounceId/debounceTtl, groupMaxSize, parentId, or flow failure policies), use Push Jobs in Bulk.

Response (200): { "ok": true, "id": "019ce9d7-6983-7000-946f-48737be2b0f9" } (UUID v7).

POST /queues/:queue/jobs/bulk

curl -X POST http://localhost:6790/queues/emails/jobs/bulk \
-H "Content-Type: application/json" \
-d '{"jobs": [{"data": {"to": "a@test.com"}, "priority": 5}, {"data": {"to": "b@test.com"}, "delay": 60000}]}'

Forwards the full job option set (customId instead of jobId, maxAttempts instead of attempts). dependsOn may reference another item’s customId in the same batch in any order. Validation is all-or-nothing (jobs[i]: ...). PostgreSQL batches are transactional; on memory/SQLite, a post-validation error (e.g., full group) can keep the accepted prefix.

Response (200): { "ok": true, "ids": ["id-1", "id-2"] }

GET /queues/:queue/jobs[?timeout=ms]

curl "http://localhost:6790/queues/emails/jobs?timeout=5000"
  • timeout: Long-poll wait in ms (0..60000, default 0, parseInt); invalid values return 200 with "ok": false.
  • Response (200): { "ok": true, "job": { "id", "queue", "data", "priority", "createdAt", "runAt", "attempts", "maxAttempts", "backoff", "progress", "tags", "lifo", "removeOnComplete", "removeOnFail", ... } } or { "ok": true, "job": null }.
  • Paused or rate-limited queues return null. HTTP pulls are stateless (stall detection recovers unacked jobs) and honor paused groups and manual group rate limits; worker group.concurrency/group.limit require TCP PULL/PULLB.

POST /queues/:queue/jobs/pull-batch

curl -X POST http://localhost:6790/queues/emails/jobs/pull-batch \
-H "Content-Type: application/json" \
-d '{"count": 10, "timeout": 5000, "owner": "worker-1", "lockTtl": 30000}'
FieldTypeRequiredRange / Notes
countnumberYes1 to 1000.
timeoutnumberNo0 to 60000 (default 0), honored with or without owner.
ownerstringNoLock owner ID; when set, response also includes positional tokens.
lockTtlnumberNoLock TTL in ms.

Response (200): { "ok": true, "jobs": [...], "tokens": [...] } (tokens present when owner is supplied).

MethodPathResponse (200)Notes
GET/jobs/:id{ "ok": true, "job": { ... } }Returns 404 if missing or deleted by removeOnComplete/removeOnFail.
GET/jobs/custom/:customId{ "ok": true, "job": { ... } }Looks up by push-time custom ID (jobId / customId).
GET/jobs/:id/state{ "ok": true, "id": "...", "state": "active" }waiting, prioritized, delayed, active, waiting-children, completed, failed, or unknown.
GET/jobs/:id/result{ "ok": true, "id": "...", "result": ... }Served from the 10,000-entry result LRU cache.
GET/jobs/:id/children{ "ok": true, "data": { "values": { "q:childId": ... } } }Completed child results for flow parent jobs (bare childId key if child was removed).
DELETE/jobs/:id{ "ok": true }Cancels waiting, prioritized, delayed, waiting-children, or completed jobs (keeping a payload-free completion record for dependents and preserving already-recorded events). Returns 200 with ok: false if missing, active, failed, or dependency-protected on PostgreSQL.
curl http://localhost:6790/jobs/019ce9d7-6983-7000-946f-48737be2b0f9
curl http://localhost:6790/jobs/custom/order-12345
curl -X DELETE http://localhost:6790/jobs/019ce9d7-6983-7000-946f-48737be2b0f9

POST /jobs/:id/ack

curl -X POST http://localhost:6790/jobs/019ce9d7-.../ack \
-H "Content-Type: application/json" \
-d '{"result": {"sent": true}, "token": "lock-token"}'

Optional result (cached in 10,000-entry LRU) and token (for locked pulls).

  • Response (200): { "ok": true }, or { "ok": true, "data": { "applied": false, "reason": "already-finalized" } } when the lease generation already timed out or finalized.
  • Error (400): { "ok": false, "error": "Job not found or not in processing state: <id>" }.
  • Frees the active slot, updates counters, broadcasts job:completed and coalesced queue:counts, resolves dependsOn dependents, and deletes the job if removeOnComplete: true.

POST /jobs/ack-batch

curl -X POST http://localhost:6790/jobs/ack-batch \
-H "Content-Type: application/json" \
-d '{"ids": ["id-1", "id-2"], "results": [{"a": 1}, null], "tokens": ["tok-1", "tok-2"]}'

ids is required; positional results and tokens are optional. Returns { "ok": true }, or { "ok": true, "data": { "ignoredIds": [...], "ignoredIndices": [...] } } if any lease generation was already finalized.

POST /jobs/:id/fail

curl -X POST http://localhost:6790/jobs/019ce9d7-.../fail \
-H "Content-Type: application/json" \
-d '{"error": "SMTP connection refused", "unrecoverable": false, "stack": ["at send (mail.ts:12)"]}'
FieldTypeDescription
errorstringError message stored on the job and DLQ entry.
tokenstringLock token when lock-based processing is used.
unrecoverablebooleanSkip remaining retries and move straight to DLQ.
stackstring[]Stack trace lines stored on the job and DLQ entry.

Response (200): { "ok": true }, or { "ok": true, "data": { "applied": false, "reason": "already-finalized" } } for an already-finalized lease generation.

Retry backoff schedule:

ModeFormulaJitter & Cap
Numeric backoff (default 1000)backoff * 2^attemptRandom multiplier 0.5 to 1.5, capped at 1 hour
{ type: "exponential", delay, maxDelay? }delay * 2^attemptRandom multiplier 0.5 to 1.5, capped at maxDelay (0 to 86,400,000 ms, default 1h)
{ type: "fixed", delay, maxDelay? }delay+/-20% jitter, capped at maxDelay

Once attempts reaches maxAttempts, the job moves to the queue’s DLQ.

MethodPathBodyBroadcast / Behavior
PUT/jobs/:id/data{ "data": { ... } }Replaces the full data object on queued, paused, waiting-children, or active jobs (or next repetition of a completed repeatable job). Broadcasts job:data-updated.
PUT/jobs/:id/priority{ "priority": 100, "lifo": true }Repositions a waiting or delayed job (lifo optional). Not valid for active jobs. Broadcasts job:priority-changed.
POST/jobs/:id/promotenoneMoves a delayed job to waiting. Returns 400 if not delayed. Broadcasts job:promoted.
POST/jobs/:id/move-to-wait{ "token"?: "..." }Releases active (requires token if locked), promotes delayed, retries failed from DLQ, or no-ops on waiting/prioritized.
POST/jobs/:id/move-to-delayed{ "delay": 60000, "token"?: "..." }Moves an active job to delayed (delay required; token required if locked).
PUT/jobs/:id/delay{ "delay": 30000 }Recalculates runAt = now + delay for queued jobs or delays an unlocked active job (for locked active jobs, use /move-to-delayed). Broadcasts job:delay-changed.
POST/jobs/:id/discardnoneSends waiting, prioritized, delayed, paused, or unlocked active job straight to DLQ (locked active jobs return 400; use TCP Discard with token). Broadcasts job:discarded.
POST/jobs/:id/wait{ "timeout"?: 30000 }Event-driven wait until completion (default 30000 ms, max 600000 ms). Returns { "ok": true, "completed": true, "result": ... } or { "ok": true, "completed": false }.
curl -X PUT http://localhost:6790/jobs/019ce9d7-.../priority \
-H "Content-Type: application/json" -d '{"priority": 100}'
curl -X POST http://localhost:6790/jobs/019ce9d7-.../wait \
-H "Content-Type: application/json" -d '{"timeout": 30000}'
  • GET /jobs/:id/progress -> { "ok": true, "progress": 75, "message": "Processing..." }
  • POST /jobs/:id/progress with { "progress": 75, "message": "Processing..." } -> updates progress (0-100) and broadcasts job:progress.
MethodPathBodyDescription
POST/jobs/:id/heartbeat{ "token"?: "...", "duration"?: 30000 }Resets stall timer on an active job (both fields optional).
POST/jobs/heartbeat-batch{ "ids": [...], "tokens"?: [...] }Batch heartbeat for multiple active jobs.
POST/jobs/:id/extend-lock{ "duration": 30000, "token": "..." }Extends lock TTL on an active job.
POST/jobs/extend-locks{ "ids": [...], "tokens": [...], "durations": [...] }Positional batch lock extension.

Stored in an LRU cache (100 entries/job, 10,000 jobs max):

  • POST /jobs/:id/logs: { "message": "...", "level"?: "info" | "warn" | "error" } (default "info").
  • GET /jobs/:id/logs: { "ok": true, "data": { "logs": [{ "timestamp", "level", "message" }], "count": 1 } }.
  • DELETE /jobs/:id/logs: { "ok": true }.
curl -X POST http://localhost:6790/jobs/019ce9d7-.../logs \
-H "Content-Type: application/json" -d '{"message": "SMTP connected", "level": "info"}'