Skip to content
pushqdocs
Get started

When a request fails, the pushq API answers with a non-2xx status and an RFC 9457 problem+json body (Content-Type: application/problem+json). Every error carries a stable code that you can branch on.

Use this page when you’re deciding which failures to retry, which to treat as success (such as a duplicate task_id), and which point at a bug in your request.

Terminal window
curl -i -X POST https://api.pushqueue.dev/v1/queues/emails/tasks \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"json_body": {"to": "a@example.com"}}'
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Bad Request",
"status": 400,
"code": "invalid_argument",
"detail": "url or path is required",
"instance": "/v1/queues/emails/tasks"
}
Field Type Description
type string Always about:blank.
title string The standard reason phrase for the status, e.g. Not Found.
status integer The HTTP status code, repeated in the body.
code string Stable machine-readable error code. Branch on this.
detail string Human-readable explanation. Its wording can change between versions, so show it or log it, but don’t parse it.
instance string The request path that failed.

Several codes share an HTTP status (failed_precondition and invalid_argument are both 400), so check code rather than the status alone.

Code HTTP status Retry?
invalid_argument 400, 405 No, fix the request
failed_precondition 400 No, change the state first
unauthenticated 401 No, fix the credentials
permission_denied 403 No, use a key or role that’s allowed
email_verification_required 403 Finish verification
not_found 404 No
already_exists 409 No; often means success
payload_too_large 413 No, shrink the request
rate_limited 429 Yes, after Retry-After
internal 500, 502, 503 Yes, with backoff

Status: 400 Bad Request (also 405 Method Not Allowed for a method a path doesn’t support).

The request is malformed or a field fails validation. Examples:

  • The body isn’t valid JSON, or a field has the wrong type.
  • A queue name doesn’t match the naming rules, or a task_id doesn’t match [A-Za-z0-9_-]{1,500}.
  • A task sets both url and path, or neither; url isn’t an absolute http(s) URL; path doesn’t start with /.
  • A task sets both body_base64 and json_body, or both schedule_time and delay_seconds; or sends a body with a method that doesn’t allow one.
  • The decoded body is larger than the server’s limits.max_body_bytes (1 MiB by default), or headers exceed limits.max_headers_bytes. A reserved header such as Host or Content-Length is set.
  • schedule_time is further ahead than the server allows (1 year by default); dispatch_deadline_seconds is outside 15 to 1800.
  • A rate limit or retry setting is out of range, e.g. max_dispatches_per_second not in (0, 10000], max_attempts not -1 or at least 1.
  • A queue names itself as its dead_letter_queue.
  • A list filter is invalid (state not one of pending, running, succeeded, failed; page_size not an integer), or a batch is empty or has more than 500 tasks.
  • A dashboard account field is invalid, such as a password that’s too short.

Handle it: don’t retry. Read detail, which names the field and the rule, and fix the request.

Status: 400 Bad Request.

