HTTP API: Jobs
Push single or bulk jobs, pull work, update progress, and ACK or FAIL over REST
All 30 job endpoints under /queues/:queue/jobs* and /jobs/*. See HTTP API Overview for auth, envelopes, validation, and rate limits.
Enqueue & Dequeue
Section titled “Enqueue & Dequeue”Push a Job
Section titled “Push a Job”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:
| Field | Type | Default | Description |
|---|---|---|---|
data | any | - | JSON-serializable payload (max 10 * 1024 * 1024 JSON chars). |
name | string | "default" | Top-level job.name. |
priority | number | 0 | Higher runs first. With groupId, integer 0..2097151 (ascending group priority). |
delay | number | 0 | Delay in ms before ready. Negative values make the job ready immediately. |
maxAttempts | number | 3 | Max attempts before DLQ (attempts accepted as alias; cap 2,147,483,647). |
backoff | number | object | 1000 | Base delay in ms, or { "type": "fixed" | "exponential", "delay": ms, "maxDelay": ms } (maxDelay 0 to 1 day, default 1h). |
ttl | number | - | Time-to-live from creation in ms (>= 0). |
timeout | number | - | Active processing timeout in ms (0 = none). |
uniqueKey | string | - | Per-queue deduplication key; returns 200 with the existing job id on match. |
jobId | string | - | Custom ID (broker-wide; namespace-wide on PostgreSQL). See Custom-ID limits. |
tags | string[] | [] | Metadata tags. |
groupId | string | - | Job-group ID (FIFO ties + round-robin across groups). |
lifo | boolean | false | Last-in-first-out within the same priority. |
removeOnComplete | boolean | false | Delete job immediately after completion. |
removeOnFail | boolean | false | Delete job after terminal failure. |
durable | boolean | false | SQLite: bypass the 10ms write buffer and commit synchronously. |
dependsOn | string[] | [] | Prerequisite job IDs; enters waiting-children until all complete. |
repeat | object | - | { 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).
Push Jobs in Bulk
Section titled “Push Jobs in Bulk”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"] }
Pull a Job
Section titled “Pull a Job”GET /queues/:queue/jobs[?timeout=ms]
curl "http://localhost:6790/queues/emails/jobs?timeout=5000"timeout: Long-poll wait in ms (0..60000, default0,parseInt); invalid values return200with"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; workergroup.concurrency/group.limitrequire TCPPULL/PULLB.
Pull Jobs in Batch
Section titled “Pull Jobs in Batch”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}'| Field | Type | Required | Range / Notes |
|---|---|---|---|
count | number | Yes | 1 to 1000. |
timeout | number | No | 0 to 60000 (default 0), honored with or without owner. |
owner | string | No | Lock owner ID; when set, response also includes positional tokens. |
lockTtl | number | No | Lock TTL in ms. |
Response (200): { "ok": true, "jobs": [...], "tokens": [...] } (tokens present when owner is supplied).
Inspect & Cancel
Section titled “Inspect & Cancel”| Method | Path | Response (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-48737be2b0f9curl http://localhost:6790/jobs/custom/order-12345curl -X DELETE http://localhost:6790/jobs/019ce9d7-6983-7000-946f-48737be2b0f9Acknowledge & Fail
Section titled “Acknowledge & Fail”Acknowledge a Job
Section titled “Acknowledge a Job”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:completedand coalescedqueue:counts, resolvesdependsOndependents, and deletes the job ifremoveOnComplete: true.
Acknowledge Jobs in Batch
Section titled “Acknowledge Jobs in Batch”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.
Fail a Job
Section titled “Fail a Job”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)"]}'| Field | Type | Description |
|---|---|---|
error | string | Error message stored on the job and DLQ entry. |
token | string | Lock token when lock-based processing is used. |
unrecoverable | boolean | Skip remaining retries and move straight to DLQ. |
stack | string[] | 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:
| Mode | Formula | Jitter & Cap |
|---|---|---|
Numeric backoff (default 1000) | backoff * 2^attempt | Random multiplier 0.5 to 1.5, capped at 1 hour |
{ type: "exponential", delay, maxDelay? } | delay * 2^attempt | Random 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.
Mutate, Reschedule & Wait
Section titled “Mutate, Reschedule & Wait”| Method | Path | Body | Broadcast / 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/promote | none | Moves 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/discard | none | Sends 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}'Heartbeats, Locks, Progress & Logs
Section titled “Heartbeats, Locks, Progress & Logs”Progress
Section titled “Progress”GET /jobs/:id/progress->{ "ok": true, "progress": 75, "message": "Processing..." }POST /jobs/:id/progresswith{ "progress": 75, "message": "Processing..." }-> updates progress (0-100) and broadcastsjob:progress.
Heartbeats & Lock Extensions
Section titled “Heartbeats & Lock Extensions”| Method | Path | Body | Description |
|---|---|---|---|
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. |
Job Logs
Section titled “Job Logs”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"}'