Skip to content
pushqdocs
Get started

A pushq task is one HTTP request that pushq makes for you: a URL, a method, headers and a body, plus when to send it and how to retry it. This page covers enqueuing tasks, delayed and scheduled tasks, deduplication with task_id, batch enqueue, and inspecting, running and cancelling tasks. Tasks live in a queue, whose rate limits and retry settings decide when each task is delivered.

The examples assume a client named pq (and a ctx in Go); see Install & configure an SDK. Tables use the JSON field names; the SDKs use their language’s casing (taskId in TypeScript and Java, task_id in Python, TaskID/TaskId in Go and .NET).

POST /v1/queues/{queue}/tasks creates one task and answers 201 with it.

const task = await pq.createTask("emails", {
path: "/hooks/send-welcome",
jsonBody: { userId: 42 },
delaySeconds: 3600,
taskId: "welcome-user-42",
retry: { maxAttempts: 5 },
});
Parameter Type Default Description
url string none Absolute http or https URL, at most 2083 characters. Set exactly one of url or path.
path string none Path starting with /, appended to the queue’s target.base_url at delivery time. The queue must have a base_url when you create the task.
method string POST GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS (case-insensitive). A queue target.method overrides it.
headers object none Headers sent with the request. Queue target.headers with the same name win.
json_body any JSON value none Body sent as JSON. Adds Content-Type: application/json unless you set a Content-Type header yourself.
body_base64 string none Raw body bytes, base64-encoded (standard alphabet). Use for non-JSON payloads. The SDKs take raw bytes and encode them for you.
schedule_time string (RFC 3339) now When to deliver. A time in the past means “now”.
delay_seconds number 0 Deliver this many seconds from now. Must be 0 or more. (.NET takes a TimeSpan named Delay.)
dispatch_deadline_seconds number 600 How long to wait for a response on each attempt, 15 to 1800 seconds. (.NET takes a TimeSpan named DispatchDeadline.)
task_id string generated Your ID for the task, used for deduplication.
retry object queue settings Per-task override of any retry field.

Rules the API enforces (each violation is 400 invalid_argument):

  • Exactly one of url or path. A path on a queue without target.base_url is 400 failed_precondition.
  • At most one of json_body or body_base64.
  • At most one of schedule_time or delay_seconds.
  • A body is only allowed with POST, PUT or PATCH.
  • Header names must be valid HTTP tokens, values can’t contain control characters such as CR, LF or NUL, and Host, Content-Length, Transfer-Encoding, Connection, Keep-Alive, Upgrade, TE and Trailer are reserved.

Send to an absolute URL with a custom method, headers and body

Section titled “Send to an absolute URL with a custom method, headers and body”
await pq.createTask("webhooks", {
url: "https://hooks.example.com/orders",
method: "PUT",
headers: { "Content-Type": "text/csv", "X-Source": "billing" },
body: "id,total\n1,9.99\n",
scheduleTime: new Date("2026-12-24T09:00:00Z"),
dispatchDeadlineSeconds: 120,
});

A raw body without a Content-Type header is delivered as application/octet-stream.

Use url when tasks in one queue go to different hosts. Use path with a queue target.base_url when they all go to one service: producers don’t need to know the host, and changing base_url re-points every queued task, because the path is resolved when the task is delivered, not when it is created. A queue with base_url https://api.example.com and a task with path /hooks/send delivers to https://api.example.com/hooks/send.

Without schedule_time or delay_seconds, a task is due immediately. With either, it waits until that time and is then delivered as soon as the queue’s rate limits allow. Use this for reminders, delayed follow-ups and anything you want to run at a set time without a cron job. See scheduling and cancelling tasks for a full example.

dispatch_deadline_seconds is how long pushq waits for your endpoint to respond on each attempt. If no response arrives in time, the attempt counts as a failure (timeout) and is retried. Raise it for slow handlers; the maximum is 30 minutes.

If you don’t set task_id, the server generates a UUIDv7. If you do, it must match [A-Za-z0-9_-]{1,500} and be unique within the queue: creating a second task with an ID that is still reserved fails with 409 already_exists.

import { PushqError } from "pushq";
try {
await pq.createTask("emails", { path: "/hooks/receipt", taskId: "receipt-1001" });
} catch (err) {
if (!(err instanceof PushqError && err.code === "already_exists")) throw err;
// Already enqueued: safe to ignore.
}

An ID stays reserved for as long as the task exists, and a task is kept for a while after it finishes. With a self-hosted server’s default settings (the hosted API may use different values):

The task… ID reserved until
is pending or running it finishes
succeeded 24 hours after it finished
failed 7 days after it finished
was deleted 1 hour after deletion (the dedup window)
was purged free immediately

Retention never drops below the dedup window (1 hour by default), so an ID always stays reserved for at least that long after the task finishes or is deleted. Self-hosters can change these with the limits.dedup_window and retention.* settings; see server configuration.

Use a deterministic task_id built from your own record ID when the same event might be enqueued twice, for example by a retried request or two workers, and you want it delivered once. The deduplication pattern shows how to build good IDs.

State Meaning
pending Waiting for its schedule time, for a retry, or for the queue’s rate limits.
running Being delivered right now.
succeeded Got a 2xx response. Final.
failed Ran out of retries. Final.

A task moves from pending to running, then to succeeded, or back to pending with a later schedule time when an attempt fails and retries remain. When retries run out it becomes failed and is copied to the queue’s dead-letter queue, if it has one. Deleted and purged tasks disappear from the API.

POST /v1/queues/{queue}/tasks:batch creates up to 500 tasks in one request.