The request is well-formed but the current state doesn’t allow it. Examples:

  • Enqueueing to, or running a task in, a queue whose state is disabled.
  • :pause on a disabled queue.
  • :run on a task that is being delivered right now.
  • A task uses path, but its queue has no target.base_url.
  • A malformed page_token.
  • Self-hosted: first-time setup was already completed; removing or demoting the last admin of a team.
  • SaaS mode: WorkOS rejected a request (the detail starts with couldn't …), or an email verification expired and the person needs to sign in again.

Handle it: don’t retry as-is. Change the state the detail describes first, for example resume or re-enable the queue, set the queue’s target.base_url, or restart pagination without a token.

Status: 401 Unauthorized.

The server doesn’t know who you are:

  • The Authorization header is missing, the key is unknown, or it was revoked.
  • An endpoint that needs a signed-in dashboard user (/v1/me, /v1/teams) was called with an API key.
  • Sign-in failed: wrong email or password, or (SaaS mode) a wrong or expired email code.

Handle it: check that you send Authorization: Bearer pq_... with a current key, and that the SDK points at the right server: a key from the hosted service won’t work on a self-hosted server and vice versa.

Status: 403 Forbidden.

You’re authenticated, but not allowed to do this:

  • Your role lacks the permission. For example, a writer key calling GET /v1/queues (listing) or DELETE /v1/queues/{queue}, or a viewer trying to enqueue. The detail names your role.
  • A cookie-authenticated request that changes something is missing the X-Requested-With header.
  • Self-hosted: first-time setup on a server protected by config-file keys was attempted without one of its admin keys.
  • SaaS mode: a non-operator caller reading /metrics when metrics aren’t public.

Handle it: use an admin key or a role that allows the call. See API keys and the access levels for each endpoint.

Status: 403 Forbidden. SaaS mode only.

An email-code sign-in is paused until the person enters the verification code WorkOS emailed them. Only the dashboard’s sign-in flow sees this.

Handle it: send the code to POST /v1/auth/email-verification to finish signing in.

Status: 404 Not Found.

  • The queue, task, API key, member or invite doesn’t exist. A task disappears once its retention runs out, so old tasks return not_found.
  • :run on a task that has already finished, was deleted or was purged.
  • No such endpoint. For a path under /v1/queues/ that contains an unencoded /, the detail adds a hint to encode the queue name (user/instagram becomes user%2Finstagram).
  • An invite or password-reset link is invalid or expired.
  • The endpoint isn’t available on this server: dashboard accounts aren’t enabled, an endpoint is SaaS-only (teams, email codes, GitHub sign-in) on a self-hosted server, or self-hosted-only (passwords, setup) on a SaaS server.

Handle it: check the name and ID, and that queue names in paths are URL-encoded. To make “create the queue if it’s missing” safe, upsert it with PUT /v1/queues/{queue} before enqueueing.

Status: 409 Conflict.

  • POST /v1/queues for a name that’s taken. Use PUT /v1/queues/{queue} to create-or-update instead.
  • POST /v1/queues/{queue}/tasks with a task_id that is already in use, or was used within the dedup window (1 hour by default) after that task finished or was deleted.
  • Creating an account with an email that already has one, or inviting someone who is already a member.

Handle it: for task creation this is usually success: the task with that ID was already enqueued, for example by an earlier attempt of the same request. Treat it as done.

Status: 413 Request Entity Too Large.

The raw request body is over the server’s limit: 256 KiB for queue requests, 8 MiB for a batch, and twice limits.max_body_bytes plus 64 KiB for a single task. (A task body that fits in the request but exceeds limits.max_body_bytes once decoded is invalid_argument.)

Handle it: send smaller task bodies (store large payloads elsewhere and pass a reference), or split a batch.

Status: 429 Too Many Requests, with a Retry-After: 6 header.

Too many attempts on a sign-in endpoint from one IP address: password sign-in, first-time setup, accepting an invite, changing a password, and requesting or verifying email codes. Each IP gets 10 attempts, refilling one every 6 seconds.

Queue and task endpoints don’t return this code.

Handle it: wait for the number of seconds in Retry-After, then try again.

Status: 500 Internal Server Error; 502 Bad Gateway when WorkOS is unreachable in SaaS mode; 503 Service Unavailable from /readyz when the database is unreachable.

Something failed on the server. The detail is generic (internal error); self-hosters find the cause in the server log.

Handle it: retry with exponential backoff. Give tasks a task_id so a retried enqueue can’t create a duplicate.

POST /v1/queues/{queue}/tasks:batch answers 200 even when some tasks fail. Each failed item has an error object with a code and detail instead of a task:

{
"results": [
{ "index": 0, "task": { "id": "welcome-user-42", "state": "pending" } },
{ "index": 1, "error": { "code": "already_exists", "detail": "already exists" } },
{ "index": 2, "error": { "code": "invalid_argument", "detail": "url or path is required" } }
]
}

Item codes are invalid_argument, already_exists, not_found, failed_precondition and internal, with the same meanings as above. The whole request still fails with a problem+json error for problems with the batch itself, such as an empty list or a missing queue.

Every SDK turns a non-2xx response into an error that carries the HTTP status, the code and the detail:

  • TypeScript: rejects with PushqError (status, code, detail).
  • Python: raises PushqError (status, code, detail), from both Pushq and AsyncPushq.
  • Go: returns a *pushq.Error (Status, Code, Detail); pushq.IsCode(err, "already_exists") checks the code through wrapped errors.
  • Java: throws the unchecked PushqException (getStatus(), getCode(), getDetail()). Network failures throw it too, with status 0 and a null code.
  • .NET: throws PushqException (Status, Code, Detail).

If a response isn’t problem+json (for example an error page from a proxy), the TypeScript, Python, Go and .NET SDKs report the code as internal and put the start of the body in detail; Java leaves the code null. Apart from Java, network failures and timeouts surface as the language’s usual HTTP client errors.

This example treats a duplicate task ID as success and rethrows everything else:

import { PushqError } from "pushq";
try {
await pq.createTask("emails", { taskId: "welcome-user-42", path: "/send" });
} catch (err) {
if (err instanceof PushqError && err.code === "already_exists") {
// already enqueued
} else {
throw err;
}
}