API error codes
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.
Problem+json error format
Section titled “Problem+json error format”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 RequestContent-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.
Error code reference
Section titled “Error code reference”| 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 |
invalid_argument
Section titled “invalid_argument”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_iddoesn’t match[A-Za-z0-9_-]{1,500}. - A task sets both
urlandpath, or neither;urlisn’t an absolute http(s) URL;pathdoesn’t start with/. - A task sets both
body_base64andjson_body, or bothschedule_timeanddelay_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 exceedlimits.max_headers_bytes. A reserved header such asHostorContent-Lengthis set. schedule_timeis further ahead than the server allows (1 year by default);dispatch_deadline_secondsis outside 15 to 1800.- A rate limit or retry setting is out of range, e.g.
max_dispatches_per_secondnot in (0, 10000],max_attemptsnot-1or at least 1. - A queue names itself as its
dead_letter_queue. - A list filter is invalid (
statenot one ofpending,running,succeeded,failed;page_sizenot 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.
failed_precondition
Section titled “failed_precondition”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. :pauseon adisabledqueue.:runon a task that is being delivered right now.- A task uses
path, but its queue has notarget.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.
unauthenticated
Section titled “unauthenticated”Status: 401 Unauthorized.
The server doesn’t know who you are:
- The
Authorizationheader 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.
permission_denied
Section titled “permission_denied”Status: 403 Forbidden.
You’re authenticated, but not allowed to do this:
- Your role lacks the permission. For example, a
writerkey callingGET /v1/queues(listing) orDELETE /v1/queues/{queue}, or aviewertrying to enqueue. The detail names your role. - A cookie-authenticated request that changes something is missing the
X-Requested-Withheader. - 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
/metricswhen 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.
email_verification_required
Section titled “email_verification_required”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.
not_found
Section titled “not_found”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. :runon 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/instagrambecomesuser%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.
already_exists
Section titled “already_exists”Status: 409 Conflict.
POST /v1/queuesfor a name that’s taken. UsePUT /v1/queues/{queue}to create-or-update instead.POST /v1/queues/{queue}/taskswith atask_idthat 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.
payload_too_large
Section titled “payload_too_large”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.
rate_limited
Section titled “rate_limited”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.
internal
Section titled “internal”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.
Errors in batch enqueue
Section titled “Errors in batch enqueue”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.
Handle errors in the SDKs
Section titled “Handle errors in the SDKs”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 bothPushqandAsyncPushq. - 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 status0and anullcode. - .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; }}from pushq import PushqError
try: pq.create_task("emails", task_id="welcome-user-42", path="/send")except PushqError as e: if e.code != "already_exists": print(e.status, e.code, e.detail) raise_, err := pq.CreateTask(ctx, "emails", pushq.TaskCreate{TaskID: "welcome-user-42", Path: "/send"})if pushq.IsCode(err, "already_exists") { err = nil // already enqueued}var pe *pushq.Errorif errors.As(err, &pe) { log.Printf("pushq error %d %s: %s", pe.Status, pe.Code, pe.Detail)}if err != nil { return err}try { pq.createTask("emails", TaskCreate.builder().taskId("welcome-user-42").path("/send").build());} catch (PushqException e) { if (!"already_exists".equals(e.getCode())) { System.err.printf("%d %s: %s%n", e.getStatus(), e.getCode(), e.getDetail()); throw e; }}try{ await pq.CreateTaskAsync("emails", new TaskCreate { TaskId = "welcome-user-42", Path = "/send" });}catch (PushqException e) when (e.Code == "already_exists"){ // already enqueued}status=$(curl -s -o /tmp/resp.json -w '%{http_code}' -X POST https://api.pushqueue.dev/v1/queues/emails/tasks \ -H "Authorization: Bearer $PUSHQ_API_KEY" \ -H "Content-Type: application/json" \ -d '{"task_id": "welcome-user-42", "path": "/send"}')code=$(jq -r '.code // empty' /tmp/resp.json)if [ "$status" -ge 300 ] && [ "$code" != "already_exists" ]; then echo "failed: $status $code $(jq -r .detail /tmp/resp.json)" >&2 exit 1fiRead more
Section titled “Read more”- REST API overview: authentication, pagination and idempotency.
- Tasks: task IDs and deduplication.
- Install & configure an SDK: error types in each language.
- Retries and backoff: delivery retries, which are separate from API errors.