Skip to content
pushqdocs
Get started

A pushq queue holds tasks and decides how they are delivered: how fast, how many at once, how failures are retried, and where relative paths point. This page covers creating and configuring queues, every queue setting, pausing, purging and deleting queues, queue folders, and queue stats.

Use one queue per kind of work (emails, webhooks), or one per customer when each needs its own rate limit (see Rate limits).

The examples on this page assume a client named pq (see Install & configure an SDK). Parameter tables use the JSON field names; the SDKs use their language’s casing (maxDispatchesPerSecond in TypeScript and Java, max_dispatches_per_second in Python, MaxDispatchesPerSecond in Go and .NET).

import { Pushq } from "pushq";
const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });

There are two ways to create a queue.

Create or update a queue with PUT (upsert)

Section titled “Create or update a queue with PUT (upsert)”

PUT /v1/queues/{queue} is an idempotent upsert. It creates the queue if it doesn’t exist and replaces its configuration if it does. It is cheap enough to call before every enqueue, so your code never has to check whether a queue exists.

await pq.upsertQueue("emails", {
rateLimits: { maxDispatchesPerSecond: 10, maxConcurrentDispatches: 5 },
retry: { maxAttempts: 5, minBackoffSeconds: 1, maxBackoffSeconds: 300 },
target: { baseUrl: "https://api.example.com" },
});

The response is the queue. The status is 201 when the queue was created and 200 otherwise, and the X-Pushq-Result header says what happened: created, updated or unchanged.

PUT never changes the queue’s state, so calling it on every enqueue can’t accidentally resume a paused queue.

Create a queue only if it doesn’t exist (POST)

Section titled “Create a queue only if it doesn’t exist (POST)”

POST /v1/queues creates a queue and fails with 409 already_exists if the name is taken. The body is the same as PUT plus a name field.

await pq.createQueue("emails", { rateLimits: { maxDispatchesPerSecond: 10 } });

Use this when creating a queue that already exists should be an error, for example in a provisioning script. New queues always start in the running state.

All fields are optional. Omitted fields take the default shown.

Parameter Type Default Description
rate_limits.max_dispatches_per_second number 500 Token refill rate. Must be greater than 0 and at most 10000. Fractions are allowed: 0.5 is one dispatch every two seconds.
rate_limits.max_burst_size integer 0 (auto) Token bucket size, 0 to 10000. 0 means auto: max_dispatches_per_second rounded up, between 1 and 500. Responses always show the resolved value.
rate_limits.max_concurrent_dispatches integer 1000 Maximum requests in flight at once for this queue, 1 to 10000.

How these interact, and how to pick values, is covered in the Rate limits guide.

Parameter Type Default Description
retry.max_attempts integer 100 Total attempts, including the first. -1 means unlimited. 0 is rejected.
retry.max_retry_duration_seconds number 0 (unlimited) How long after the first attempt retries may continue. Must be 0 or more.
retry.min_backoff_seconds number 0.1 Delay before the first retry. Must be 0 or more.
retry.max_backoff_seconds number 3600 Upper bound on any delay. Must be at least min_backoff_seconds.
retry.max_doublings integer 16 How many times the delay doubles before growing linearly, 0 to 31.

The exact schedule, and how max_attempts and max_retry_duration_seconds combine, are explained in Retries. Tasks can override any of these individually.

Target settings: base URL, method, headers and signing secret

Section titled “Target settings: base URL, method, headers and signing secret”
Parameter Type Default Description
target.base_url string none Absolute http or https URL. Tasks created with a relative path are sent to base_url + path. Without it, every task must have an absolute url.
target.method string none When set, overrides every task’s HTTP method. One of GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
target.headers object none Headers added to every delivery. They win over task headers with the same name. At most 16 KiB in total (names plus values).
target.signing_secret string none Standard Webhooks secret (whsec_...). When set, every delivery is signed. Never returned; responses show has_signing_secret instead.

The target is applied at delivery time, so changing base_url or headers affects tasks that are already queued. See Delivery for the full request pushq sends.

target.headers can’t contain Host, Content-Length, Transfer-Encoding, Connection, Keep-Alive, Upgrade, TE or Trailer, and values can’t contain control characters such as CR, LF or NUL.

signing_secret has special update rules: omit it to keep the stored secret, send "" to remove it.

Parameter Type Default Description
dead_letter_queue string none Name of another queue that receives a copy of each task that runs out of retries. Can’t be the queue itself.

See Dead-letter queues.

Names are lowercase and made of one or more segments separated by /. Each segment matches [a-z0-9][a-z0-9-]* (starts with a letter or digit, then letters, digits and hyphens). The whole name is at most 200 characters. See Folders.

PATCH /v1/queues/{queue} changes only the fields you send and leaves everything else alone. The merged result is validated before it is saved, so a PATCH can never leave a queue with invalid settings.

await pq.patchQueue("emails", { rateLimits: { maxDispatchesPerSecond: 2 } });

PATCH differs from PUT in these ways (Go’s PatchQueue only sends non-empty strings, so it can’t clear base_url, method, headers or dead_letter_queue; use the HTTP API for that, or ClearSigningSecret: true for the secret):

  • It accepts a state field: running, paused or disabled.
  • target.headers, when sent, replaces the whole header map. Send {} to remove all queue headers.
  • target.signing_secret: "" removes the secret, target.base_url: "" removes the base URL, and dead_letter_queue: "" removes the dead-letter queue.

Changes take effect for the next dispatch, including tasks already waiting in the queue. Use this when you want to adjust one setting at runtime, such as lowering a rate limit during an incident.

State Accepts new tasks Dispatches tasks :run works
running Yes Yes Yes
paused Yes No Yes
disabled No (400 failed_precondition) No No (400 failed_precondition)