const results = await pq.createTasks("emails", [
{ path: "/hooks/digest", jsonBody: { userId: 1 }, taskId: "digest-1" },
{ path: "/hooks/digest", jsonBody: { userId: 2 }, taskId: "digest-2" },
]);
for (const r of results) {
if (r.error) console.error(`item ${r.index}: ${r.error.code} ${r.error.detail}`);
}

The batch is not atomic. Each item succeeds or fails on its own, and the response has one result per item, in request order:

{
"results": [
{"index": 0, "task": {"id": "digest-1", "state": "pending"}},
{"index": 1, "error": {"code": "already_exists", "detail": "already exists"}}
]
}

Item error codes are invalid_argument, already_exists, not_found, failed_precondition (for example, the queue is disabled) and internal. The request answers 200 even when some items fail. It fails as a whole only if tasks is empty or has more than 500 items, the queue doesn’t exist, or the request body exceeds 8 MiB.

Use batches for fan-out jobs, such as one task per user, where a duplicate or invalid item should not block the rest. For more than 500 tasks, see bulk enqueue.

GET /v1/queues/{queue}/tasks/{task_id} returns one task. By default headers and body are left out; the full view (?view=full) includes them.

const t = await pq.getTask("emails", "welcome-user-42", { view: "full" });
console.log(t.state, t.dispatchCount, t.lastAttempt);
Field Description
id, queue, state Identity and current state.
url, method As created. url holds the path for path-based tasks.
headers, body_base64 Only in the full view.
schedule_time When the task is (or was) due. Each retry moves it forward.
created_at When the task was created.
dispatch_deadline_seconds Effective deadline per attempt.
retry The per-task override, if one was set.
dispatch_count Attempts started so far.
response_count Attempts that got an HTTP response (any status).
first_attempt_at Time of the first attempt.
finished_at When the task succeeded or failed.
last_attempt at, plus status (HTTP status, if any) and error (error kind and a snippet).

GET /v1/queues/{queue}/tasks lists tasks, newest first.

Query parameter Default Description
state all pending, running, succeeded or failed.
id_prefix none Only tasks whose ID starts with this string.
view basic full includes headers and bodies.
page_size 100 Up to 1000.
page_token none next_page_token from the previous page.
const page = await pq.listTasks("emails", { state: "failed", idPrefix: "receipt-", pageSize: 50 });
// page.items, page.nextPageToken

Pass the returned page token back to get the next page; it is empty on the last page. Use id_prefix with structured IDs (such as tenant-42-...) to look at one slice of a queue; the stats endpoint accepts the same filter.

GET /v1/queues/{queue}/tasks/{task_id}/attempts returns the delivery history of a task, newest first (up to the last 1000 attempts).

const attempts = await pq.listAttempts("emails", "welcome-user-42");
{
"attempts": [
{
"number": 2,
"dispatch_time": "2026-11-28T10:00:01.2Z",
"response_time": "2026-11-28T10:00:01.4Z",
"response_status": 200,
"duration_ms": 180
},
{
"number": 1,
"dispatch_time": "2026-11-28T10:00:00Z",
"response_time": "2026-11-28T10:00:00.3Z",
"response_status": 503,
"error_kind": "non_2xx",
"error_snippet": "upstream unavailable",
"duration_ms": 290
}
]
}

error_kind is one of non_2xx, timeout, connect, dns, tls, config (for example, a path task on a queue whose base_url was removed) or lease_lost (the outcome was never recorded, for example because the server restarted mid-delivery). error_snippet holds the start of the response body or the error message, up to 4 KiB. Use this to see why a task is failing without adding logging to your endpoint.

POST /v1/queues/{queue}/tasks/{task_id}:run delivers a pending task immediately, ignoring its schedule time.

await pq.runTask("emails", "welcome-user-42");
  • It bypasses the queue’s rate limits and concurrency limit, and works on a paused queue.
  • It counts as a normal attempt. If it fails, the usual retry rules apply; on a paused queue the retry then waits until you resume.
  • It fails with 400 failed_precondition if the queue is disabled or the task is currently running, and with 404 not_found if the task already succeeded, failed, or was deleted or purged.

Use this to test an endpoint fix on one task before resuming a paused queue, or to skip the wait on a scheduled task.

DELETE /v1/queues/{queue}/tasks/{task_id} deletes a task in any state and answers 204.

await pq.deleteTask("emails", "welcome-user-42");

A deleted task is never delivered again. If it was running, that request may still reach your endpoint, but its result is ignored. The ID stays reserved for the dedup window (1 hour by default), so a task with the same ID can’t be created right away. Use this to cancel a scheduled task, such as a reminder for an order that was cancelled.

Finished tasks and their attempt history are kept so you can inspect them: succeeded tasks for 24 hours and failed tasks for 7 days by default on a self-hosted server, never less than the dedup window. After that they are removed automatically. Self-hosters can change this with retention.succeeded and retention.failed.

Limit Self-hosted default Notes
Body size 1 MiB Decoded bytes. Over the limit is 400 invalid_argument. Self-hosted: limits.max_body_bytes.
Headers per task 16 KiB Sum of names and values. Self-hosted: limits.max_headers_bytes.
Schedule ahead 1 year A later schedule_time or delay_seconds is rejected. Self-hosted: limits.max_schedule_ahead.
url length 2083 characters
task_id 500 characters [A-Za-z0-9_-]
dispatch_deadline_seconds 15 to 1800 Default 600.
Batch size 500 tasks Request body up to 8 MiB.

A request body larger than the server accepts is rejected with 413 payload_too_large. The values above are a self-hosted server’s defaults; the hosted API may set different ones. Self-hosters can change them, see server configuration.