In every state you can still read the queue, list its tasks, read stats, change its configuration and purge it.

Pausing or disabling a queue doesn’t interrupt requests already in flight; they finish normally. If one of them fails, its retry is scheduled and waits until the queue runs again.

await pq.pauseQueue("emails");
await pq.resumeQueue("emails");

Both return the queue. Pausing a disabled queue fails with 400 failed_precondition; :resume moves a queue from either paused or disabled back to running.

Use pause when the endpoint is down or misbehaving and you want tasks to pile up safely instead of using up their retries. Tasks whose time has passed are delivered as soon as you resume, within the queue’s rate limits.

There is no :disable endpoint; set the state with PATCH:

await pq.patchQueue("emails", { state: "disabled" });

Use this when producers must stop enqueuing to a queue, for example while you retire it. Re-enable it with :resume or a PATCH to running.

POST /v1/queues/{queue}:purge deletes every task created up to now, in any state (pending, running, succeeded or failed). It answers 202 with the queue; purged_at shows the purge time.

await pq.purgeQueue("emails");

How it behaves:

  • The cut-off is exact: every task created before the purge disappears from the API immediately, and the rows are removed in the background.
  • Tasks created after the purge are not affected, even within the same millisecond.
  • Requests already in flight can still reach your endpoint, but their results are discarded and they are not retried.
  • Task IDs of purged tasks can be reused right away, without waiting for the dedup window.
  • The queue’s configuration and state are unchanged.

Use this to throw away a backlog you no longer want delivered, such as tasks built from bad data.

DELETE /v1/queues/{queue} deletes the queue together with all of its tasks and their attempt history. It answers 204. The name can be reused immediately.

await pq.deleteQueue("emails");

Deleting needs more than write access: admin API keys and admin or member dashboard users can delete queues; writer API keys get 403 permission_denied. Requests already in flight may still reach your endpoint, but their results are discarded.

GET /v1/queues/{queue} returns one queue. Any role can read a queue it knows by name.

GET /v1/queues lists queues in name order:

Query parameter Default Description
name_prefix none Only queues whose name starts with this string, such as tenants/.
page_size 100 Results per page, up to 1000.
page_token none next_page_token from the previous page.
let pageToken: string | undefined;
do {
const page = await pq.listQueues({ namePrefix: "tenants/", pageToken });
for (const q of page.items) console.log(q.name, q.state);
pageToken = page.nextPageToken;
} while (pageToken);

Listing needs list permission: admin API keys and every dashboard user have it, writer API keys don’t. Writer keys are meant for apps that work with queues they already know by name.

A queue response looks like this:

{
"name": "emails",
"state": "running",
"rate_limits": {"max_dispatches_per_second": 10, "max_burst_size": 10, "max_concurrent_dispatches": 5},
"retry": {"max_attempts": 5, "max_retry_duration_seconds": 0, "min_backoff_seconds": 1, "max_backoff_seconds": 300, "max_doublings": 16},
"target": {"base_url": "https://api.example.com", "has_signing_secret": false},
"created_at": "2026-11-28T10:00:00Z",
"updated_at": "2026-11-28T10:00:00Z"
}

target.method, target.headers, dead_letter_queue and purged_at appear when set.

A / in a queue name puts the queue in a folder: user/instagram is an instagram queue in a user folder, and folders can nest (user/tiktok/eu). Folders are only part of the name. They need no setup, have no settings of their own, and exist as long as some queue name uses them. Each queue in a folder is still independent, with its own limits and retry settings.

In API paths, the whole name is a single path segment, so encode / as %2F. The SDKs do this for you, so pass the name as is:

await pq.upsertQueue("user/instagram", { target: { baseUrl: "https://api.example.com" } });
await pq.createTask("user/instagram", { path: "/hooks/post" });

If you send the / unencoded, the API answers 404 with a hint to URL-encode the name. In query strings such as name_prefix=user/, no encoding is needed.

Use folders to group many related queues, such as one queue per customer under tenants/, and to list or monitor them together with name_prefix.

GET /v1/queues/{queue}/stats returns live counts for a queue without listing its tasks. Add id_prefix to count only tasks whose ID starts with a prefix.

const stats = await pq.queueStats("emails", { idPrefix: "invoice-" });
{
"state": "running",
"pending": 12,
"running": 3,
"succeeded": 4810,
"failed": 2,
"scheduled_future": 140,
"oldest_due_at": "2026-11-28T10:00:00Z",
"oldest_due_age_seconds": 4.2,
"dispatched_last_1m": 95,
"errors_last_1m": 1,
"dispatched_last_1h": 5120,
"errors_last_1h": 30
}
Field Description
state The queue’s state: running, paused or disabled.
pending Tasks that are due now or overdue and waiting to be dispatched, including retries whose time has come.
running Tasks currently being delivered.
succeeded Succeeded tasks still retained (24 hours by default on a self-hosted server).
failed Failed tasks still retained (7 days by default on a self-hosted server).
scheduled_future Pending tasks scheduled for later, including those waiting for a retry.
oldest_due_at Schedule time of the oldest due task. Omitted when nothing is due.
oldest_due_age_seconds How long that task has been waiting past its schedule time. A growing value means the queue is falling behind.
dispatched_last_1m / dispatched_last_1h Delivery attempts started in the last minute / hour.
errors_last_1m / errors_last_1h Of those attempts, how many did not get a 2xx response (non-2xx status, timeout or connection error).
last_purge Time of the last purge. Omitted if the queue was never purged.

Purged and deleted tasks are not counted. Use stats for dashboards and alerts: alert on oldest_due_age_seconds for lag and on errors_last_1m for a failing endpoint.