` | `$PUSHQ_API_KEY` | API key sent as a bearer token. |
| Command | Description |
|---|---|
| `pushq queues ls [--prefix ]` | List queues (admin key). |
| `pushq queues upsert [flags]` | Create or update a queue. Flags: `--rate`, `--burst`, `--concurrency`, `--max-attempts`, `--min-backoff`, `--max-backoff` (durations, e.g. `1s`, `5m`), `--base-url`, `--method`, `--signing-secret` (`""` clears it; omit to keep), `--dlq`. |
| `pushq queues get ` | Show a queue. |
| `pushq queues pause ` / `resume ` | Pause or resume dispatching. |
| `pushq queues purge ` | Delete all tasks created up to now. |
| `pushq queues rm ` | Delete a queue (admin key). |
| `pushq queues stats [--id-prefix ]` | Queue depth and error rates. |
| `pushq tasks ls [--state ] [--prefix ] [--view basic\|full]` | List tasks. `--state` is `pending`, `running`, `succeeded` or `failed`. |
| `pushq tasks create [flags]` | Enqueue a task. Flags: `--id`, `--url`, `--path`, `--method`, `--json`, `--delay` (e.g. `30s`, `2h`), `--max-attempts`. |
| `pushq tasks get ` | Show a task, including headers and body. |
| `pushq tasks rm ` | Delete a task. |
| `pushq tasks run ` | Dispatch a task now. |
| `pushq tasks attempts ` | Show a task's attempt history. |
```bash
export PUSHQ_SERVER=https://pushq.example.com PUSHQ_API_KEY=pq_admin_change-me
pushq queues upsert emails --rate 10 --max-attempts 5 --base-url https://app.example.com
pushq tasks create emails --path /hooks/send --json '{"to":"a@example.com"}' --delay 1h
pushq queues stats emails
```
---
# Deploy a self-hosted server
> Deploy pushq in production: one SQLite node with systemd, or Postgres replicas with docker-compose, behind nginx or Caddy, with blue/green deploys.
Source: https://pushqueue.dev/docs/self-hosting/deploy/
pushq is one static binary with the dashboard included. It runs in one of two shapes:
| Shape | Use it when |
|---|---|
| **Single node + SQLite** | You want zero dependencies: one box, one file. Plan for up to about 500 sustained dispatches per second. |
| **Several replicas + Postgres** | You need high availability or more throughput. Every replica serves the API; a Postgres advisory lock elects one replica to run the dispatcher. |
Both shapes run the same binary; only the `db` setting changes. See the [server configuration reference](https://pushqueue.dev/docs/self-hosting/configuration/) for every setting.
**systemd**
```bash
# Single node, SQLite: install the unit and config below, then
sudo systemctl enable --now pushq
```
**docker-compose**
```bash
# Two replicas on Postgres: save the compose file below, then
docker compose up -d
```
## Deploy a single node with systemd and SQLite
Use this when one machine is enough and you don't want to run a database server.
```ini
# /etc/systemd/system/pushq.service
[Unit]
Description=pushq task queue
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/pushq serve -c /etc/pushq/pushq.yaml
Restart=always
RestartSec=2
User=pushq
StateDirectory=pushq
# SIGTERM starts a graceful drain: in-flight deliveries get up to
# dispatcher.drain_timeout (default 30s) to finish.
TimeoutStopSec=45
[Install]
WantedBy=multi-user.target
```
```yaml
# /etc/pushq/pushq.yaml
db: sqlite:/var/lib/pushq/pushq.db
listen: 127.0.0.1:8080 # a reverse proxy in front terminates TLS
log: { format: json }
```
```bash
sudo useradd --system --no-create-home pushq
sudo systemctl daemon-reload
sudo systemctl enable --now pushq
journalctl -u pushq -f
```
`StateDirectory=pushq` creates `/var/lib/pushq` owned by the `pushq` user. SQLite runs in WAL mode, so you'll see `pushq.db-wal` and `pushq.db-shm` next to the database file.
Keep `TimeoutStopSec` above `drain_timeout` plus a few seconds, or systemd will kill the process before in-flight deliveries finish.
:::caution
Create the admin account in the dashboard **before** exposing the server. Until then, a server without `api_keys` accepts anonymous requests. See [create the first admin account](https://pushqueue.dev/docs/self-hosting/install/#create-the-first-admin-account).
:::
## Run multiple replicas with docker-compose and Postgres
Use this when you need the API to stay up through a crash or a deploy. All replicas serve the API; one at a time runs the dispatcher.
```yaml
# docker-compose.yml
services:
db:
image: postgres:16
environment: { POSTGRES_USER: pushq, POSTGRES_PASSWORD: pushq, POSTGRES_DB: pushq }
volumes: [pgdata:/var/lib/postgresql/data]
healthcheck: { test: ["CMD-SHELL", "pg_isready -U pushq"], interval: 2s, retries: 30 }
pushq-a: &pushq
image: ghcr.io/blissfulrays/pushq:1.0.0 # pin a version
command: serve
environment:
PUSHQ_DB: postgres://pushq:pushq@db/pushq?sslmode=disable
PUSHQ_LISTEN: ":8080"
PUSHQ_LOG_FORMAT: json
PUSHQ_API_KEYS: "admin:pq_admin_,writer:pq_writer_"
depends_on: { db: { condition: service_healthy } }
ports: ["8081:8080"]
pushq-b:
<<: *pushq
ports: ["8082:8080"]
volumes:
pgdata:
```
Generate real keys (for example `echo "pq_$(openssl rand -hex 24)"`) instead of the placeholders.
Load-balance across the replicas however you like. `GET /readyz` reports which replica currently runs the dispatcher (`"role": "leader"`); the others report `"follower"` and still serve every API request. See [high availability and leader election](https://pushqueue.dev/docs/self-hosting/operations/#high-availability-and-leader-election).
## Put pushq behind a reverse proxy
Run pushq on a private address and put a TLS-terminating proxy in front. Two things matter.
### Forward encoded queue names unmodified
Queue names can contain `/` (folders, e.g. `user/instagram`). In URLs the whole name travels as one encoded segment: `/v1/queues/user%2Finstagram`. Your proxy must pass `%2F` through as-is. If it decodes `%2F` into `/`, pushq sees a different path and answers `404 not_found`.
- **Caddy** forwards the path unmodified by default.
- **nginx**: write `proxy_pass http://127.0.0.1:8080;` with **no** URI part. A trailing slash (`proxy_pass http://127.0.0.1:8080/;`) makes nginx normalize the path and decode `%2F`.
### Set X-Forwarded-Proto for TLS
pushq marks the dashboard session cookie `Secure` only when the request arrived over TLS or carries `X-Forwarded-Proto: https`. In SaaS mode the same check picks the scheme of the default WorkOS redirect URI. Behind a TLS-terminating proxy, forward that header. Caddy sets `X-Forwarded-Proto` and gets certificates on its own; with nginx, set it yourself.
**nginx**
```nginx
server {
listen 443 ssl;
server_name pushq.example.com;
# ssl_certificate / ssl_certificate_key ...
client_max_body_size 10m; # batch enqueue bodies can be up to 8 MiB
location / {
proxy_pass http://127.0.0.1:8080; # no trailing slash
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 60s;
}
}
```
**Caddy**
```text
pushq.example.com {
reverse_proxy 127.0.0.1:8080
}
```
pushq rate-limits password sign-in attempts per client IP. Behind a proxy every client shares the proxy's address, which still caps brute-force attempts but means one noisy client can briefly lock out others.
## Zero-downtime blue/green deploys
You can run the old and new versions side by side against the same Postgres database:
1. Start the new instance. It serves the API immediately; its dispatcher role is `follower`.
2. Send `SIGTERM` to the old instance. It releases dispatcher leadership at once, stops accepting new connections, then drains in-flight deliveries for up to `dispatcher.drain_timeout` (default 30s).
3. The new instance takes leadership within about 5 seconds (followers retry the lock every 5s) and continues from where the old one left off.
Correctness never depends on the lock: each delivery's result is recorded only if the task's lease token still matches, so overlapping instances can't both complete the same attempt. As with any at-least-once queue, a task whose lease expires mid-delivery is retried, so keep handlers idempotent. See [at-least-once delivery](https://pushqueue.dev/docs/concepts/delivery/).
New versions apply their database migrations on startup. To apply them before switching traffic, run `pushq migrate` with the new binary first.
## Deploy on Coolify or another Docker PaaS
The image works on any platform that runs a container image. A typical setup on Coolify or a similar Docker PaaS:
1. Create a Postgres database on a private network.
2. Create an app from the Docker image `ghcr.io/blissfulrays/pushq:`, or `:latest` to follow stable releases.
3. Expose port `8080` and attach your domain. The platform's proxy terminates TLS and should send `X-Forwarded-Proto`.
4. Set environment variables: `PUSHQ_DB=postgres://USER:PASS@:5432/?sslmode=disable`, plus `PUSHQ_API_KEYS` or the [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/) variables if you need them. Use the platform's secret storage for passwords and keys.
5. Turn off the platform's in-container health check, or point it at the HTTP endpoint from outside: the image is distroless, so a check that runs `curl` or `wget` inside the container fails.
To redeploy automatically on every release, run the app on `:latest` and trigger the platform's deploy webhook when a new image is published. With SQLite instead of Postgres, mount a persistent volume at `/data` (the image defaults to `PUSHQ_DB=sqlite:/data/pushq.db`).
## Sizing and performance
- **Memory**: the ceiling is roughly `dispatcher.global_concurrency × limits.max_body_bytes` (defaults: 512 × 1 MiB = 512 MiB worst case), plus a few MB per 10,000 active queues.
- **SQLite** (pure-Go driver, one writer): plan for about 500 sustained dispatches per second with headroom. Beyond that, or for high availability, use Postgres.
- **Postgres**: each replica opens up to 16 pooled connections, plus a dedicated connection for the leader lock and one for `LISTEN`/`NOTIFY`. If you put PgBouncer in front, use **session** mode: `LISTEN`/`NOTIFY` and advisory locks need real sessions.
### Throughput benchmark
Smoke benchmark from the repository (`PUSHQ_LOAD=1 go test ./test/load`): one laptop, a local receiver that answers instantly, 1,000 dynamic queues and 50,000 tasks.
| Backend | Queue creation | Enqueue | End-to-end dispatch |
|---|---|---|---|
| SQLite | 1,000 in 0.2s | ~11,000/s | ~2,300 tasks/s |
| Postgres 15 | 1,000 in 0.6s | ~2,600/s (batched) | ~3,600 tasks/s |
Treat these as upper-bound smoke numbers, not guarantees. In production, throughput is usually bounded by your receivers and by each queue's rate limits.
## Read more
- [Install a self-hosted server](https://pushqueue.dev/docs/self-hosting/install/): binaries, Docker image and first-time setup.
- [Server configuration reference](https://pushqueue.dev/docs/self-hosting/configuration/): every setting and environment variable.
- [Monitoring, backups and upgrades](https://pushqueue.dev/docs/self-hosting/operations/): health checks, metrics and leader election.
- [SaaS mode with WorkOS](https://pushqueue.dev/docs/self-hosting/saas-mode/): multi-team sign-in.
- [How delivery works](https://pushqueue.dev/docs/concepts/delivery/): at-least-once delivery and signatures.
---
# Monitoring, backups and upgrades
> Operate a self-hosted pushq server: health checks, Prometheus metrics, logging, leader election, task retention, backups and upgrades.
Source: https://pushqueue.dev/docs/self-hosting/operations/
This page covers what you need once pushq is running: probing it, monitoring it, keeping it highly available, backing it up and upgrading it.
## Health and readiness checks
| Endpoint | Auth | Answers | Use it for |
|---|---|---|---|
| `GET /healthz` | none | `200` with body `ok` while the process is up. Doesn't touch the database. | Liveness probes: restart the process if this fails. |
| `GET /readyz` | none | `200` with `{"role": "...", "dialect": "..."}` when the database answers a ping; `503` with a problem+json body (`"detail": "database unreachable"`) when it doesn't. | Readiness probes and load balancer health checks. |
```bash
curl -s http://localhost:8080/readyz
```
```json
{"role":"leader","dialect":"postgres"}
```
`dialect` is `sqlite` or `postgres`. `role` says what this replica's dispatcher is doing:
| `role` | Meaning |
|---|---|
| `leader` | This replica runs the dispatcher. A SQLite server is always `leader` once started. |
| `follower` | Another replica holds the dispatcher lock. This one still serves the full API. |
| `stopped` | The dispatcher has shut down (the process is exiting). |
A `follower` is healthy. Don't take followers out of the load balancer: every replica serves the API.
Use `/readyz` for Kubernetes readiness probes and `/healthz` for liveness probes:
```yaml
livenessProbe:
httpGet: { path: /healthz, port: 8080 }
readinessProbe:
httpGet: { path: /readyz, port: 8080 }
```
`GET /v1/version` (any API key) returns `{"version", "commit", "dialect"}`, and `pushq version` prints the same for a binary.
## Prometheus metrics
`GET /metrics` serves Prometheus metrics. It is public by default; set `metrics.public: false` (or `PUSHQ_METRICS_PUBLIC=false`) to require an admin API key or a dashboard session. In [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/) with metrics not public, only the operator's config-file keys can read it.
```yaml
# prometheus.yml
scrape_configs:
- job_name: pushq
static_configs:
- targets: ["pushq-a:8080", "pushq-b:8080"]
# with metrics.public: false
# authorization: { credentials: pq_admin_... }
```
The metrics are aggregate on purpose: there are no per-queue labels, because a server with 10,000+ dynamic queues would explode label cardinality. For per-queue numbers use `GET /v1/queues/{queue}/stats`.
| Metric | Type | Labels | Meaning |
|---|---|---|---|
| `pushq_dispatches_total` | counter | `code_class`: `2xx`, `3xx`, `4xx`, `5xx`, `error` | Delivery attempts by response class. `error` means no HTTP response (timeout, connection, DNS, TLS, or a request that couldn't be built). |
| `pushq_dispatch_errors_total` | counter | `error_kind`: `non_2xx`, `timeout`, `connect`, `dns`, `tls`, `config` | Failed delivery attempts by cause. |
| `pushq_dispatch_duration_seconds` | histogram | none | Delivery round-trip latency, default Prometheus buckets. |
| `pushq_dispatch_inflight` | gauge | none | Deliveries currently in flight. Compare with `dispatcher.global_concurrency`. |
| `pushq_tasks_claimed_total` | counter | none | Tasks leased by the dispatcher for delivery. |
| `pushq_task_retries_total` | counter | none | Failed attempts that were rescheduled for retry. |
| `pushq_tasks_dead_lettered_total` | counter | none | Tasks copied to a dead-letter queue after exhausting retries. |
| `pushq_leases_expired_total` | counter | none | Leases reclaimed by the sweeper because no result was recorded in time (for example after a crash). |
| `pushq_active_queues` | gauge | none | Queues the dispatcher is currently tracking. |
The endpoint also exposes the standard Go runtime (`go_*`) and process (`process_*`) collectors.
Only the replica that is `leader` dispatches, so dispatch metrics come from that replica. Sum across replicas in your queries so a leader change doesn't look like a drop.
Useful queries:
```text
# Delivery error ratio over 5 minutes
sum(rate(pushq_dispatches_total{code_class!="2xx"}[5m]))
/ sum(rate(pushq_dispatches_total[5m]))
# p95 delivery latency
histogram_quantile(0.95, sum(rate(pushq_dispatch_duration_seconds_bucket[5m])) by (le))
# Dispatcher saturation (alert when close to global_concurrency)
max(pushq_dispatch_inflight)
```
## Structured logging
Logs go to stderr. Choose the format and level in the config (see [logging settings](https://pushqueue.dev/docs/self-hosting/configuration/#logging)):
```yaml
log:
level: info # debug | info | warn | error
format: json # text | json
```
At `info` you get startup and shutdown messages, warnings (such as an unauthenticated server, or a lost leader lock) and errors. At `debug` you also get one line per HTTP request (`method`, `path`, `status`, `dur_ms`) and dispatcher detail. `pushq dev` always logs at `debug`.
## High availability and leader election
Run two or more replicas against one Postgres database for high availability. SQLite servers are single-node.
- **Every replica serves the API.** Enqueues, queue changes and reads work on any replica.
- **One replica dispatches.** Replicas compete for a session-level Postgres advisory lock. The holder becomes `leader` and runs the dispatcher; the rest are `follower` and retry the lock every 5 seconds.
- **Failover.** The leader pings its lock connection every 5 seconds. If that connection dies, the lock is gone and another replica takes over at its next attempt. On a graceful shutdown (`SIGTERM`), the leader releases the lock immediately.
- **Wakeups.** With Postgres, new tasks and queue changes reach the leader through `LISTEN`/`NOTIFY`, so a task enqueued on a follower is dispatched without waiting for a poll.
### Lease fencing
The lock is an optimization that avoids duplicate work, not what keeps delivery correct. Correctness comes from per-task leases:
1. When the dispatcher claims a task, it writes a fresh lease token and a lease expiry of `dispatch_deadline_seconds + dispatcher.lease_grace` (default grace 60s).
2. A delivery's result is recorded only if the task still carries that lease token. A stale worker, for example from a replica that lost leadership mid-delivery, can't overwrite a newer attempt.
3. Every `dispatcher.sweep_interval` (default 15s), the leader finds leases that expired without a result, records a `lease_lost` attempt, and retries or fails the task by its retry policy. The attempt counts toward `max_attempts`, because the request may well have reached your endpoint.
This is why blue/green deploys and crash failover are safe. It is also why delivery is at-least-once: make your handlers idempotent. See [at-least-once delivery](https://pushqueue.dev/docs/concepts/delivery/).
## Task retention and cleanup
The leader deletes finished tasks in the background, every `dispatcher.cleanup_interval` (default 60s), in batches. If a backlog remains, it runs again a second later instead of waiting a full interval.
| What | Kept for | Setting |
|---|---|---|
| Succeeded tasks and their attempts | 24h | `retention.succeeded` |
| Failed tasks and their attempts | 7 days | `retention.failed` |
| Deleted tasks (tombstones) | 1h | `limits.dedup_window` |
| Tasks removed by a purge | Deleted in the background right after the purge | none |
A finished or deleted task's ID stays reserved for at least `limits.dedup_window`, so retention shorter than the dedup window is extended to it. Longer retention means more rows to scan; size your database accordingly.
## Back up the database
All state lives in the database: queues, tasks, attempt history, dashboard accounts, sessions, invites, API keys and teams. The binary itself is stateless.
### Back up SQLite
The database runs in WAL mode, so copying only the `.db` file while the server runs can miss recent writes. Use SQLite's online backup, which is safe while pushq runs:
```bash
sqlite3 /var/lib/pushq/pushq.db ".backup '/backups/pushq-$(date +%F).db'"
```
Or stop the service and copy `pushq.db` together with any `pushq.db-wal` and `pushq.db-shm` files.
To restore, stop pushq, put the backup in place as `pushq.db` (removing stale `-wal` and `-shm` files), and start it.
### Back up Postgres
Use your normal Postgres tooling:
```bash
pg_dump --format=custom --file=pushq-$(date +%F).dump "postgres://pushq:secret@db/pushq"
pg_restore --clean --dbname="postgres://pushq:secret@db/pushq" pushq-2026-11-28.dump
```
Managed Postgres snapshots and point-in-time recovery work too.
:::note
Restoring a backup brings back tasks as they were at backup time. Tasks that were delivered after the backup may be delivered again, consistent with at-least-once delivery.
:::
## Upgrade to a new version
1. Read the [release notes](https://github.com/blissfulrays/pushq/releases) for the version you're moving to.
2. Back up the database.
3. Replace the binary or change the image tag, then restart. `pushq serve` applies any new database migrations on startup; each migration runs in its own transaction and is recorded in a `schema_migrations` table, so restarting is safe.
4. Check `GET /readyz` and `GET /v1/version` on each replica.
With several Postgres replicas, upgrade one replica at a time, or follow the [blue/green procedure](https://pushqueue.dev/docs/self-hosting/deploy/#zero-downtime-bluegreen-deploys). To apply migrations before you switch traffic, run the new binary's `pushq migrate -c pushq.yaml` first.
Pin an exact image tag (`:1.0.0`) in production so upgrades happen when you choose. `:latest` moves on every stable release and `:edge` on every release, prereleases included.
There is no `down` migration. To roll back to an older binary after a release that changed the schema, restore the backup you took in step 2.
## Read more
- [Deploy to production](https://pushqueue.dev/docs/self-hosting/deploy/): systemd, docker-compose and blue/green deploys.
- [Server configuration reference](https://pushqueue.dev/docs/self-hosting/configuration/): retention, dispatcher and metrics settings.
- [Retries and backoff](https://pushqueue.dev/docs/concepts/retries/): how failed deliveries are retried.
- [Dead-letter queues](https://pushqueue.dev/docs/concepts/dead-letter-queues/): where tasks go after their last attempt.
---
# Multi-tenant SaaS mode with WorkOS
> Run your own multi-tenant pushq with WorkOS sign-in, where anyone can sign up, create teams and get isolated queues, tasks and API keys.
Source: https://pushqueue.dev/docs/self-hosting/saas-mode/
By default a self-hosted pushq server has one team: you and the people you invite, all sharing the same queues. **SaaS mode** turns it into a multi-tenant service like the hosted one at pushqueue.dev: anyone can sign up, create teams, and get their own isolated queues, tasks, stats and API keys. Sign-in and team membership are handled by [WorkOS](https://workos.com/).
Use this when you want to offer pushq to several customers or internal groups from one deployment, with each one unable to see the others' data. For a single team, the default mode is simpler.
## What changes
| | Self-hosted (default) | SaaS mode |
|---|---|---|
| Turned on by | Nothing; no WorkOS settings | `WORKOS_CLIENT_ID` and `WORKOS_API_KEY` |
| Sign-in | Local accounts with passwords; the first person creates the admin | A 6-digit code emailed by WorkOS, or GitHub, on pushq's own sign-in page. Signing in the first time creates the account. No passwords. |
| Teams | One: everyone on the server | Anyone can create teams; a person can belong to several and switch between them |
| Data | Shared by everyone | Isolated per team: queues, tasks, attempts, stats and API keys |
| Invites | A one-time link you send yourself | Emailed by WorkOS |
| Config-file `api_keys` | Ordinary admin/writer keys | Operator keys that see every team |
Everything in [Team members](https://pushqueue.dev/docs/guides/team-members/) that's described for the hosted service applies to SaaS mode.
## Turn it on
Set both WorkOS credentials and start the server with `pushq serve`:
```bash
export WORKOS_CLIENT_ID=client_...
export WORKOS_API_KEY=sk_...
export PUSHQ_DB=postgres://pushq:secret@db.internal/pushq
export PUSHQ_API_KEYS="admin:pq_operator_"
export PUSHQ_METRICS_PUBLIC=false
pushq serve
```
The log confirms it at startup:
```text
level=INFO msg="SaaS mode: WorkOS sign-in, one isolated workspace per team" client_id=client_... redirect_uri=/v1/auth/workos/callback
```
| Variable | YAML key | Default | Description |
|---|---|---|---|
| `WORKOS_CLIENT_ID` | `workos.client_id` | none | Your WorkOS client ID. Required for SaaS mode. |
| `WORKOS_API_KEY` | `workos.api_key` | none | Your WorkOS API key. Required for SaaS mode. Prefer the environment variable over writing it in the config file. |
| `WORKOS_REDIRECT_URI` | `workos.redirect_uri` | `/v1/auth/workos/callback` | Where WorkOS sends people back after GitHub sign-in. Set it when pushq is behind a proxy that changes the host or scheme. It must be listed under Redirects in WorkOS. |
Set both `WORKOS_CLIENT_ID` and `WORKOS_API_KEY`, or neither: with only one, the server refuses to start. With neither, it runs in the default self-hosted mode.
pushq also reads a `.env` file from the directory where `pushq serve` runs (or the file named by `PUSHQ_ENV_FILE`). Variables already set in the real environment win over the file.
```bash
# .env (keep it out of version control)
WORKOS_CLIENT_ID=client_...
WORKOS_API_KEY=sk_...
# WORKOS_REDIRECT_URI=https://pushq.example.com/v1/auth/workos/callback
PUSHQ_API_KEYS=admin:pq_operator_
```
The equivalent in the YAML config file:
```yaml
workos:
client_id: client_...
redirect_uri: https://pushq.example.com/v1/auth/workos/callback
# api_key: better passed as WORKOS_API_KEY
```
SaaS mode works with SQLite and Postgres. `pushq dev` ignores WorkOS settings and always runs with authentication off.
Serve pushq over HTTPS. Behind a TLS-terminating proxy, forward `X-Forwarded-Proto: https` so session cookies are marked `Secure` and the default redirect URI uses `https`. See [Deploy](https://pushqueue.dev/docs/self-hosting/deploy/).
## WorkOS dashboard checklist
1. **Authentication:** enable **Magic Auth** (email codes) and **GitHub OAuth**, and allow sign-ups so new people can create accounts.
- **Email verification:** with it on, WorkOS pauses a GitHub sign-in until the person enters a code it emails them; pushq's sign-in page asks for it. Turn it off to let GitHub sign-ins straight in, in which case pushq trusts the email address GitHub provides. Email-code sign-ins prove the address either way.
2. **Redirects → Sign-in callback** (used by GitHub sign-in only): add `https:///v1/auth/workos/callback`. For local testing against a staging environment, `http://localhost:8080/v1/auth/workos/callback`. If you set `WORKOS_REDIRECT_URI`, add exactly that URL.
3. **Roles:** keep the default `admin` and `member` roles. pushq uses those slugs; if `admin` is missing, it falls back to the environment's default role.
4. Use the WorkOS **staging** environment while testing.
## How people sign in
The sign-in page is pushq's own (served by the dashboard at `/login`); WorkOS works behind it and no WorkOS-hosted screens are shown, apart from GitHub's consent screen.
- **Email code:** the person enters their email and pushq asks WorkOS to send a 6-digit code. An email WorkOS hasn't seen before gets a new WorkOS user first, so this is also sign-up. The response never reveals whether the email already had an account.
- **GitHub:** the browser goes to GitHub through WorkOS and comes back to `/v1/auth/workos/callback`.
After sign-in, pushq finds or creates the local account (matching by WorkOS user, then by verified email), mirrors the person's WorkOS organizations as teams, and starts the session in the team they used last. Someone with no team yet lands on the **Welcome** screen to create one.
Password sign-in, first-time setup, invite and reset links, and password changes are switched off: those endpoints return `404` (`/v1/auth/setup`, `/v1/auth/login`, `/v1/auth/invites/{token}`, `/v1/auth/invites/{token}:accept`, `/v1/me/password`, `/v1/users/{id}/reset-link`).
## Teams and roles
**Each team is a WorkOS Organization.** Creating a team in the dashboard creates an organization with the creator as its `admin` member. Renaming the team renames the organization. Inviting someone sends a WorkOS invitation email; removing someone deletes their organization membership.
**Roles live in pushq.** pushq has three roles per team (admin, member, viewer; see [Roles](https://pushqueue.dev/docs/guides/team-members/#roles)), and WorkOS has two. pushq maps them like this:
| pushq role | WorkOS organization role |
|---|---|
| admin | `admin` |
| member | `member` |
| viewer | `member` (pushq enforces read-only) |
pushq's role is authoritative. When it learns of a member from WorkOS (someone added in the WorkOS dashboard, for example), it gives them `admin` if their WorkOS role is `admin` and `member` otherwise, unless a pending pushq invite for their email says which role to grant. After that, changing their role in WorkOS doesn't change it in pushq; change it on pushq's Team page.
**pushq re-syncs from WorkOS** every time a person signs in (their teams) and whenever a team's Team settings page is opened (its members). Memberships added or removed directly in the WorkOS dashboard are picked up then.
## How team data is isolated
- Queues, tasks, attempts, stats and API keys all belong to a team. Two teams can each have a queue called `emails`.
- Internally each team gets a random 12-character namespace, and its queues are stored as `:`. Queue names can't contain `:`, so no name a client sends can reach outside its own namespace. pushq strips the namespace from everything it returns, including error messages.
- Receivers only ever see the short name: the `X-Pushq-Queue` header and the signed `webhook-id` use `emails`, not the stored name.
- API keys created in the dashboard or through `/v1/api-keys` belong to the team that created them and only see its queues. A team's admin key manages that team's members, invites and keys.
- A person removed from a team loses access at once; their sessions on that team stop working on the next request.
## Operator keys
In SaaS mode, the keys in the config file (`api_keys` or `PUSHQ_API_KEYS`) are **operator keys** for you, the operator:
- They aren't tied to any team and see every team's queues. Listings show stored names, `:`.
- Teams never see them: the API keys page reports no config keys.
- Only operator keys can read `/metrics` when it isn't public (see below).
- Queues created with an operator key belong to no team.
Keep them for your own tooling and monitoring. Team management (members, invites, team API keys) belongs to each team's admins, in the dashboard or with that team's admin key; don't use operator keys for it.
### Metrics
`/metrics` is public by default (`metrics.public: true`). Its metrics are aggregate over the whole instance (no per-queue or per-team labels), but you likely don't want customers reading your instance's totals. Set `PUSHQ_METRICS_PUBLIC=false` (or `metrics: { public: false }`) and scrape with an operator key:
```bash
curl https://pushq.example.com/metrics \
-H "Authorization: Bearer $PUSHQ_OPERATOR_KEY"
```
## Switch an existing server to SaaS mode
You can add the WorkOS settings to a server that already has data. What happens to it:
- **Queues and tasks** are left untouched, but they belong to no team. Only operator keys can see and manage them, under their existing names.
- **Dashboard accounts** are kept. When someone signs in through WorkOS with the same verified email, pushq links their existing account instead of creating a new one. Their password and old server-wide role no longer apply; they start with no team until they create one or accept an invite.
- **API keys created in the dashboard** before the switch stop working: they belong to no team, and pushq refuses them in SaaS mode. Create new keys inside a team.
- **Config-file keys** keep working and become operator keys.
- **Pending invite and password-reset links** stop working.
Plan the switch like a migration: create the teams, move workloads to queues created with each team's own keys, then update your apps to use those keys.
---
# Queues API reference
> pushq Queues API reference: create, upsert, get, list, patch, pause, resume, purge and delete queues and read queue stats, with SDK and curl examples.
Source: https://pushqueue.dev/docs/reference/rest/queues/
The Queues API creates and manages pushq queues. A queue holds tasks and decides how they are delivered: how fast (`rate_limits`), how failures are retried (`retry`), where relative task paths point and which headers are forced (`target`), and where permanently failed tasks go (`dead_letter_queue`). To put work on a queue, see the [Tasks API reference](https://pushqueue.dev/docs/reference/rest/tasks/).
All examples use the hosted API at `https://api.pushqueue.dev` and an API key in `$PUSHQ_API_KEY`. Self-hosted servers expose the same endpoints at their own URL.
:::note[Queue names in paths]
Queue names may contain `/` to group queues into folders (`user/instagram`). In a URL path the whole name is **one** segment, so encode the slash: `/v1/queues/user%2Finstagram`. An unencoded slash is read as a different route and returns `404 not_found` with a hint to encode it. The SDKs encode queue names for you.
:::
## Create an SDK client
Every example on this page is shown in TypeScript, Python, Go, Java and .NET, plus the raw `curl` request. The SDK snippets assume a client named `pq`, created like this (see [install and configure an SDK](https://pushqueue.dev/docs/getting-started/sdks/) for self-hosted URLs, timeouts and other options):
**TypeScript**
```ts
const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });
```
**Python**
```python
import os
from pushq import Pushq, RateLimits, Retry, Target
pq = Pushq(api_key=os.environ["PUSHQ_API_KEY"])
```
**Go**
```go
import (
"context"
"os"
pushq "github.com/blissfulrays/pushq/sdks/go"
)
pq := pushq.New("", os.Getenv("PUSHQ_API_KEY")) // "" = https://api.pushqueue.dev
ctx := context.Background()
```
**Java**
```java
import io.pushq.*;
Pushq pq = Pushq.builder().apiKey(System.getenv("PUSHQ_API_KEY")).build();
```
**.NET**
```csharp
using Pushq;
using var pq = new PushqClient(apiKey: Environment.GetEnvironmentVariable("PUSHQ_API_KEY"));
```
Parameter tables on this page use the JSON field names (`rate_limits.max_dispatches_per_second`). The SDKs use their language's casing for the same fields: camelCase in TypeScript and Java (`maxDispatchesPerSecond`), snake_case in Python, PascalCase in Go and .NET (`MaxDispatchesPerSecond`).
## Queue API permissions
| Endpoint | Writer API key | Admin API key | Dashboard roles |
|---|---|---|---|
| Create, upsert, patch, pause, resume, purge | yes | yes | member, admin |
| Get a queue, get stats | yes | yes | viewer, member, admin |
| List queues | no | yes | viewer, member, admin |
| Delete a queue | no | yes | member, admin |
A request without valid credentials gets `401 unauthenticated`; a key or role that lacks the permission gets `403 permission_denied`. On the hosted service each team has its own queue namespace: two teams can both have a queue called `emails` and never see each other's.
## Queue names and folders
A queue name is 1–200 characters made of `/`-separated segments. Each segment starts with a lowercase letter or digit and contains only `a-z`, `0-9` and `-` (regex `^[a-z0-9][a-z0-9-]*(/[a-z0-9][a-z0-9-]*)*$`). Folders have no configuration of their own; they exist as long as some queue name uses them.
Pass folder names to the SDKs as-is; they URL-encode the name as one path segment for you:
**TypeScript**
```ts
await pq.upsertQueue("user/instagram", { target: { baseUrl: "https://api.example.com" } });
await pq.createTask("user/instagram", { path: "/sync", jsonBody: { user_id: 42 } });
```
**Python**
```python
pq.upsert_queue("user/instagram", target=Target(base_url="https://api.example.com"))
pq.create_task("user/instagram", path="/sync", json_body={"user_id": 42})
```
**Go**
```go
_, err := pq.UpsertQueue(ctx, "user/instagram", pushq.QueueConfig{
Target: &pushq.Target{BaseURL: "https://api.example.com"},
})
_, err = pq.CreateTask(ctx, "user/instagram", pushq.TaskCreate{
Path: "/sync",
JSONBody: map[string]any{"user_id": 42},
})
```
**Java**
```java
pq.upsertQueue("user/instagram", QueueConfig.builder()
.target(Target.builder().baseUrl("https://api.example.com").build())
.build());
pq.createTask("user/instagram", TaskCreate.builder()
.path("/sync")
.jsonBody(Map.of("user_id", 42))
.build());
```
**.NET**
```csharp
await pq.UpsertQueueAsync("user/instagram", new QueueConfig
{
Target = new Target { BaseUrl = "https://api.example.com" },
});
await pq.CreateTaskAsync("user/instagram", new TaskCreate { Path = "/sync", JsonBody = new { user_id = 42 } });
```
**curl**
```bash
curl -X PUT https://api.pushqueue.dev/v1/queues/user%2Finstagram \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"target":{"base_url":"https://api.example.com"}}'
curl -X POST https://api.pushqueue.dev/v1/queues/user%2Finstagram/tasks \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path":"/sync","json_body":{"user_id":42}}'
```
List one folder with `name_prefix=user/` on [list queues](#list-queues). For a full walkthrough, see [per-tenant queues](https://pushqueue.dev/docs/patterns/per-tenant-queues/).
## The queue object
Every endpoint on this page except delete and stats returns a queue object.
```json
{
"name": "emails",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 3600,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 5
},
"target": {
"base_url": "https://app.example.com",
"method": "POST",
"headers": { "X-Source": "pushq" },
"has_signing_secret": true
},
"dead_letter_queue": "emails-dead",
"purged_at": "2026-11-27T09:00:00Z",
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T10:15:00.12Z"
}
```
| Field | Type | Description |
|---|---|---|
| `name` | string | The queue name. |
| `state` | string | `running` (dispatching), `paused` (accepting tasks, not dispatching) or `disabled` (rejects new tasks and force-runs). |
| `rate_limits.max_dispatches_per_second` | number | Maximum rate at which tasks are started. |
| `rate_limits.max_burst_size` | integer | Effective token-bucket size. If you configured `0` (auto), this is the resolved value: `ceil(max_dispatches_per_second)` clamped to 1–500. |
| `rate_limits.max_concurrent_dispatches` | integer | Maximum requests in flight at once for this queue. |
| `retry.max_attempts` | integer | Total attempts including the first. `-1` means unlimited. |
| `retry.max_retry_duration_seconds` | number | Time limit for retrying, measured from the first attempt. `0` means unlimited. |
| `retry.min_backoff_seconds` | number | Delay before the first retry. |
| `retry.max_backoff_seconds` | number | Upper bound on any retry delay. |
| `retry.max_doublings` | integer | How many times the backoff doubles before it grows linearly. |
| `target.base_url` | string | Base URL that relative task `path`s are resolved against. Omitted when not set. |
| `target.method` | string | HTTP method that overrides every task's method at dispatch. Omitted when not set. |
| `target.headers` | object | Headers set on every dispatch; they win over task headers with the same name. Omitted when empty. |
| `target.has_signing_secret` | boolean | Whether deliveries are signed. The secret itself is never returned. |
| `dead_letter_queue` | string | Queue that receives a copy of each permanently failed task. Omitted when not set. |
| `purged_at` | string (RFC 3339) | Time of the last purge. Omitted if the queue was never purged. |
| `created_at` | string (RFC 3339) | When the queue was created. |
| `updated_at` | string (RFC 3339) | When its configuration or state last changed. |
For how these settings behave, see [how queues work](https://pushqueue.dev/docs/concepts/queues/), [rate limiting with queues](https://pushqueue.dev/docs/guides/rate-limits/), [retry backoff and max attempts](https://pushqueue.dev/docs/concepts/retries/) and [dead-letter queues](https://pushqueue.dev/docs/concepts/dead-letter-queues/).
## Queue configuration fields (rate limits, retry, target)
The create, upsert and patch endpoints accept the same configuration fields. Ranges are enforced on the final configuration; an out-of-range value returns `400 invalid_argument` naming the field.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `rate_limits.max_dispatches_per_second` | number | no | `500` | Must be greater than 0 and at most 10000. |
| `rate_limits.max_burst_size` | integer | no | `0` (auto) | 0–10000. `0` derives the burst from the rate: `ceil(rate)` clamped to 1–500. |
| `rate_limits.max_concurrent_dispatches` | integer | no | `1000` | 1–10000. |
| `retry.max_attempts` | integer | no | `100` | `-1` (unlimited) or at least 1. Includes the first attempt. |
| `retry.max_retry_duration_seconds` | number | no | `0` (unlimited) | At least 0. Measured from the first attempt. |
| `retry.min_backoff_seconds` | number | no | `0.1` | At least 0. |
| `retry.max_backoff_seconds` | number | no | `3600` | Must be at least `min_backoff_seconds`. |
| `retry.max_doublings` | integer | no | `16` | 0–31. |
| `target.base_url` | string | no | none | Absolute `http` or `https` URL. Lets tasks use a relative `path` instead of a full `url`. |
| `target.method` | string | no | none | One of `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS` (case-insensitive; stored uppercase). Overrides each task's method; with `GET`, `HEAD`, `DELETE` or `OPTIONS` the task body is not sent. |
| `target.headers` | object (string → string) | no | none | Headers added to every dispatch, overriding task headers of the same name. Names and values must be valid HTTP; `Host`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Keep-Alive`, `Upgrade`, `TE` and `Trailer` are reserved. Total size of names and values at most 16 KiB. |
| `target.signing_secret` | string | no | none | Secret used to sign deliveries with [Standard Webhooks](https://www.standardwebhooks.com/) headers (`webhook-id`, `webhook-timestamp`, `webhook-signature`). A `whsec_`-prefixed secret is base64-decoded; any other string is used as raw bytes. Write-only: responses show `has_signing_secret` instead. `""` removes it. |
| `dead_letter_queue` | string | no | none | Name of another queue that receives a copy of each task that fails permanently. Must follow the queue name rules and cannot be the queue itself. It does not have to exist when you set it, but it must exist when a task fails, or the copy is dropped. `""` removes it. |
## Create a queue
`POST /v1/queues`
Creates a new queue and fails if the name is already taken. Use this when creating a queue should be a one-time, deliberate step (for example in a provisioning script that must notice name collisions). If you want "create it if missing, otherwise make it match this config", use [create or update a queue (upsert)](#create-or-update-a-queue-upsert) instead. A new queue always starts in the `running` state.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | yes | — | The queue name; see [Queue name rules](#queue-names-and-folders). |
| `rate_limits` | object | no | defaults below | Rate limits; see [Queue configuration fields](#queue-configuration-fields-rate-limits-retry-target). |
| `rate_limits.max_dispatches_per_second` | number | no | `500` | (0, 10000]. |
| `rate_limits.max_burst_size` | integer | no | `0` (auto) | [0, 10000]. |
| `rate_limits.max_concurrent_dispatches` | integer | no | `1000` | [1, 10000]. |
| `retry` | object | no | defaults below | Retry policy. |
| `retry.max_attempts` | integer | no | `100` | `-1` or ≥ 1. |
| `retry.max_retry_duration_seconds` | number | no | `0` | ≥ 0; `0` = unlimited. |
| `retry.min_backoff_seconds` | number | no | `0.1` | ≥ 0. |
| `retry.max_backoff_seconds` | number | no | `3600` | ≥ `min_backoff_seconds`. |
| `retry.max_doublings` | integer | no | `16` | [0, 31]. |
| `target` | object | no | none | Delivery target settings. |
| `target.base_url` | string | no | none | Absolute http(s) URL for relative task paths. |
| `target.method` | string | no | none | Method override. |
| `target.headers` | object | no | none | Header overrides. |
| `target.signing_secret` | string | no | none | Signing secret (write-only). |
| `dead_letter_queue` | string | no | none | Dead-letter queue name. |
The request body may be at most 256 KiB.
**Example**
**TypeScript**
```ts
const queue = await pq.createQueue("emails", {
rateLimits: { maxDispatchesPerSecond: 50, maxConcurrentDispatches: 20 },
retry: { maxAttempts: 10, minBackoffSeconds: 1, maxBackoffSeconds: 300 },
target: {
baseUrl: "https://app.example.com",
headers: { "X-Source": "pushq" },
signingSecret: process.env.PUSHQ_SIGNING_SECRET,
},
deadLetterQueue: "emails-dead",
});
```
**Python**
```python
queue = pq.create_queue(
"emails",
rate_limits=RateLimits(max_dispatches_per_second=50, max_concurrent_dispatches=20),
retry=Retry(max_attempts=10, min_backoff_seconds=1, max_backoff_seconds=300),
target=Target(
base_url="https://app.example.com",
headers={"X-Source": "pushq"},
signing_secret=os.environ["PUSHQ_SIGNING_SECRET"],
),
dead_letter_queue="emails-dead",
)
```
**Go**
```go
queue, err := pq.CreateQueue(ctx, "emails", pushq.QueueConfig{
RateLimits: &pushq.RateLimits{
MaxDispatchesPerSecond: pushq.Float64(50),
MaxConcurrentDispatches: pushq.Int(20),
},
Retry: &pushq.Retry{
MaxAttempts: pushq.Int(10),
MinBackoffSeconds: pushq.Float64(1),
MaxBackoffSeconds: pushq.Float64(300),
},
Target: &pushq.Target{
BaseURL: "https://app.example.com",
Headers: map[string]string{"X-Source": "pushq"},
SigningSecret: os.Getenv("PUSHQ_SIGNING_SECRET"),
},
DeadLetterQueue: "emails-dead",
})
```
**Java**
```java
Queue queue = pq.createQueue("emails", QueueConfig.builder()
.rateLimits(RateLimits.builder().maxDispatchesPerSecond(50).maxConcurrentDispatches(20).build())
.retry(RetryConfig.builder().maxAttempts(10).minBackoffSeconds(1).maxBackoffSeconds(300).build())
.target(Target.builder()
.baseUrl("https://app.example.com")
.header("X-Source", "pushq")
.signingSecret(System.getenv("PUSHQ_SIGNING_SECRET"))
.build())
.deadLetterQueue("emails-dead")
.build());
```
**.NET**
```csharp
var queue = await pq.CreateQueueAsync("emails", new QueueConfig
{
RateLimits = new RateLimits { MaxDispatchesPerSecond = 50, MaxConcurrentDispatches = 20 },
Retry = new RetryConfig { MaxAttempts = 10, MinBackoffSeconds = 1, MaxBackoffSeconds = 300 },
Target = new Target
{
BaseUrl = "https://app.example.com",
Headers = new Dictionary { ["X-Source"] = "pushq" },
SigningSecret = Environment.GetEnvironmentVariable("PUSHQ_SIGNING_SECRET"),
},
DeadLetterQueue = "emails-dead",
});
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "emails",
"rate_limits": { "max_dispatches_per_second": 50, "max_concurrent_dispatches": 20 },
"retry": { "max_attempts": 10, "min_backoff_seconds": 1, "max_backoff_seconds": 300 },
"target": {
"base_url": "https://app.example.com",
"headers": { "X-Source": "pushq" },
"signing_secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"
},
"dead_letter_queue": "emails-dead"
}'
```
In Python, `create_queue` exists only on the synchronous `Pushq` client, not on `AsyncPushq`. To handle a taken name, catch the SDK's error and check for the `already_exists` code (see [error codes](https://pushqueue.dev/docs/reference/errors/)).
**Response**
`201 Created` with the [queue object](#the-queue-object):
```json
{
"name": "emails",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"headers": { "X-Source": "pushq" },
"has_signing_secret": true
},
"dead_letter_queue": "emails-dead",
"created_at": "2026-11-28T10:15:00.12Z",
"updated_at": "2026-11-28T10:15:00.12Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, invalid name, or a configuration value out of range. |
| 401 | `unauthenticated` | No valid API key or session. |
| 403 | `permission_denied` | The key or role can't write (for example a viewer). |
| 409 | `already_exists` | A queue with this name exists. |
| 413 | `payload_too_large` | Body over 256 KiB. |
See [API error codes](https://pushqueue.dev/docs/reference/errors/) for the error format.
## Create or update a queue (upsert)
`PUT /v1/queues/{queue}`
Makes the queue's configuration exactly match the body, creating the queue if it doesn't exist. It is idempotent, so you can call it on every deploy or even before every enqueue. PUT never changes the queue's `state`, so it can't accidentally resume a paused queue.
Use this when your code owns the queue's configuration and you want "declare it and move on" semantics. Every SDK's upsert method (`upsertQueue`, `upsert_queue`, `UpsertQueue`, `UpsertQueueAsync`) calls this endpoint.
:::caution[PUT replaces the whole configuration]
Fields you leave out are reset to their defaults, not kept: omitting `target` clears `target.base_url`, `target.method` and `target.headers`, and omitting `dead_letter_queue` removes the dead-letter queue. The one exception is `target.signing_secret`: omit it to keep the stored secret, send `""` to remove it. To change a single setting, use [update queue settings with PATCH](#update-queue-settings-patch).
:::
The response carries an `X-Pushq-Result` header: `created`, `updated` or `unchanged`.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Request body**
Same fields as [Create a queue](#create-a-queue) without `name` (the name comes from the path). Every field is optional; an empty body `{}` sets every setting to its default.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `rate_limits.max_dispatches_per_second` | number | no | `500` | (0, 10000]. |
| `rate_limits.max_burst_size` | integer | no | `0` (auto) | [0, 10000]. |
| `rate_limits.max_concurrent_dispatches` | integer | no | `1000` | [1, 10000]. |
| `retry.max_attempts` | integer | no | `100` | `-1` or ≥ 1. |
| `retry.max_retry_duration_seconds` | number | no | `0` | ≥ 0; `0` = unlimited. |
| `retry.min_backoff_seconds` | number | no | `0.1` | ≥ 0. |
| `retry.max_backoff_seconds` | number | no | `3600` | ≥ `min_backoff_seconds`. |
| `retry.max_doublings` | integer | no | `16` | [0, 31]. |
| `target.base_url` | string | no | none | Absolute http(s) URL. |
| `target.method` | string | no | none | Method override. |
| `target.headers` | object | no | none | Header overrides; replaces any existing set. |
| `target.signing_secret` | string | no | keep existing | Omit to keep the stored secret; `""` to remove it; any other value replaces it. |
| `dead_letter_queue` | string | no | none | Dead-letter queue name. |
**Example**
**TypeScript**
```ts
const queue = await pq.upsertQueue("user/instagram", {
rateLimits: { maxDispatchesPerSecond: 5, maxConcurrentDispatches: 2 },
retry: { maxAttempts: 5 },
target: { baseUrl: "https://worker.example.com" },
});
```
**Python**
```python
queue = pq.upsert_queue(
"user/instagram",
rate_limits=RateLimits(max_dispatches_per_second=5, max_concurrent_dispatches=2),
retry=Retry(max_attempts=5),
target=Target(base_url="https://worker.example.com"),
)
```
**Go**
```go
queue, err := pq.UpsertQueue(ctx, "user/instagram", pushq.QueueConfig{
RateLimits: &pushq.RateLimits{
MaxDispatchesPerSecond: pushq.Float64(5),
MaxConcurrentDispatches: pushq.Int(2),
},
Retry: &pushq.Retry{MaxAttempts: pushq.Int(5)},
Target: &pushq.Target{BaseURL: "https://worker.example.com"},
})
```
**Java**
```java
Queue queue = pq.upsertQueue("user/instagram", QueueConfig.builder()
.rateLimits(RateLimits.builder().maxDispatchesPerSecond(5).maxConcurrentDispatches(2).build())
.retry(RetryConfig.builder().maxAttempts(5).build())
.target(Target.builder().baseUrl("https://worker.example.com").build())
.build());
```
**.NET**
```csharp
var queue = await pq.UpsertQueueAsync("user/instagram", new QueueConfig
{
RateLimits = new RateLimits { MaxDispatchesPerSecond = 5, MaxConcurrentDispatches = 2 },
Retry = new RetryConfig { MaxAttempts = 5 },
Target = new Target { BaseUrl = "https://worker.example.com" },
});
```
**curl**
```bash
curl -X PUT https://api.pushqueue.dev/v1/queues/user%2Finstagram \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rate_limits": { "max_dispatches_per_second": 5, "max_concurrent_dispatches": 2 },
"retry": { "max_attempts": 5 },
"target": { "base_url": "https://worker.example.com" }
}'
```
The SDKs don't expose the `X-Pushq-Result` header; use `curl -i` or your own HTTP client if you need it. In Go, an empty `Target.SigningSecret` keeps the stored secret; set `Target.ClearSigningSecret: true` to remove it.
**Response**
`201 Created` when the queue was created, `200 OK` when it existed (whether or not anything changed). The body is the [queue object](#the-queue-object):
```json
{
"name": "user/instagram",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 5,
"max_burst_size": 5,
"max_concurrent_dispatches": 2
},
"retry": {
"max_attempts": 5,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 0.1,
"max_backoff_seconds": 3600,
"max_doublings": 16
},
"target": {
"base_url": "https://worker.example.com",
"has_signing_secret": false
},
"created_at": "2026-11-28T10:15:00.12Z",
"updated_at": "2026-11-28T10:15:00.12Z"
}
```
| Header | Description |
|---|---|
| `X-Pushq-Result` | `created`, `updated` or `unchanged`. |
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, invalid queue name, or a value out of range. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 413 | `payload_too_large` | Body over 256 KiB. |
## Get a queue
`GET /v1/queues/{queue}`
Returns one queue's current configuration and state. Use it to check how a queue is configured or whether it is paused. Writer keys can read any queue they know by name, even though they can't list queues.
**Who can call it:** writer or admin API key; dashboard viewer, member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Example**
**TypeScript**
```ts
const queue = await pq.getQueue("emails");
```
**Python**
```python
queue = pq.get_queue("emails")
```
**Go**
```go
queue, err := pq.GetQueue(ctx, "emails")
```
**Java**
```java
Queue queue = pq.getQueue("emails");
```
**.NET**
```csharp
var queue = await pq.GetQueueAsync("emails");
```
**curl**
```bash
curl https://api.pushqueue.dev/v1/queues/emails \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK` with the [queue object](#the-queue-object):
```json
{
"name": "emails",
"state": "paused",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"headers": { "X-Source": "pushq" },
"has_signing_secret": true
},
"dead_letter_queue": "emails-dead",
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T09:40:03.004Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission (for example a SaaS user with no team selected). |
| 404 | `not_found` | No queue with this name. |
## List queues
`GET /v1/queues`
Lists queues in name order, one page at a time. Use `name_prefix` to list one folder (`user/`). Use this for dashboards, audits or cleanup scripts. Writer keys can't list queues; use an admin key.
**Who can call it:** admin API key; dashboard viewer, member or admin.
**Query parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name_prefix` | string | no | none | Only queues whose name starts with this. `user/` lists the `user` folder. |
| `page_size` | integer | no | `100` | Queues per page. Values above 1000 are capped at 1000; 0 or less means 100. |
| `page_token` | string | no | none | `next_page_token` from the previous response. |
**Example**
**TypeScript**
```ts
const page = await pq.listQueues({ namePrefix: "user/", pageSize: 50 });
// page.items, page.nextPageToken
```
**Python**
```python
page = pq.list_queues(name_prefix="user/", page_size=50)
# page.items, page.next_page_token
```
**Go**
```go
queues, next, err := pq.ListQueues(ctx, pushq.ListQueuesParams{NamePrefix: "user/", PageSize: 50})
```
**Java**
```java
QueuePage page = pq.listQueues(ListQueuesParams.builder().namePrefix("user/").pageSize(50).build());
// page.getQueues(), page.getNextPageToken()
```
**.NET**
```csharp
var page = await pq.ListQueuesAsync(new ListQueuesOptions { NamePrefix = "user/", PageSize = 50 });
// page.Items, page.NextPageToken
```
**curl**
```bash
curl "https://api.pushqueue.dev/v1/queues?name_prefix=user/&page_size=50" \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"queues": [
{
"name": "user/instagram",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 5,
"max_burst_size": 5,
"max_concurrent_dispatches": 2
},
"retry": {
"max_attempts": 5,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 0.1,
"max_backoff_seconds": 3600,
"max_doublings": 16
},
"target": {
"base_url": "https://worker.example.com",
"has_signing_secret": false
},
"created_at": "2026-11-28T10:15:00.12Z",
"updated_at": "2026-11-28T10:15:00.12Z"
}
],
"next_page_token": "dXNlci9pbnN0YWdyYW0"
}
```
The SDKs return a page object instead of the raw JSON: `items` and `nextPageToken` in TypeScript, `items` and `next_page_token` in Python, `getQueues()` and `getNextPageToken()` in Java, `Items` and `NextPageToken` in .NET; Go returns the slice and the next token as separate values. In Python, `list_queues` exists only on the synchronous `Pushq` client.
| Field | Type | Description |
|---|---|---|
| `queues` | array of [queue objects](#the-queue-object) | This page of queues, ordered by name. Empty array when nothing matches. |
| `next_page_token` | string | Pass as `page_token` to get the next page. Omitted on the last page. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `page_size` is not an integer. |
| 400 | `failed_precondition` | `page_token` is malformed. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Writer API key, or a caller without list permission. |
## Update queue settings (patch)
`PATCH /v1/queues/{queue}`
Changes only the fields you send and leaves everything else as it is. Use it for targeted changes such as lowering the rate during an incident, or setting `state` to `disabled` (which pause/resume can't do). The merged result is validated before it is saved, so a patch can't leave the queue with an invalid configuration.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `state` | string | no | unchanged | `running`, `paused` or `disabled`. A disabled queue rejects new tasks and force-runs. |
| `rate_limits.max_dispatches_per_second` | number | no | unchanged | (0, 10000]. |
| `rate_limits.max_burst_size` | integer | no | unchanged | [0, 10000]; `0` = auto. |
| `rate_limits.max_concurrent_dispatches` | integer | no | unchanged | [1, 10000]. |
| `retry.max_attempts` | integer | no | unchanged | `-1` or ≥ 1. |
| `retry.max_retry_duration_seconds` | number | no | unchanged | ≥ 0; `0` = unlimited. |
| `retry.min_backoff_seconds` | number | no | unchanged | ≥ 0. |
| `retry.max_backoff_seconds` | number | no | unchanged | ≥ `min_backoff_seconds` (checked against the merged config). |
| `retry.max_doublings` | integer | no | unchanged | [0, 31]. |
| `target.base_url` | string | no | unchanged | Absolute http(s) URL; `""` removes it. |
| `target.method` | string | no | unchanged | Method override; `""` removes it. |
| `target.headers` | object | no | unchanged | Replaces the whole header-override map; `{}` removes all overrides. |
| `target.signing_secret` | string | no | unchanged | New secret; `""` removes it. |
| `dead_letter_queue` | string | no | unchanged | Dead-letter queue name; `""` removes it. |
**Example**
**TypeScript**
```ts
const queue = await pq.patchQueue("emails", {
rateLimits: { maxDispatchesPerSecond: 10 },
retry: { maxAttempts: 20 },
});
```
**Python**
```python
queue = pq.patch_queue(
"emails",
rate_limits=RateLimits(max_dispatches_per_second=10),
retry=Retry(max_attempts=20),
)
```
**Go**
```go
// The last argument is the new state ("" leaves it unchanged).
queue, err := pq.PatchQueue(ctx, "emails", pushq.QueueConfig{
RateLimits: &pushq.RateLimits{MaxDispatchesPerSecond: pushq.Float64(10)},
Retry: &pushq.Retry{MaxAttempts: pushq.Int(20)},
}, "")
```
**Java**
```java
Queue queue = pq.patchQueue("emails", QueuePatch.builder()
.rateLimits(RateLimits.builder().maxDispatchesPerSecond(10).build())
.retry(RetryConfig.builder().maxAttempts(20).build())
.build());
```
**.NET**
```csharp
var queue = await pq.PatchQueueAsync("emails", new QueuePatch
{
RateLimits = new RateLimits { MaxDispatchesPerSecond = 10 },
Retry = new RetryConfig { MaxAttempts = 20 },
});
```
**curl**
```bash
curl -X PATCH https://api.pushqueue.dev/v1/queues/emails \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rate_limits": { "max_dispatches_per_second": 10 },
"retry": { "max_attempts": 20 }
}'
```
In Python, `patch_queue` exists only on the synchronous `Pushq` client. In Go, the fourth argument of `PatchQueue` sets `state` (`"running"`, `"paused"`, `"disabled"`, or `""` to leave it unchanged).
:::caution[Clearing fields from the Go SDK]
The Go SDK never sends empty strings or empty maps, so `PatchQueue` can't clear `target.base_url`, `target.method`, `target.headers` or `dead_letter_queue`. Use `UpsertQueue` with the full configuration, or send the PATCH over HTTP with `""` / `{}`. `Target.ClearSigningSecret: true` does clear the signing secret.
:::
**Response**
`200 OK` with the updated [queue object](#the-queue-object):
```json
{
"name": "emails",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 10,
"max_burst_size": 10,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 20,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"headers": { "X-Source": "pushq" },
"has_signing_secret": true
},
"dead_letter_queue": "emails-dead",
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T10:20:41.88Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, unknown `state`, or the merged configuration is out of range. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No queue with this name. |
| 413 | `payload_too_large` | Body over 256 KiB. |
## Delete a queue
`DELETE /v1/queues/{queue}`
Deletes the queue and every task in it, immediately and permanently. Use it to remove a queue you no longer need; if you only want to drop its backlog and keep the configuration, [purge](#purge-a-queue) it instead.
**Who can call it:** admin API key; dashboard member or admin. Writer keys can't delete queues.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Example**
**TypeScript**
```ts
await pq.deleteQueue("user/instagram");
```
**Python**
```python
pq.delete_queue("user/instagram")
```
**Go**
```go
err := pq.DeleteQueue(ctx, "user/instagram")
```
**Java**
```java
pq.deleteQueue("user/instagram");
```
**.NET**
```csharp
await pq.DeleteQueueAsync("user/instagram");
```
**curl**
```bash
curl -X DELETE https://api.pushqueue.dev/v1/queues/user%2Finstagram \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Writer key or viewer role. |
| 404 | `not_found` | No queue with this name. |
## Pause a queue
`POST /v1/queues/{queue}:pause`
Stops dispatching. The queue keeps accepting new tasks, but nothing is delivered until you resume it. Use it when the receiving service is down or being deployed and you want work to pile up instead of failing and burning retries. Pausing an already-paused queue is a no-op. You can still [force-run](https://pushqueue.dev/docs/reference/rest/tasks/#run-a-task-now) individual tasks while paused.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
No request body.
**Example**
**TypeScript**
```ts
const queue = await pq.pauseQueue("emails");
```
**Python**
```python
queue = pq.pause_queue("emails")
```
**Go**
```go
queue, err := pq.PauseQueue(ctx, "emails")
```
**Java**
```java
Queue queue = pq.pauseQueue("emails");
```
**.NET**
```csharp
var queue = await pq.PauseQueueAsync("emails");
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails:pause \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK` with the [queue object](#the-queue-object), now with `"state": "paused"`:
```json
{
"name": "emails",
"state": "paused",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"has_signing_secret": true
},
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T10:22:00Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `failed_precondition` | The queue is `disabled`; a disabled queue can't be paused. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No queue with this name. |
## Resume a queue
`POST /v1/queues/{queue}:resume`
Sets the queue back to `running` so due tasks start dispatching again. This also re-enables a `disabled` queue. Resuming a running queue is a no-op.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
No request body.
**Example**
**TypeScript**
```ts
const queue = await pq.resumeQueue("emails");
```
**Python**
```python
queue = pq.resume_queue("emails")
```
**Go**
```go
queue, err := pq.ResumeQueue(ctx, "emails")
```
**Java**
```java
Queue queue = pq.resumeQueue("emails");
```
**.NET**
```csharp
var queue = await pq.ResumeQueueAsync("emails");
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails:resume \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK` with the [queue object](#the-queue-object), now with `"state": "running"`:
```json
{
"name": "emails",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"has_signing_secret": true
},
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T10:30:12.448Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No queue with this name. |
## Purge a queue
`POST /v1/queues/{queue}:purge`
Deletes every task created up to now, in any state, and keeps the queue and its configuration. Purged tasks disappear from the API at once and are removed from storage in the background; results of attempts that were in flight are discarded, and the purged task IDs can be reused right away. Tasks created after the purge are not affected. Use it to throw away a backlog you no longer want delivered, for example after a bad deploy enqueued garbage.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
No request body.
**Example**
**TypeScript**
```ts
const queue = await pq.purgeQueue("emails");
```
**Python**
```python
queue = pq.purge_queue("emails")
```
**Go**
```go
queue, err := pq.PurgeQueue(ctx, "emails")
```
**Java**
```java
Queue queue = pq.purgeQueue("emails");
```
**.NET**
```csharp
var queue = await pq.PurgeQueueAsync("emails");
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails:purge \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`202 Accepted` with the [queue object](#the-queue-object); `purged_at` is the purge watermark:
```json
{
"name": "emails",
"state": "running",
"rate_limits": {
"max_dispatches_per_second": 50,
"max_burst_size": 50,
"max_concurrent_dispatches": 20
},
"retry": {
"max_attempts": 10,
"max_retry_duration_seconds": 0,
"min_backoff_seconds": 1,
"max_backoff_seconds": 300,
"max_doublings": 16
},
"target": {
"base_url": "https://app.example.com",
"has_signing_secret": true
},
"purged_at": "2026-11-28T10:31:00Z",
"created_at": "2026-11-20T14:02:11.512Z",
"updated_at": "2026-11-28T10:31:00Z"
}
```
Response fields are described in [The queue object](#the-queue-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No queue with this name. |
## Get queue stats
`GET /v1/queues/{queue}/stats`
Returns live counts for the queue: how many tasks are due, running, scheduled for later, finished, and how many attempts ran and failed in the last minute and hour. Use it for monitoring and alerting (for example, alert when `oldest_due_age_seconds` grows, which means the queue is falling behind). Filter with `id_prefix` to see stats for one group of tasks if you give related tasks a common ID prefix.
Counts cover tasks still stored on the server; finished tasks are removed after their retention period (on self-hosted servers, 24 hours for succeeded and 7 days for failed by default), and purged tasks are excluded.
**Who can call it:** writer or admin API key; dashboard viewer, member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Query parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id_prefix` | string | no | none | Only count tasks whose ID starts with this. |
**Example**
**TypeScript**
```ts
const stats = await pq.queueStats("emails", { idPrefix: "welcome-" });
```
**Python**
```python
stats = pq.queue_stats("emails", id_prefix="welcome-")
```
**Go**
```go
stats, err := pq.QueueStats(ctx, "emails", "welcome-")
```
**Java**
```java
QueueStats stats = pq.queueStats("emails", "welcome-");
```
**.NET**
```csharp
var stats = await pq.GetQueueStatsAsync("emails", idPrefix: "welcome-");
```
**curl**
```bash
curl "https://api.pushqueue.dev/v1/queues/emails/stats?id_prefix=welcome-" \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"state": "running",
"pending": 42,
"running": 7,
"succeeded": 15320,
"failed": 12,
"scheduled_future": 310,
"oldest_due_at": "2026-11-28T10:29:58.12Z",
"oldest_due_age_seconds": 2.88,
"dispatched_last_1m": 410,
"errors_last_1m": 3,
"dispatched_last_1h": 21877,
"errors_last_1h": 96,
"last_purge": "2026-11-27T09:00:00Z"
}
```
| Field | Type | Description |
|---|---|---|
| `state` | string | The queue's state: `running`, `paused` or `disabled`. |
| `pending` | integer | Pending tasks that are due now or overdue. |
| `running` | integer | Tasks currently being delivered. |
| `succeeded` | integer | Succeeded tasks still retained. |
| `failed` | integer | Permanently failed tasks still retained. |
| `scheduled_future` | integer | Pending tasks scheduled for a later time. |
| `oldest_due_at` | string (RFC 3339) | Schedule time of the oldest due task. Omitted when nothing is due. |
| `oldest_due_age_seconds` | number | How long the oldest due task has been waiting. Omitted when nothing is due. |
| `dispatched_last_1m` | integer | Delivery attempts started in the last minute. |
| `errors_last_1m` | integer | Attempts in the last minute that did not get a 2xx response. |
| `dispatched_last_1h` | integer | Delivery attempts started in the last hour. |
| `errors_last_1h` | integer | Attempts in the last hour that did not get a 2xx response. |
| `last_purge` | string (RFC 3339) | Time of the last purge. Omitted if never purged. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission. |
| 404 | `not_found` | No queue with this name. |
## Read more
- [How queues work](https://pushqueue.dev/docs/concepts/queues/): states, folders and what each setting does.
- [Rate limiting with queues](https://pushqueue.dev/docs/guides/rate-limits/): choose `max_dispatches_per_second` and `max_concurrent_dispatches`.
- [Per-tenant queues](https://pushqueue.dev/docs/patterns/per-tenant-queues/): one queue per customer with folder names.
- [Tasks API reference](https://pushqueue.dev/docs/reference/rest/tasks/): enqueue, inspect, run and delete tasks.
- [API error codes](https://pushqueue.dev/docs/reference/errors/): the problem+json format and every `code`.
---
# REST API overview
> How the pushq REST API works: base URL, API key auth, URL-encoded queue names, pagination, errors and idempotency, plus every endpoint.
Source: https://pushqueue.dev/docs/reference/api/
Everything pushq does is available over a JSON HTTP API. The SDKs and the dashboard use the same API. This page covers the conventions every endpoint shares and lists all endpoints; each group links to its detailed reference.
Use the API directly when there's no SDK for your language, from shell scripts, or to debug what an SDK sends.
- Interactive reference (Swagger UI): https://api.pushqueue.dev/docs
- OpenAPI document: https://api.pushqueue.dev/openapi.json
A self-hosted server serves the same two pages at `/docs` and `/openapi.json`, generated from its own routes. To get the document without running a server, use `pushq openapi > openapi.json`.
## API base URL
| Server | Base URL |
|---|---|
| Hosted | `https://api.pushqueue.dev` |
| Self-hosted | Your server, e.g. `http://localhost:8080` or `https://pushq.example.com` |
API endpoints live under `/v1`. Health, metrics and documentation endpoints (`/healthz`, `/readyz`, `/metrics`, `/docs`, `/openapi.json`) sit at the root.
## Authenticate with an API key
Send an API key as a bearer token:
```bash
curl https://api.pushqueue.dev/v1/queues/emails \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
Keys look like `pq_...`. Create them in the dashboard under **Settings → API keys**, or, when self-hosting, in the server config. See [API keys](https://pushqueue.dev/docs/guides/api-keys/) for roles and rotation.
A missing or unknown key returns `401 unauthenticated`. A valid key whose role doesn't allow the call returns `403 permission_denied`.
The dashboard authenticates with a session cookie instead. Requests that change something with the cookie must also send `X-Requested-With: pushq`, which blocks cross-site request forgery. Requests with an `Authorization` header don't need it.
A `pushq dev` server, or a fresh self-hosted server before its first admin account exists, accepts requests without a key.
### Who can call what
The endpoint tables use these access levels:
| Access | API keys | Dashboard users |
|---|---|---|
| Public | No credentials needed | |
| Read | `admin`, `writer` | `admin`, `member`, `viewer` |
| Write | `admin`, `writer` | `admin`, `member` |
| List | `admin` | `admin`, `member`, `viewer` |
| Delete queue | `admin` | `admin`, `member` |
| Manage | `admin` | `admin` |
| Signed-in user | Not allowed (`401`) | Any role, with a session cookie |
A `writer` key works with queues it knows by name: it can create, change, pause, resume and purge queues and enqueue, run and delete tasks, but it can't list all queues or delete a queue.
## Request and response format
- Request and response bodies are JSON. Send `Content-Type: application/json` with a body.
- Field names are `snake_case`: `rate_limits.max_dispatches_per_second`, `delay_seconds`. The SDKs use their language's casing.
- Timestamps are RFC 3339 strings in UTC, e.g. `2026-12-01T17:00:00Z`.
- Durations are numbers of seconds and may be fractional: `"min_backoff_seconds": 0.1`.
- Operations that aren't plain CRUD use a colon suffix on the resource, Google API style: `POST /v1/queues/emails:pause`, `POST /v1/queues/emails/tasks/welcome-user-42:run`.
- Deletes answer `204 No Content`. `:purge` answers `202 Accepted`.
Request bodies have size limits: 256 KiB for queue bodies, 8 MiB for a batch, and for a single task twice `limits.max_body_bytes` plus 64 KiB (the body is base64-encoded inside the JSON). A larger request fails with `413 payload_too_large`. The decoded task body itself must fit in `limits.max_body_bytes` (default 1 MiB).
## URL-encode queue names
Queue names can contain `/` to form folders, such as `user/instagram`. In a URL path the whole name is **one** segment, so encode the slash as `%2F`:
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/user%2Finstagram/tasks \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "/hooks/post"}'
```
An unencoded slash produces a different path and returns `404 not_found` with a hint to encode it. Query parameters take the name as-is: `GET /v1/queues?name_prefix=user/` lists the folder. The SDKs encode queue names for you. If you run a reverse proxy, make sure it doesn't decode `%2F`; see [reverse proxy setup](https://pushqueue.dev/docs/self-hosting/deploy/#put-pushq-behind-a-reverse-proxy).
Valid queue names are 1 to 200 characters of `/`-separated segments, each matching `[a-z0-9][a-z0-9-]*`. Task IDs match `[A-Za-z0-9_-]{1,500}`.
## Paginate list results
`GET /v1/queues` and `GET /v1/queues/{queue}/tasks` return one page at a time:
| Query parameter | Description |
|---|---|
| `page_size` | Items per page. Default 100, maximum 1000 (larger values are capped). |
| `page_token` | The `next_page_token` from the previous response. |
The response holds the items (`queues` or `tasks`) and a `next_page_token`. When `next_page_token` is missing, you have the last page. Keep your other filters (`state`, `id_prefix`, `name_prefix`) the same while you page. A malformed token returns `400 failed_precondition`.
**TypeScript**
```ts
let pageToken: string | undefined;
do {
const page = await pq.listTasks("emails", { state: "failed", pageSize: 500, pageToken });
for (const task of page.items) console.log(task.id);
pageToken = page.nextPageToken;
} while (pageToken);
```
**Python**
```python
page_token = None
while True:
page = pq.list_tasks("emails", state="failed", page_size=500, page_token=page_token)
for task in page.items:
print(task.id)
page_token = page.next_page_token
if not page_token:
break
```
**Go**
```go
token := ""
for {
tasks, next, err := pq.ListTasks(ctx, "emails", pushq.ListTasksParams{State: "failed", PageSize: 500, PageToken: token})
if err != nil {
return err
}
for _, t := range tasks {
fmt.Println(t.ID)
}
if next == "" {
break
}
token = next
}
```
**Java**
```java
String token = null;
do {
TaskPage page = pq.listTasks("emails", ListTasksParams.builder()
.state("failed").pageSize(500).pageToken(token).build());
for (Task task : page.getTasks()) System.out.println(task.getId());
token = page.getNextPageToken();
} while (token != null && !token.isEmpty());
```
**.NET**
```csharp
string? token = null;
do
{
var page = await pq.ListTasksAsync("emails", new ListTasksOptions
{
State = TaskState.Failed, PageSize = 500, PageToken = token,
});
foreach (var task in page.Items) Console.WriteLine(task.Id);
token = page.NextPageToken;
} while (!string.IsNullOrEmpty(token));
```
**curl**
```bash
token=""
while :; do
resp=$(curl -s "https://api.pushqueue.dev/v1/queues/emails/tasks?state=failed&page_size=500&page_token=$token" \
-H "Authorization: Bearer $PUSHQ_API_KEY")
echo "$resp" | jq -r '.tasks[].id'
token=$(echo "$resp" | jq -r '.next_page_token // empty')
[ -z "$token" ] && break
done
```
Tasks are listed newest first.
## Error responses
Every error is an [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) problem+json body with a stable machine-readable `code`:
```json
{
"type": "about:blank",
"title": "Not Found",
"status": 404,
"code": "not_found",
"detail": "not found",
"instance": "/v1/queues/emails"
}
```
Branch on `code`, not on `detail`. See [API error codes](https://pushqueue.dev/docs/reference/errors/) for every code and how to handle it.
## Idempotency and safe retries
There is no `Idempotency-Key` header. Instead:
- **Queue upserts** (`PUT /v1/queues/{queue}`) are idempotent: send the same config as often as you like. The response answers `201` when it created the queue and `200` otherwise, with an `X-Pushq-Result` header of `created`, `updated` or `unchanged`. An upsert never changes whether the queue is running or paused.
- **Task creation** is deduplicated by `task_id`. If you retry an enqueue after a timeout or network error with the same `task_id`, a `409 already_exists` means the first request went through. The ID stays reserved for the server's dedup window (1 hour by default) after the task finishes or is deleted. Without a `task_id` the server generates one, and a retried request can create a duplicate task.
- **Batch enqueue** (`POST /v1/queues/{queue}/tasks:batch`) is not atomic. It answers `200` with one result per task, in request order; each result holds either the created `task` or an `error` with a `code` and `detail`. Retry only the failed items, and give tasks IDs so retries are safe.
Retry requests that fail with `5xx` or a network error, with backoff. Don't retry `4xx` errors without changing the request, except `429 rate_limited`.
## API endpoints
### Queue endpoints
Details: [Queues reference](https://pushqueue.dev/docs/reference/rest/queues/).
| Method | Path | Summary | Access |
|---|---|---|---|
| `POST` | `/v1/queues` | Create a queue (fails with `already_exists` if the name is taken) | Write |
| `PUT` | `/v1/queues/{queue}` | Create or replace a queue's configuration | Write |
| `GET` | `/v1/queues/{queue}` | Get a queue | Read |
| `PATCH` | `/v1/queues/{queue}` | Update some of a queue's settings, including `state` | Write |
| `DELETE` | `/v1/queues/{queue}` | Delete a queue and all its tasks | Delete queue |
| `GET` | `/v1/queues` | List queues (`name_prefix`, `page_size`, `page_token`) | List |
| `POST` | `/v1/queues/{queue}:pause` | Pause dispatching | Write |
| `POST` | `/v1/queues/{queue}:resume` | Resume dispatching | Write |
| `POST` | `/v1/queues/{queue}:purge` | Delete every task created up to now | Write |
| `GET` | `/v1/queues/{queue}/stats` | Live queue statistics (`id_prefix`) | Read |
### Task endpoints
Details: [Tasks reference](https://pushqueue.dev/docs/reference/rest/tasks/).
| Method | Path | Summary | Access |
|---|---|---|---|
| `POST` | `/v1/queues/{queue}/tasks` | Enqueue a task | Write |
| `POST` | `/v1/queues/{queue}/tasks:batch` | Enqueue up to 500 tasks | Write |
| `GET` | `/v1/queues/{queue}/tasks` | List tasks, newest first (`state`, `id_prefix`, `view`, `page_size`, `page_token`) | Read |
| `GET` | `/v1/queues/{queue}/tasks/{taskID}` | Get a task (`view=full` includes headers and body) | Read |
| `DELETE` | `/v1/queues/{queue}/tasks/{taskID}` | Delete a task | Write |
| `POST` | `/v1/queues/{queue}/tasks/{taskID}:run` | Dispatch a task now, bypassing rate limits and the paused state | Write |
| `GET` | `/v1/queues/{queue}/tasks/{taskID}/attempts` | A task's delivery attempts, newest first | Read |
### API key endpoints
Details: [API keys reference](https://pushqueue.dev/docs/reference/rest/api-keys/).
| Method | Path | Summary | Access |
|---|---|---|---|
| `GET` | `/v1/api-keys` | List API keys | Manage |
| `POST` | `/v1/api-keys` | Create an API key (the secret is returned once) | Manage |
| `DELETE` | `/v1/api-keys/{id}` | Revoke an API key | Manage |
### Team and user endpoints
Details: [Teams and users reference](https://pushqueue.dev/docs/reference/rest/teams-and-users/). Endpoints marked SaaS exist only on servers in [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/), including the hosted service; those marked self-hosted exist only without it.
| Method | Path | Summary | Access |
|---|---|---|---|
| `PATCH` | `/v1/me` | Change your name | Signed-in user |
| `POST` | `/v1/me/password` | Change your password (self-hosted) | Signed-in user |
| `GET` | `/v1/teams` | Your teams (SaaS) | Signed-in user |
| `POST` | `/v1/teams` | Create a team (SaaS) | Signed-in user |
| `POST` | `/v1/teams/{id}:switch` | Switch your session to another of your teams (SaaS) | Signed-in user |
| `PATCH` | `/v1/teams/current` | Rename the current team (SaaS) | Manage |
| `GET` | `/v1/users` | List members | Manage |
| `PATCH` | `/v1/users/{id}` | Change a member's role | Manage |
| `DELETE` | `/v1/users/{id}` | Remove a member | Manage |
| `POST` | `/v1/users/{id}/reset-link` | Create a password-reset link (self-hosted) | Manage |
| `GET` | `/v1/invites` | Pending invites | Manage |
| `POST` | `/v1/invites` | Invite someone | Manage |
| `DELETE` | `/v1/invites/{id}` | Revoke an invite | Manage |
### Sign-in endpoints
Details: [Sign-in reference](https://pushqueue.dev/docs/reference/rest/auth/). These endpoints power the dashboard's sign-in pages. You don't need them to use queues and tasks.
| Method | Path | Summary | Access |
|---|---|---|---|
| `GET` | `/v1/auth/session` | Who am I, and how does this server sign people in? | Public |
| `POST` | `/v1/auth/setup` | Create the first admin account (self-hosted) | Public |
| `POST` | `/v1/auth/login` | Sign in with email and password (self-hosted) | Public |
| `POST` | `/v1/auth/logout` | Sign out | Public |
| `GET` | `/v1/auth/invites/{token}` | Look up an invite or password-reset link (self-hosted) | Public |
| `POST` | `/v1/auth/invites/{token}:accept` | Accept an invite or reset link (self-hosted) | Public |
| `POST` | `/v1/auth/email-code` | Email a 6-digit sign-in code (SaaS) | Public |
| `POST` | `/v1/auth/email-code:verify` | Sign in with the emailed code (SaaS) | Public |
| `GET` | `/v1/auth/email-verification` | Is a sign-in waiting for an email verification code? (SaaS) | Public |
| `POST` | `/v1/auth/email-verification` | Finish a sign-in with the emailed verification code (SaaS) | Public |
| `GET` | `/v1/auth/workos/login` | Start signing in with GitHub (SaaS) | Public |
| `GET` | `/v1/auth/workos/callback` | Where GitHub sign-in returns (SaaS) | Public |
### System endpoints
Details: [System reference](https://pushqueue.dev/docs/reference/rest/system/).
| Method | Path | Summary | Access |
|---|---|---|---|
| `GET` | `/healthz` | Liveness check (`ok`) | Public |
| `GET` | `/readyz` | Readiness check; reports the dispatcher role | Public |
| `GET` | `/metrics` | Prometheus metrics | Public by default; otherwise List (in SaaS mode, only the operator's config-file keys) |
| `GET` | `/openapi.json` | The OpenAPI document | Public |
| `GET` | `/docs` | Interactive API docs (Swagger UI) | Public |
| `GET` | `/v1/version` | Server version, commit and database dialect | Read |
## Read more
- [API error codes](https://pushqueue.dev/docs/reference/errors/): every `code` and how to handle it.
- [Install & configure an SDK](https://pushqueue.dev/docs/getting-started/sdks/): typed clients for TypeScript, Python, Go, Java and .NET.
- [API keys](https://pushqueue.dev/docs/guides/api-keys/): create, scope and revoke keys.
- [Queues](https://pushqueue.dev/docs/concepts/queues/) and [tasks](https://pushqueue.dev/docs/concepts/tasks/): what the fields mean.
---
# API error codes
> Every pushq API error code with its HTTP status, cause and fix, the problem+json error format, and how each SDK surfaces errors.
Source: https://pushqueue.dev/docs/reference/errors/
When a request fails, the pushq API answers with a non-2xx status and an [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) 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
```bash
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
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.
## Error code reference
| Code | HTTP status | Retry? |
|---|---|---|
| [`invalid_argument`](#invalid_argument) | 400, 405 | No, fix the request |
| [`failed_precondition`](#failed_precondition) | 400 | No, change the state first |
| [`unauthenticated`](#unauthenticated) | 401 | No, fix the credentials |
| [`permission_denied`](#permission_denied) | 403 | No, use a key or role that's allowed |
| [`email_verification_required`](#email_verification_required) | 403 | Finish verification |
| [`not_found`](#not_found) | 404 | No |
| [`already_exists`](#already_exists) | 409 | No; often means success |
| [`payload_too_large`](#payload_too_large) | 413 | No, shrink the request |
| [`rate_limited`](#rate_limited) | 429 | Yes, after `Retry-After` |
| [`internal`](#internal) | 500, 502, 503 | Yes, with backoff |
### 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_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.
### 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`.
- `: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.
### unauthenticated
**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.
### permission_denied
**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](https://pushqueue.dev/docs/guides/api-keys/) and the [access levels for each endpoint](https://pushqueue.dev/docs/reference/api/#who-can-call-what).
### 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
**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.
### already_exists
**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.
### 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
**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
**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
`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`:
```json
{
"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
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:
**TypeScript**
```ts
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;
}
}
```
**Python**
```python
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
```
**Go**
```go
_, 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.Error
if errors.As(err, &pe) {
log.Printf("pushq error %d %s: %s", pe.Status, pe.Code, pe.Detail)
}
if err != nil {
return err
}
```
**Java**
```java
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;
}
}
```
**.NET**
```csharp
try
{
await pq.CreateTaskAsync("emails", new TaskCreate { TaskId = "welcome-user-42", Path = "/send" });
}
catch (PushqException e) when (e.Code == "already_exists")
{
// already enqueued
}
```
**curl**
```bash
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 1
fi
```
## Read more
- [REST API overview](https://pushqueue.dev/docs/reference/api/): authentication, pagination and idempotency.
- [Tasks](https://pushqueue.dev/docs/concepts/tasks/): task IDs and deduplication.
- [Install & configure an SDK](https://pushqueue.dev/docs/getting-started/sdks/): error types in each language.
- [Retries and backoff](https://pushqueue.dev/docs/concepts/retries/): delivery retries, which are separate from API errors.
---
# Tasks API reference
> pushq Tasks API reference: enqueue tasks singly or in batches, list, get, run now and delete them, and read delivery attempts, with examples.
Source: https://pushqueue.dev/docs/reference/rest/tasks/
The Tasks API is how you put work on a pushq queue and follow it through delivery. A task is one HTTP request that pushq will send to your endpoint, on time, at the queue's rate, with retries. This page documents every task endpoint: enqueue a task, enqueue tasks in bulk, list and get tasks, run a task now, delete a task, and list its delivery attempts.
**TypeScript**
```ts
const task = await pq.createTask("emails", {
taskId: "welcome-user-42",
path: "/hooks/send-welcome",
jsonBody: { user_id: 42 },
delaySeconds: 3600,
});
```
**Python**
```python
task = pq.create_task(
"emails",
task_id="welcome-user-42",
path="/hooks/send-welcome",
json_body={"user_id": 42},
delay_seconds=3600,
)
```
**Go**
```go
task, err := pq.CreateTask(ctx, "emails", pushq.TaskCreate{
TaskID: "welcome-user-42",
Path: "/hooks/send-welcome",
JSONBody: map[string]any{"user_id": 42},
DelaySeconds: pushq.Float64(3600),
})
```
**Java**
```java
Task task = pq.createTask("emails", TaskCreate.builder()
.taskId("welcome-user-42")
.path("/hooks/send-welcome")
.jsonBody(Map.of("user_id", 42))
.delaySeconds(3600)
.build());
```
**.NET**
```csharp
PushqTask task = await pq.CreateTaskAsync("emails", new TaskCreate
{
TaskId = "welcome-user-42",
Path = "/hooks/send-welcome",
JsonBody = new { user_id = 42 },
Delay = TimeSpan.FromHours(1),
});
```
**curl**
```bash
curl -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":"/hooks/send-welcome","json_body":{"user_id":42},"delay_seconds":3600}'
```
The examples assume an SDK client named `pq` (and, in Go, a `ctx`), created as shown in [install and configure an SDK](https://pushqueue.dev/docs/getting-started/sdks/). They use the hosted API at `https://api.pushqueue.dev`; self-hosted servers expose the same endpoints at their own URL. Parameter tables use the JSON field names (`dispatch_deadline_seconds`); the SDKs use their language's casing for the same fields: camelCase in TypeScript and Java (`dispatchDeadlineSeconds`), snake_case in Python, PascalCase in Go and .NET.
:::note[Queue names in paths]
Queue names may contain `/` (folders such as `user/instagram`). In a URL path the whole name is **one** segment, so encode the slash: `/v1/queues/user%2Finstagram/tasks`. The SDKs encode queue names for you. Task IDs never contain `/`.
:::
## Task API permissions
| Endpoint | Writer API key | Admin API key | Dashboard roles |
|---|---|---|---|
| Enqueue, batch enqueue, run, delete | yes | yes | member, admin |
| List, get, list attempts | yes | yes | viewer, member, admin |
A request without valid credentials gets `401 unauthenticated`; a key or role without the permission gets `403 permission_denied`.
## The task object
Every endpoint that returns a task uses this shape.
```json
{
"id": "welcome-user-42",
"queue": "emails",
"state": "pending",
"url": "/hooks/send-welcome",
"method": "POST",
"headers": { "Content-Type": "application/json" },
"body_base64": "eyJ1c2VyX2lkIjo0Mn0=",
"schedule_time": "2026-11-28T11:15:00.12Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 600,
"retry": { "max_attempts": 3 },
"dispatch_count": 1,
"response_count": 1,
"first_attempt_at": "2026-11-28T11:15:00.304Z",
"last_attempt": {
"at": "2026-11-28T11:15:00.304Z",
"status": 503,
"error": "non_2xx: upstream unavailable"
}
}
```
| Field | Type | Description |
|---|---|---|
| `id` | string | Task ID: the `task_id` you sent, or a server-generated UUIDv7. |
| `queue` | string | Queue name. |
| `state` | string | `pending` (waiting for its time or a dispatch slot, including between retries), `running` (being delivered now), `succeeded` (got a 2xx) or `failed` (retries exhausted, or a task whose own headers can never be sent). |
| `url` | string | The absolute `url`, or the `path` as sent (resolved against the queue's `target.base_url` at dispatch). |
| `method` | string | HTTP method stored on the task. A queue-level `target.method` overrides it at dispatch. |
| `headers` | object | Task headers. Only in the full view (and in create responses); omitted when empty. |
| `body_base64` | string | Request body, base64-encoded. Only in the full view (and in create responses); omitted when empty. |
| `schedule_time` | string (RFC 3339) | When the task is (or was) due. Moves forward on each retry, and to "now" on a force-run. |
| `created_at` | string (RFC 3339) | When the task was created. |
| `dispatch_deadline_seconds` | number | How long pushq waits for a response on each attempt. |
| `retry` | object | The per-task retry override you sent (only the fields you set), not the effective policy. Omitted when there is none. Fields as in [retry fields](#enqueue-a-task). |
| `dispatch_count` | integer | Attempts started so far. |
| `response_count` | integer | Attempts that got an HTTP response (any status). |
| `first_attempt_at` | string (RFC 3339) | When the first attempt started. Omitted before the first attempt. |
| `finished_at` | string (RFC 3339) | When the task succeeded or failed for good. Omitted while it is pending or running. |
| `last_attempt.at` | string (RFC 3339) | When the latest attempt started. `last_attempt` is omitted before the first attempt. |
| `last_attempt.status` | integer | HTTP status of the latest attempt. Omitted when no response arrived. |
| `last_attempt.error` | string | Error kind of the latest attempt, followed by up to 512 characters of detail (`non_2xx: `). Omitted on success. |
## Enqueue a task
`POST /v1/queues/{queue}/tasks`
Creates one task. pushq will send it as an HTTP request to `url` (or the queue's `target.base_url` + `path`) at `schedule_time`, within the queue's rate limits, and retry it on failure according to the queue's retry policy merged with any per-task `retry` override. Use this for every unit of background work: send an email, call a webhook, run a job later.
Give the task a `task_id` when the same work might be enqueued twice (a retried request, a duplicate event): a second enqueue with the same ID in the same queue fails with `409 already_exists` instead of creating a duplicate. That makes `task_id` your idempotency key. See [deduplicate tasks with task IDs](https://pushqueue.dev/docs/patterns/deduplication/).
Tasks can be added to a paused queue (they wait until it's resumed) but not to a disabled one.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). The queue must exist. |
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `task_id` | string | no | server-generated UUIDv7 | Your ID for the task, `[A-Za-z0-9_-]`, 1–500 characters. Deduplicates within the queue (see below). |
| `url` | string | one of `url`/`path` | — | Absolute `http` or `https` URL to call, at most 2083 characters. |
| `path` | string | one of `url`/`path` | — | Path starting with `/`, appended to the queue's `target.base_url` at dispatch time. The queue must have a `target.base_url`. |
| `method` | string | no | `POST` | `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS` (case-insensitive). |
| `headers` | object (string → string) | no | none | Request headers. Names and values must be valid HTTP; `Host`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Keep-Alive`, `Upgrade`, `TE` and `Trailer` are reserved. Total size at most 16 KiB (self-hosted default). Queue `target.headers` override these at dispatch. |
| `json_body` | any JSON value | no | none | Body to send as JSON. Sets `Content-Type: application/json` unless you set a `Content-Type` header. Can't be combined with `body_base64`. |
| `body_base64` | string | no | none | Raw body, standard base64. Without a `Content-Type` header it is sent as `application/octet-stream`. Can't be combined with `json_body`. |
| `schedule_time` | string (RFC 3339) | no | now | When to send it. A time in the past means "now". At most 1 year ahead (self-hosted default). Can't be combined with `delay_seconds`. |
| `delay_seconds` | number | no | `0` | Send it this many seconds from now. At least 0; also limited by the 1-year schedule-ahead limit. |
| `dispatch_deadline_seconds` | number | no | `600` | How long to wait for a response on each attempt before it counts as a `timeout`. 15–1800. |
| `retry` | object | no | queue's policy | Per-task override of the queue's retry policy; set only the fields you want to change. |
| `retry.max_attempts` | integer | no | queue's | `-1` (unlimited) or at least 1, including the first attempt. |
| `retry.max_retry_duration_seconds` | number | no | queue's | At least 0; `0` = unlimited. Measured from the first attempt. |
| `retry.min_backoff_seconds` | number | no | queue's | At least 0. |
| `retry.max_backoff_seconds` | number | no | queue's | At least `min_backoff_seconds`. |
| `retry.max_doublings` | integer | no | queue's | 0–31. |
A body (`json_body` or `body_base64`) is only allowed with `POST`, `PUT` or `PATCH`, and may be at most 1 MiB once decoded (self-hosted default). The JSON request itself may be at most twice that plus 64 KiB. Per-task `retry` values are checked against the server's default retry policy when the task is created; the queue's policy fills in the fields you leave out when the task runs. See [retry backoff and max attempts](https://pushqueue.dev/docs/concepts/retries/).
**How long a task ID stays taken.** A `task_id` is reserved in its queue for as long as a task with that ID is stored: while it is pending or running, after it finishes until retention cleanup removes it (self-hosted defaults: 24 hours after success, 7 days after failure), and for the dedup window after you [delete a task](#delete-a-task) (self-hosted default: 1 hour). [Purging the queue](https://pushqueue.dev/docs/reference/rest/queues/#purge-a-queue) frees all IDs immediately. Limits on the hosted service may differ from these self-hosted defaults.
**Example**
The example at the top of this page enqueues a JSON task with a delay. This one calls an absolute URL with a raw body at a fixed time:
**TypeScript**
```ts
const task = await pq.createTask("emails", {
url: "https://api.example.com/hooks/digest",
method: "PUT",
headers: { "Content-Type": "text/plain" },
body: "weekly digest for user 42", // string or Uint8Array; the SDK base64-encodes it
scheduleTime: new Date("2026-12-01T09:00:00Z"),
dispatchDeadlineSeconds: 120,
retry: { maxAttempts: 3 },
});
```
**Python**
```python
from datetime import datetime, timezone
from pushq import Retry
task = pq.create_task(
"emails",
url="https://api.example.com/hooks/digest",
method="PUT",
headers={"Content-Type": "text/plain"},
body=b"weekly digest for user 42", # raw bytes; the SDK base64-encodes them
schedule_time=datetime(2026, 12, 1, 9, 0, tzinfo=timezone.utc),
dispatch_deadline_seconds=120,
retry=Retry(max_attempts=3),
)
```
**Go**
```go
at := time.Date(2026, 12, 1, 9, 0, 0, 0, time.UTC)
task, err := pq.CreateTask(ctx, "emails", pushq.TaskCreate{
URL: "https://api.example.com/hooks/digest",
Method: "PUT",
Headers: map[string]string{"Content-Type": "text/plain"},
Body: []byte("weekly digest for user 42"), // the SDK base64-encodes it
ScheduleTime: &at,
DispatchDeadlineSeconds: pushq.Float64(120),
Retry: &pushq.Retry{MaxAttempts: pushq.Int(3)},
})
```
**Java**
```java
Task task = pq.createTask("emails", TaskCreate.builder()
.url("https://api.example.com/hooks/digest")
.method("PUT")
.header("Content-Type", "text/plain")
.body("weekly digest for user 42".getBytes(StandardCharsets.UTF_8)) // the SDK base64-encodes it
.scheduleTime(Instant.parse("2026-12-01T09:00:00Z"))
.dispatchDeadlineSeconds(120)
.retry(RetryConfig.builder().maxAttempts(3).build())
.build());
```
**.NET**
```csharp
PushqTask task = await pq.CreateTaskAsync("emails", new TaskCreate
{
Url = "https://api.example.com/hooks/digest",
Method = "PUT",
Headers = new Dictionary { ["Content-Type"] = "text/plain" },
Body = Encoding.UTF8.GetBytes("weekly digest for user 42"), // the SDK base64-encodes it
ScheduleTime = new DateTimeOffset(2026, 12, 1, 9, 0, 0, TimeSpan.Zero),
DispatchDeadline = TimeSpan.FromSeconds(120),
Retry = new RetryConfig { MaxAttempts = 3 },
});
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails/tasks \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.example.com/hooks/digest",
"method": "PUT",
"headers": { "Content-Type": "text/plain" },
"body_base64": "d2Vla2x5IGRpZ2VzdCBmb3IgdXNlciA0Mg==",
"schedule_time": "2026-12-01T09:00:00Z",
"dispatch_deadline_seconds": 120,
"retry": { "max_attempts": 3 }
}'
```
The SDKs take the raw body and do the base64 encoding for you. In .NET, `delay_seconds` and `dispatch_deadline_seconds` are `TimeSpan` properties named `Delay` and `DispatchDeadline`, and the task type is `PushqTask` (to avoid clashing with `System.Threading.Tasks.Task`). In Python, a naive `datetime` for `schedule_time` is treated as UTC. Some SDKs catch conflicting fields before sending: the Java builder rejects `url` with `path`, a body with `json_body`, and `schedule_time` with `delay_seconds`; .NET rejects the last two; TypeScript and Python reject a body with `json_body`. Everything else is validated by the server.
**Response**
`201 Created` with the [task object](#the-task-object). The create response always includes `headers` and `body_base64` when set:
```json
{
"id": "0193b6f2-7c1e-7a3d-9f4e-2b8c5d1a6e90",
"queue": "emails",
"state": "pending",
"url": "https://api.example.com/hooks/digest",
"method": "PUT",
"headers": { "Content-Type": "text/plain" },
"body_base64": "d2Vla2x5IGRpZ2VzdCBmb3IgdXNlciA0Mg==",
"schedule_time": "2026-12-01T09:00:00Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 120,
"retry": { "max_attempts": 3 },
"dispatch_count": 0,
"response_count": 0
}
```
Field descriptions are in [the task object](#the-task-object).
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON; bad `task_id`; both or neither of `url`/`path`; invalid URL; `path` not starting with `/`; method not allowed; invalid or reserved header; headers or body too large; invalid base64; body with a method that doesn't allow one; both `schedule_time` and `delay_seconds`; schedule too far ahead; `dispatch_deadline_seconds` outside 15–1800; invalid `retry` values. |
| 400 | `failed_precondition` | The task uses `path` but the queue has no `target.base_url`, or the queue is `disabled`. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | The queue doesn't exist. |
| 409 | `already_exists` | A task with this `task_id` is already stored in the queue. |
| 413 | `payload_too_large` | The request body is over the size limit. |
See [API error codes](https://pushqueue.dev/docs/reference/errors/) for the error format.
## Enqueue tasks in bulk (batch)
`POST /v1/queues/{queue}/tasks:batch`
Creates up to 500 tasks in one request. Use it for fan-out (one task per user, per row, per webhook subscriber) to cut round trips. The batch is **not atomic**: each item succeeds or fails on its own, and the response lists a result per item in request order. A duplicate `task_id`, including one repeated inside the same batch, fails only that item with `already_exists`. See [bulk enqueue](https://pushqueue.dev/docs/patterns/bulk-enqueue/).
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). The queue must exist. |
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `tasks` | array | yes | — | 1–500 task definitions. |
| `tasks[].*` | object | — | — | Each item takes exactly the fields of [Enqueue a task](#enqueue-a-task): `task_id`, `url`, `path`, `method`, `headers`, `json_body`, `body_base64`, `schedule_time`, `delay_seconds`, `dispatch_deadline_seconds`, `retry.*`. |
The whole request may be at most 8 MiB.
**Example**
**TypeScript**
```ts
const results = await pq.createTasks("emails", [
{ taskId: "welcome-user-42", path: "/hooks/send-welcome", jsonBody: { user_id: 42 } },
{ taskId: "welcome-user-43", path: "/hooks/send-welcome", jsonBody: { user_id: 43 } },
]);
for (const r of results) {
if (r.error) console.warn(`#${r.index}: ${r.error.code} ${r.error.detail}`);
else console.log(`#${r.index}: created ${r.task!.id}`);
}
```
**Python**
```python
results = pq.create_tasks("emails", [
{"task_id": "welcome-user-42", "path": "/hooks/send-welcome", "json_body": {"user_id": 42}},
{"task_id": "welcome-user-43", "path": "/hooks/send-welcome", "json_body": {"user_id": 43}},
])
for r in results:
if r.error:
print(r.index, r.error.code, r.error.detail)
else:
print(r.index, r.task.id)
```
**Go**
```go
results, err := pq.CreateTasks(ctx, "emails", []pushq.TaskCreate{
{TaskID: "welcome-user-42", Path: "/hooks/send-welcome", JSONBody: map[string]any{"user_id": 42}},
{TaskID: "welcome-user-43", Path: "/hooks/send-welcome", JSONBody: map[string]any{"user_id": 43}},
})
if err != nil {
return err // the whole request failed
}
for _, r := range results {
if r.Error != nil {
log.Printf("item %d: %s: %s", r.Index, r.Error.Code, r.Error.Detail)
continue
}
fmt.Println("created", r.Task.ID)
}
```
**Java**
```java
List results = pq.createTasks("emails", List.of(
TaskCreate.builder().taskId("welcome-user-42").path("/hooks/send-welcome")
.jsonBody(Map.of("user_id", 42)).build(),
TaskCreate.builder().taskId("welcome-user-43").path("/hooks/send-welcome")
.jsonBody(Map.of("user_id", 43)).build()));
for (BatchResult r : results) {
if (r.isSuccess()) {
System.out.println(r.getIndex() + " -> " + r.getTask().getId());
} else {
System.err.println(r.getIndex() + " failed: " + r.getError().getCode() + " " + r.getError().getDetail());
}
}
```
**.NET**
```csharp
IReadOnlyList results = await pq.CreateTasksAsync("emails", new[]
{
new TaskCreate { TaskId = "welcome-user-42", Path = "/hooks/send-welcome", JsonBody = new { user_id = 42 } },
new TaskCreate { TaskId = "welcome-user-43", Path = "/hooks/send-welcome", JsonBody = new { user_id = 43 } },
});
foreach (var r in results)
{
if (r.Error != null) Console.WriteLine($"#{r.Index} failed: {r.Error.Code} {r.Error.Detail}");
else Console.WriteLine($"#{r.Index} -> {r.Task!.Id}");
}
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails/tasks:batch \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tasks": [
{ "task_id": "welcome-user-42", "path": "/hooks/send-welcome", "json_body": { "user_id": 42 } },
{ "task_id": "welcome-user-43", "path": "/hooks/send-welcome", "json_body": { "user_id": 43 } }
]
}'
```
The SDK method is `createTasks` / `create_tasks` / `CreateTasks` / `CreateTasksAsync` and returns the `results` array directly. In Python each item is a dict using `create_task`'s keyword names; unknown keys are silently ignored.
**Response**
`200 OK`, even when some items failed:
```json
{
"results": [
{
"index": 0,
"task": {
"id": "welcome-user-42",
"queue": "emails",
"state": "pending",
"url": "/hooks/send-welcome",
"method": "POST",
"headers": { "Content-Type": "application/json" },
"body_base64": "eyJ1c2VyX2lkIjo0Mn0=",
"schedule_time": "2026-11-28T10:15:00.12Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 600,
"dispatch_count": 0,
"response_count": 0
}
},
{
"index": 1,
"error": { "code": "already_exists", "detail": "already exists" }
}
]
}
```
| Field | Type | Description |
|---|---|---|
| `results` | array | One entry per input task, in request order. |
| `results[].index` | integer | Position of the task in the request (0-based). |
| `results[].task` | [task object](#the-task-object) | The created task. Present only on success. |
| `results[].error.code` | string | Present only on failure: `invalid_argument`, `already_exists`, `not_found`, `failed_precondition` or `internal`. |
| `results[].error.detail` | string | Human-readable reason for the failure. |
**Errors**
These fail the whole request; per-item failures are reported in `results` instead.
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, `tasks` empty, or more than 500 tasks. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | The queue doesn't exist. |
| 413 | `payload_too_large` | Request body over 8 MiB. |
## List tasks
`GET /v1/queues/{queue}/tasks`
Lists a queue's tasks, newest first, one page at a time. Filter by `state` to find failed tasks to inspect or retry, or by `id_prefix` to find a group of related tasks (for example everything for one user if your IDs start with the user ID). Deleted and purged tasks are not listed; finished tasks are listed until retention cleanup removes them.
**Who can call it:** writer or admin API key; dashboard viewer, member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
**Query parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `state` | string | no | all | `pending`, `running`, `succeeded` or `failed`. |
| `id_prefix` | string | no | none | Only tasks whose ID starts with this. |
| `view` | string | no | `basic` | `basic` omits `headers` and `body_base64`; `full` includes them. |
| `page_size` | integer | no | `100` | Tasks per page. Values above 1000 are capped at 1000; 0 or less means 100. |
| `page_token` | string | no | none | `next_page_token` from the previous response. |
**Example**
**TypeScript**
```ts
const page = await pq.listTasks("emails", { state: "failed", idPrefix: "welcome-", pageSize: 50 });
for (const t of page.items) console.log(t.id, t.lastAttempt?.status, t.lastAttempt?.error);
// page.nextPageToken -> pass as pageToken for the next page
```
**Python**
```python
page = pq.list_tasks("emails", state="failed", id_prefix="welcome-", page_size=50)
for t in page.items:
print(t.id, t.last_attempt.status if t.last_attempt else None)
# page.next_page_token -> pass as page_token for the next page
```
**Go**
```go
tasks, next, err := pq.ListTasks(ctx, "emails", pushq.ListTasksParams{
State: "failed",
IDPrefix: "welcome-",
PageSize: 50,
})
// pass next as PageToken for the next page ("" on the last page)
```
**Java**
```java
TaskPage page = pq.listTasks("emails", ListTasksParams.builder()
.state("failed")
.idPrefix("welcome-")
.pageSize(50)
.build());
page.getTasks().forEach(t -> System.out.println(t.getId() + " " + t.getState()));
// page.getNextPageToken() -> pageToken(...) for the next page
```
**.NET**
```csharp
Page page = await pq.ListTasksAsync("emails", new ListTasksOptions
{
State = TaskState.Failed,
IdPrefix = "welcome-",
PageSize = 50,
});
// page.NextPageToken -> ListTasksOptions.PageToken for the next page
```
**curl**
```bash
curl "https://api.pushqueue.dev/v1/queues/emails/tasks?state=failed&id_prefix=welcome-&page_size=50" \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"tasks": [
{
"id": "welcome-user-43",
"queue": "emails",
"state": "failed",
"url": "/hooks/send-welcome",
"method": "POST",
"schedule_time": "2026-11-28T10:42:51.004Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 600,
"retry": { "max_attempts": 3 },
"dispatch_count": 3,
"response_count": 3,
"first_attempt_at": "2026-11-28T10:15:00.31Z",
"finished_at": "2026-11-28T10:42:51.88Z",
"last_attempt": {
"at": "2026-11-28T10:42:51.004Z",
"status": 500,
"error": "non_2xx: template not found"
}
}
],
"next_page_token": "MTI4Nzc"
}
```
| Field | Type | Description |
|---|---|---|
| `tasks` | array of [task objects](#the-task-object) | This page, newest first. Empty array when nothing matches. |
| `next_page_token` | string | Pass as `page_token` to get the next page. Omitted on the last page. |
The SDKs return a page object: `items` / `nextPageToken` in TypeScript, `items` / `next_page_token` in Python, `getTasks()` / `getNextPageToken()` in Java, `Items` / `NextPageToken` in .NET; Go returns the slice and the next token separately.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Unknown `state`, or `page_size` not an integer. |
| 400 | `failed_precondition` | `page_token` is malformed. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission. |
| 404 | `not_found` | The queue doesn't exist. |
## Get a task
`GET /v1/queues/{queue}/tasks/{taskID}`
Returns one task's current state, schedule and last attempt. Use it to check whether a specific job ran, or (with `view=full`) to see exactly what will be sent. Deleted and purged tasks return `404`.
**Who can call it:** writer or admin API key; dashboard viewer, member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
| `taskID` | string | yes | — | The task's ID. |
**Query parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `view` | string | no | `basic` | `basic` omits `headers` and `body_base64`; `full` includes them. |
**Example**
**TypeScript**
```ts
const task = await pq.getTask("emails", "welcome-user-42");
const full = await pq.getTask("emails", "welcome-user-42", { view: "full" });
const body = full.body ? new TextDecoder().decode(full.body) : undefined; // Uint8Array
```
**Python**
```python
task = pq.get_task("emails", "welcome-user-42")
full = pq.get_task("emails", "welcome-user-42", view="full")
print(full.headers, full.body) # body is decoded bytes
```
**Go**
```go
task, err := pq.GetTask(ctx, "emails", "welcome-user-42")
full, err := pq.GetTaskFull(ctx, "emails", "welcome-user-42") // includes headers + body
body, _ := base64.StdEncoding.DecodeString(full.BodyBase64)
```
**Java**
```java
Task task = pq.getTask("emails", "welcome-user-42");
Task full = pq.getTaskFull("emails", "welcome-user-42"); // includes headers + body
byte[] body = full.getBodyBase64() == null
? new byte[0]
: Base64.getDecoder().decode(full.getBodyBase64());
```
**.NET**
```csharp
PushqTask task = await pq.GetTaskAsync("emails", "welcome-user-42");
PushqTask full = await pq.GetTaskAsync("emails", "welcome-user-42", TaskView.Full);
string? bodyText = full.Body == null ? null : Encoding.UTF8.GetString(full.Body);
```
**curl**
```bash
curl "https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42?view=full" \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
Go and Java get the full view from a separate method (`GetTaskFull`, `getTaskFull`) and return the body as the base64 string; TypeScript, Python and .NET decode it into bytes for you.
**Response**
`200 OK` with the [task object](#the-task-object) (here with `view=full`):
```json
{
"id": "welcome-user-42",
"queue": "emails",
"state": "succeeded",
"url": "/hooks/send-welcome",
"method": "POST",
"headers": { "Content-Type": "application/json" },
"body_base64": "eyJ1c2VyX2lkIjo0Mn0=",
"schedule_time": "2026-11-28T11:15:00.12Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 600,
"dispatch_count": 1,
"response_count": 1,
"first_attempt_at": "2026-11-28T11:15:00.304Z",
"finished_at": "2026-11-28T11:15:00.511Z",
"last_attempt": { "at": "2026-11-28T11:15:00.304Z", "status": 200 }
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission. |
| 404 | `not_found` | No such task (or it was deleted or purged), or no such queue. |
## Delete a task
`DELETE /v1/queues/{queue}/tasks/{taskID}`
Cancels a task. A pending task will never be sent; if it is being delivered right now, the delivery's result is discarded. You can also delete finished tasks. Use it to cancel scheduled work that is no longer needed, such as a reminder for an order that was already paid. The task ID stays reserved for the dedup window (1 hour by default on self-hosted servers), so re-enqueueing the same ID right away fails with `already_exists`. See [schedule and cancel tasks](https://pushqueue.dev/docs/patterns/scheduling-and-cancelling/).
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
| `taskID` | string | yes | — | The task's ID. |
**Example**
**TypeScript**
```ts
await pq.deleteTask("emails", "welcome-user-42");
```
**Python**
```python
pq.delete_task("emails", "welcome-user-42")
```
**Go**
```go
err := pq.DeleteTask(ctx, "emails", "welcome-user-42")
```
**Java**
```java
pq.deleteTask("emails", "welcome-user-42");
```
**.NET**
```csharp
await pq.DeleteTaskAsync("emails", "welcome-user-42");
```
**curl**
```bash
curl -X DELETE https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42 \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No such task (or already deleted or purged), or no such queue. |
## Run a task now
`POST /v1/queues/{queue}/tasks/{taskID}:run`
Dispatches a pending task immediately: its `schedule_time` is set to now and it is sent right away, ignoring the queue's rate limits and its paused state. Use it to test a delivery, to skip the wait on a delayed or backing-off task, or to push one urgent task through a paused queue. Only `pending` tasks can be run.
**Who can call it:** writer or admin API key; dashboard member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
| `taskID` | string | yes | — | The task's ID. |
No request body.
**Example**
**TypeScript**
```ts
const task = await pq.runTask("emails", "welcome-user-42");
```
**Python**
```python
task = pq.run_task("emails", "welcome-user-42")
```
**Go**
```go
task, err := pq.RunTask(ctx, "emails", "welcome-user-42")
```
**Java**
```java
Task task = pq.runTask("emails", "welcome-user-42");
```
**.NET**
```csharp
PushqTask task = await pq.RunTaskAsync("emails", "welcome-user-42");
```
**curl**
```bash
curl -X POST https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42:run \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK` with the [task object](#the-task-object) in the full view, still `pending` with `schedule_time` set to now (the dispatch happens right after the response):
```json
{
"id": "welcome-user-42",
"queue": "emails",
"state": "pending",
"url": "/hooks/send-welcome",
"method": "POST",
"headers": { "Content-Type": "application/json" },
"body_base64": "eyJ1c2VyX2lkIjo0Mn0=",
"schedule_time": "2026-11-28T10:20:31.007Z",
"created_at": "2026-11-28T10:15:00.12Z",
"dispatch_deadline_seconds": 600,
"dispatch_count": 0,
"response_count": 0
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `failed_precondition` | The task is being delivered right now, or the queue is `disabled`. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The key or role can't write. |
| 404 | `not_found` | No such task or queue, or the task already succeeded, failed, was deleted or was purged. |
## List a task's delivery attempts
`GET /v1/queues/{queue}/tasks/{taskID}/attempts`
Returns the task's delivery attempts, newest first (up to the 1000 most recent), with the status code, error kind, a snippet of the response body and the duration of each. Use it to debug why a task is failing or retrying. Attempts are kept as long as the task is.
**Who can call it:** writer or admin API key; dashboard viewer, member or admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `queue` | string | yes | — | Queue name, URL-encoded as one segment (`user%2Finstagram`). |
| `taskID` | string | yes | — | The task's ID. |
**Example**
**TypeScript**
```ts
const attempts = await pq.listAttempts("emails", "welcome-user-42");
for (const a of attempts) console.log(a.number, a.responseStatus ?? a.errorKind, a.durationMs);
```
**Python**
```python
for a in pq.list_attempts("emails", "welcome-user-42"):
print(a.number, a.response_status, a.error_kind, a.duration_ms)
```
**Go**
```go
attempts, err := pq.ListAttempts(ctx, "emails", "welcome-user-42")
for _, a := range attempts {
fmt.Println(a.Number, a.ResponseStatus, a.ErrorKind, a.DurationMS)
}
```
**Java**
```java
List attempts = pq.listAttempts("emails", "welcome-user-42");
for (Attempt a : attempts) {
System.out.printf("#%d status=%s kind=%s %dms%n",
a.getNumber(), a.getResponseStatus(), a.getErrorKind(), a.getDurationMs());
}
```
**.NET**
```csharp
IReadOnlyList attempts = await pq.ListAttemptsAsync("emails", "welcome-user-42");
foreach (var a in attempts)
Console.WriteLine($"#{a.Number} {a.ResponseStatus?.ToString() ?? a.ErrorKind} {a.DurationMs}ms");
```
**curl**
```bash
curl https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42/attempts \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
The SDKs return the list of attempts directly (no page object).
**Response**
`200 OK`:
```json
{
"attempts": [
{
"number": 2,
"dispatch_time": "2026-11-28T11:15:02.41Z",
"response_time": "2026-11-28T11:15:02.598Z",
"response_status": 200,
"duration_ms": 188
},
{
"number": 1,
"dispatch_time": "2026-11-28T11:15:00.304Z",
"response_time": "2026-11-28T11:15:00.511Z",
"response_status": 503,
"error_kind": "non_2xx",
"error_snippet": "upstream unavailable",
"duration_ms": 207
}
]
}
```
| Field | Type | Description |
|---|---|---|
| `attempts` | array | Attempts, newest first. Empty array before the first attempt. |
| `attempts[].number` | integer | Attempt number, starting at 1. |
| `attempts[].dispatch_time` | string (RFC 3339) | When the request was sent. |
| `attempts[].response_time` | string (RFC 3339) | When the response arrived. Omitted when there was no response. |
| `attempts[].response_status` | integer | HTTP status code. Omitted when there was no response. |
| `attempts[].error_kind` | string | Why the attempt failed: `non_2xx`, `timeout`, `connect`, `dns`, `tls`, `config` (the request couldn't be built, e.g. relative path with no `target.base_url`) or `lease_lost` (the worker stopped mid-delivery). Omitted on success. |
| `attempts[].error_snippet` | string | Up to 4 KiB of the response body for `non_2xx`, or the error message otherwise. Omitted when empty. |
| `attempts[].duration_ms` | integer | How long the attempt took, in milliseconds. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission. |
| 404 | `not_found` | No such task (or it was deleted or purged), or no such queue. |
## Read more
- [How tasks work](https://pushqueue.dev/docs/concepts/tasks/): states, scheduling and task IDs.
- [Delivery and request headers](https://pushqueue.dev/docs/concepts/delivery/): what your endpoint receives and how to respond.
- [Deduplicate tasks with task IDs](https://pushqueue.dev/docs/patterns/deduplication/): use `task_id` as an idempotency key.
- [Queues API reference](https://pushqueue.dev/docs/reference/rest/queues/): create and configure the queues tasks go into.
- [API error codes](https://pushqueue.dev/docs/reference/errors/): every `code` and what to do about it.
---
# API keys API reference
> pushq API keys API reference: list, create and revoke writer and admin API keys with /v1/api-keys, including key roles, request examples and error codes.
Source: https://pushqueue.dev/docs/reference/rest/api-keys/
The API keys API (`/v1/api-keys`) lists, creates and revokes pushq API keys. API keys authenticate programs that call pushq: your app server, a worker, a deploy script. Each key has a role, `writer` or `admin`, which decides what it can do. These endpoints manage keys created in the dashboard (or through this API). Most people create keys in the dashboard under **Settings → API keys**; use these endpoints when you want to automate key rotation or provisioning. See the [guide to creating and rotating API keys](https://pushqueue.dev/docs/guides/api-keys/) for the bigger picture.
The SDKs don't wrap these endpoints; call them over HTTP. All examples use the hosted API at `https://api.pushqueue.dev`.
## API key roles: writer and admin
| Capability | `writer` | `admin` |
|---|---|---|
| Create, upsert, patch, pause, resume and purge queues it knows by name | yes | yes |
| Read a queue, its stats, tasks and attempts | yes | yes |
| Enqueue, run and delete tasks | yes | yes |
| `GET /v1/version` | yes | yes |
| List queues (`GET /v1/queues`) | no | yes |
| Delete queues | no | yes |
| Manage API keys, team members and invites | no | yes |
Give services a `writer` key unless they really need to list or delete queues.
Keys look like `pq_` followed by 32 URL-safe characters. pushq stores only a SHA-256 hash, so the full key is shown once, when it is created. On the hosted service a key belongs to the team that was active when it was created and only sees that team's queues. Self-hosted servers can also define keys in the server config file; those are not listed or revocable here (see [server configuration](https://pushqueue.dev/docs/self-hosting/configuration/)).
## Who can manage API keys
All three endpoints need the **manage** permission: an `admin` API key, or a dashboard user with the `admin` role. A writer key or a member/viewer gets `403 permission_denied`. On a self-hosted server without dashboard accounts enabled they return `404 not_found`.
## The API key object
```json
{
"id": 17,
"name": "billing-service",
"prefix": "pq_x7Kp2Qa9",
"role": "writer",
"created_by": "ana@example.com",
"created_at": "2026-11-28T10:15:00.12Z",
"last_used_at": "2026-11-28T11:02:44Z"
}
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | Key ID; use it to revoke the key. |
| `name` | string | Label for what uses the key. |
| `prefix` | string | First 11 characters of the key (`pq_` plus 8), so you can recognise it. |
| `role` | string | `writer` or `admin`. |
| `created_by` | string | Email of the dashboard user who created it. Omitted when an API key created it. |
| `created_at` | string (RFC 3339) | When the key was created. |
| `last_used_at` | string (RFC 3339) | When the key last authenticated a request. Updated at most once a minute. Omitted if never used. |
## List API keys
`GET /v1/api-keys`
Returns the dashboard-managed keys, newest first. On the hosted service you see only the current team's keys. Use it to audit which keys exist and spot ones that haven't been used in a long time.
**Who can call it:** admin API key; dashboard admin.
No parameters.
**Example**
```bash
curl https://api.pushqueue.dev/v1/api-keys \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"keys": [
{
"id": 17,
"name": "billing-service",
"prefix": "pq_x7Kp2Qa9",
"role": "writer",
"created_by": "ana@example.com",
"created_at": "2026-11-28T10:15:00.12Z",
"last_used_at": "2026-11-28T11:02:44Z"
},
{
"id": 12,
"name": "deploy-pipeline",
"prefix": "pq_Lm3vT0cE",
"role": "admin",
"created_at": "2026-10-02T08:00:00Z"
}
],
"config_keys": 0
}
```
| Field | Type | Description |
|---|---|---|
| `keys` | array of [API key objects](#the-api-key-object) | Dashboard-managed keys, newest first. |
| `config_keys` | integer | How many additional keys the server config file defines (self-hosted). Always `0` on the hosted service. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin key or admin user. |
| 404 | `not_found` | Dashboard accounts are not enabled on this server. |
See [API error codes](https://pushqueue.dev/docs/reference/errors/) for the error format.
## Create an API key
`POST /v1/api-keys`
Creates a key and returns it once, in `secret`. Store it in your secret manager straight away; it can't be retrieved later. Use this to provision a key per service, or to rotate a key: create the new one, deploy it, then [revoke](#revoke-an-api-key) the old one.
**Who can call it:** admin API key; dashboard admin.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | yes | — | What uses the key, e.g. `billing-service`. 1–100 characters after trimming spaces. |
| `role` | string | yes | — | `writer` or `admin`. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/api-keys \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "billing-service", "role": "writer" }'
```
**Response**
`201 Created`:
```json
{
"key": {
"id": 18,
"name": "billing-service",
"prefix": "pq_9bQe4Rz1",
"role": "writer",
"created_at": "2026-11-28T12:00:00Z"
},
"secret": "pq_9bQe4Rz1Hk2mVxN7cTqL0aYwPf3sUe8D"
}
```
| Field | Type | Description |
|---|---|---|
| `key` | [API key object](#the-api-key-object) | The new key's metadata. `created_by` is set when a dashboard user created it. |
| `secret` | string | The API key itself. Shown only in this response. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, `name` empty or longer than 100 characters, or `role` not `writer`/`admin`. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin key or admin user. |
| 404 | `not_found` | Dashboard accounts are not enabled on this server. |
| 413 | `payload_too_large` | Body over 16 KiB. |
## Revoke an API key
`DELETE /v1/api-keys/{id}`
Deletes a key. Requests that use it fail with `401 unauthenticated` from the next request on. Use it when a key leaks, when a service is retired, or as the last step of a rotation. On the hosted service you can only revoke keys that belong to your current team.
**Who can call it:** admin API key; dashboard admin. An admin key can revoke itself.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | The key's `id` from the list or create response. |
**Example**
```bash
curl -X DELETE https://api.pushqueue.dev/v1/api-keys/17 \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `id` is not a positive integer. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin key or admin user. |
| 404 | `not_found` | No such key in your team, or dashboard accounts are not enabled. |
## Read more
- [Create and rotate API keys](https://pushqueue.dev/docs/guides/api-keys/): the dashboard flow and rotation checklist.
- [Teams & users API reference](https://pushqueue.dev/docs/reference/rest/teams-and-users/): roles for people instead of programs.
- [REST API overview](https://pushqueue.dev/docs/reference/api/): authentication, request format and conventions.
- [API error codes](https://pushqueue.dev/docs/reference/errors/): `unauthenticated`, `permission_denied` and the rest.
---
# Teams and users API reference
> pushq Teams & users API reference: manage your profile, password, teams, team members and roles, password-reset links and invites, hosted or self-hosted.
Source: https://pushqueue.dev/docs/reference/rest/teams-and-users/
The teams and users API manages people rather than queues: your own profile (`/v1/me`), the teams you belong to (`/v1/teams`), the members of a team (`/v1/users`) and pending invitations (`/v1/invites`). The dashboard uses all of them; you only need them directly if you are automating member management. For a walkthrough, see [managing team members](https://pushqueue.dev/docs/guides/team-members/).
The SDKs don't wrap these endpoints; call them over HTTP. Examples use the hosted API at `https://api.pushqueue.dev`.
## Self-hosted vs hosted accounts
pushq runs in one of two account modes, and some endpoints behave differently or exist in only one of them:
- **Self-hosted** (no WorkOS configured): the server has one set of users with email/password sign-in. `/v1/users` lists every account on the server. Invites are single-use links you send yourself.
- **Hosted / SaaS mode** (WorkOS configured, as on `api.pushqueue.dev`): people sign in with an emailed code or GitHub, and belong to one or more **teams**. Every request acts inside the session's current team; `/v1/users` lists that team's members, and WorkOS emails the invitations.
Endpoints marked *self-hosted only* return `404 not_found` in SaaS mode, and endpoints marked *SaaS only* return `404 not_found` on a self-hosted server. All of them return `404 not_found` when dashboard accounts are disabled on a self-hosted server.
## Who can call the account endpoints
| Endpoints | Who can call |
|---|---|
| `/v1/me`, `/v1/me/password`, `GET`/`POST /v1/teams`, `POST /v1/teams/{id}:switch` | A signed-in dashboard user only (session cookie). API keys get `401 unauthenticated`. |
| `PATCH /v1/teams/current`, `/v1/users*`, `/v1/invites*` | The **manage** permission: an `admin` API key or a dashboard `admin`. Others get `403 permission_denied`. |
Session requests send the `pushq_session` cookie that [sign-in](https://pushqueue.dev/docs/reference/rest/auth/) sets. Any session request that changes something (`POST`, `PATCH`, `DELETE`) must also send an `X-Requested-With` header with any non-empty value, or it fails with `403 permission_denied`; this blocks cross-site request forgery. Requests with an `Authorization` header don't need it. The session examples below use `$PUSHQ_SESSION` for the cookie value.
## Dashboard roles: viewer, member and admin
| Role | Can do |
|---|---|
| `viewer` | See queues, stats, tasks and attempts, list queues. |
| `member` | Everything a viewer can, plus create, change, pause, purge and delete queues and enqueue, run and delete tasks. |
| `admin` | Everything a member can, plus manage members, invites and API keys. |
## The user object
```json
{
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
}
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | User ID; use it in `/v1/users/{id}`. |
| `email` | string | Email address (lowercase). |
| `name` | string | Display name; may be empty. |
| `role` | string | `admin`, `member` or `viewer`. In SaaS mode, the role in the current team. |
| `created_at` | string (RFC 3339) | When the account was created. |
| `last_login_at` | string (RFC 3339) | Last sign-in. Omitted if the user never signed in. |
## The invite object
```json
{
"id": 9,
"kind": "invite",
"email": "sam@example.com",
"role": "member",
"created_at": "2026-11-28T10:00:00Z",
"expires_at": "2026-12-05T10:00:00Z"
}
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | Invite ID; use it to revoke the invite. |
| `kind` | string | `invite` (a new member) or `reset` (a password-reset link). |
| `email` | string | Who it is for. |
| `role` | string | Role the new member gets. Omitted for `reset` links. |
| `created_at` | string (RFC 3339) | When it was created. |
| `expires_at` | string (RFC 3339) | When it stops working. |
## Change your name
`PATCH /v1/me`
Updates the signed-in user's display name. The dashboard's profile page uses it.
**Who can call it:** a signed-in dashboard user (session only).
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | no | unchanged | New display name, at most 100 characters after trimming spaces. Omit to leave it as is. |
**Example**
```bash
curl -X PATCH https://api.pushqueue.dev/v1/me \
--cookie "pushq_session=$PUSHQ_SESSION" \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "name": "Ana Lima" }'
```
**Response**
`200 OK` with the updated [user object](#the-user-object):
```json
{
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON or a name longer than 100 characters. |
| 401 | `unauthenticated` | No session (API keys can't call this). |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
See [API error codes](https://pushqueue.dev/docs/reference/errors/) for the error format.
## Change your password
`POST /v1/me/password`
Sets a new password for the signed-in user after checking the current one, and signs them out on every other device (the current session stays valid). *Self-hosted only*: in SaaS mode there are no passwords.
**Who can call it:** a signed-in dashboard user (session only). Rate-limited per client IP (10 attempts, then one every 6 seconds).
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `current_password` | string | yes | — | The user's current password. |
| `new_password` | string | yes | — | At least 8 characters and at most 256 bytes. |
**Example**
```bash
curl -X POST https://pushq.example.com/v1/me/password \
--cookie "pushq_session=$PUSHQ_SESSION" \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "current_password": "old-password", "new_password": "a-much-longer-passphrase" }'
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Current password wrong, or the new one too short or too long. |
| 401 | `unauthenticated` | No session. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | SaaS mode. |
| 429 | `rate_limited` | Too many attempts; retry after the `Retry-After` seconds. |
## List your teams
`GET /v1/teams`
Lists the teams the signed-in user belongs to, with their role in each, oldest membership first. The dashboard's team switcher uses it. *SaaS only.*
**Who can call it:** a signed-in dashboard user (session only).
**Example**
```bash
curl https://api.pushqueue.dev/v1/teams \
--cookie "pushq_session=$PUSHQ_SESSION"
```
**Response**
`200 OK`:
```json
{
"teams": [
{ "id": 4, "name": "Acme", "role": "admin" },
{ "id": 11, "name": "Side project", "role": "viewer" }
]
}
```
| Field | Type | Description |
|---|---|---|
| `teams[].id` | integer | Team ID. |
| `teams[].name` | string | Team name. |
| `teams[].role` | string | Your role in that team: `admin`, `member` or `viewer`. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No session. |
| 404 | `not_found` | Not in SaaS mode. |
## Create a team
`POST /v1/teams`
Creates a new team with the caller as its admin and switches the caller's session to it. Use it to separate environments or projects: each team has its own queues, API keys and members. *SaaS only.* Behind the scenes this creates a WorkOS Organization.
**Who can call it:** a signed-in dashboard user (session only).
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | yes | — | Team name, 1–100 characters. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/teams \
--cookie "pushq_session=$PUSHQ_SESSION" \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "name": "Acme staging" }'
```
**Response**
`201 Created`:
```json
{ "id": 15, "name": "Acme staging", "role": "admin" }
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | New team ID. |
| `name` | string | Team name. |
| `role` | string | Always `admin` for the creator. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Name empty or longer than 100 characters, or the account isn't linked to WorkOS. |
| 400 | `failed_precondition` | WorkOS rejected the request; `detail` explains why. |
| 401 | `unauthenticated` | No session. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | Not in SaaS mode. |
| 502 | `internal` | WorkOS is unavailable; try again. |
## Switch teams
`POST /v1/teams/{id}:switch`
Makes another of your teams the current team for this session. Every later request on the session (queues, keys, members) acts in that team, and it becomes the team you start in next time you sign in. *SaaS only.*
**Who can call it:** a signed-in dashboard user (session only) who is a member of the target team.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | ID of a team you belong to. |
No request body.
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/teams/11:switch \
--cookie "pushq_session=$PUSHQ_SESSION" \
-H "X-Requested-With: pushq"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `id` is not an integer. |
| 401 | `unauthenticated` | No session. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | You aren't a member of that team, or not in SaaS mode. |
## Rename the current team
`PATCH /v1/teams/current`
Renames the team the caller is acting in (the session's current team, or the team an API key belongs to). The new name is also pushed to WorkOS. *SaaS only.*
**Who can call it:** an `admin` API key of the team, or a dashboard admin of the team.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | yes | — | New team name, 1–100 characters after trimming spaces. |
**Example**
```bash
curl -X PATCH https://api.pushqueue.dev/v1/teams/current \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Acme production" }'
```
**Response**
`200 OK`:
```json
{ "id": 4, "name": "Acme production", "role": "admin" }
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | Team ID. |
| `name` | string | The new name. |
| `role` | string | The caller's role (for an API key, the key's role). |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Name empty or longer than 100 characters. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin of the team. |
| 404 | `not_found` | Not in SaaS mode. |
## List members
`GET /v1/users`
Self-hosted: lists every account on the server. SaaS mode: lists the current team's members, re-synced from WorkOS first (so people who accepted an invite show up), with `role` set to their role in the team. Both are ordered by email. Use it to audit who has access.
**Who can call it:** admin API key; dashboard admin.
**Example**
```bash
curl https://api.pushqueue.dev/v1/users \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"users": [
{
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
},
{
"id": 8,
"email": "sam@example.com",
"name": "",
"role": "viewer",
"created_at": "2026-11-20T16:40:00Z"
}
]
}
```
| Field | Type | Description |
|---|---|---|
| `users` | array of [user objects](#the-user-object) | The members. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | Dashboard accounts are not enabled. |
## Change a member
`PATCH /v1/users/{id}`
Changes a member's role (and, on a self-hosted server, their name). Use it to promote someone to admin or reduce someone to read-only. The last admin can't be demoted, so a team always keeps at least one admin. In SaaS mode only the role can change; names come from WorkOS.
**Who can call it:** admin API key; dashboard admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | The member's user ID. |
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `role` | string | no (yes in SaaS mode) | unchanged | `admin`, `member` or `viewer`. |
| `name` | string | no | unchanged | Self-hosted only: new display name, at most 100 characters. Ignored in SaaS mode. |
**Example**
```bash
curl -X PATCH https://api.pushqueue.dev/v1/users/8 \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "role": "member" }'
```
**Response**
`200 OK` with the updated [user object](#the-user-object):
```json
{
"id": 8,
"email": "sam@example.com",
"name": "",
"role": "member",
"created_at": "2026-11-20T16:40:00Z"
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid `id` or JSON, unknown role, name too long, or (SaaS mode) no `role` given. |
| 400 | `failed_precondition` | The change would leave the team without an admin. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | No such user, or not a member of the current team. |
## Remove a member
`DELETE /v1/users/{id}`
Removes someone's access immediately. Self-hosted: deletes the account and all its sessions. SaaS mode: removes them from the current team (their sessions in that team lose access at once, and the WorkOS membership is deleted); their account and other teams are untouched. The last admin can't be removed.
**Who can call it:** admin API key; dashboard admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | The member's user ID. |
**Example**
```bash
curl -X DELETE https://api.pushqueue.dev/v1/users/8 \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `id` is not a positive integer. |
| 400 | `failed_precondition` | They are the last admin. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | No such user, or not a member of the current team. |
## Create a password-reset link
`POST /v1/users/{id}/reset-link`
Creates a single-use link that lets a user set a new password, for when someone is locked out. Send them the link; opening it in the dashboard and choosing a password signs them out everywhere else. The link is valid for 24 hours and replaces any earlier reset link for that user. *Self-hosted only.*
**Who can call it:** admin API key; dashboard admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | The user's ID. |
No request body.
**Example**
```bash
curl -X POST https://pushq.example.com/v1/users/8/reset-link \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`201 Created`:
```json
{
"link": {
"id": 21,
"kind": "reset",
"email": "sam@example.com",
"created_at": "2026-11-28T12:30:00Z",
"expires_at": "2026-11-29T12:30:00Z"
},
"path": "/invite#token=pqi_4p0yN8cJ2wqZbX1sRk7mT3vLhD9eF6aGuQ5iW0oYcEs"
}
```
| Field | Type | Description |
|---|---|---|
| `link` | [invite object](#the-invite-object) | The reset link's metadata (`kind` is `reset`, no `role`). |
| `path` | string | The single-use link, relative to your server. Prepend your server's URL before sending it. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `id` is not a positive integer. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | No such user, SaaS mode, or dashboard accounts disabled. |
## List pending invites
`GET /v1/invites`
Lists invitations that haven't been accepted or expired yet. Self-hosted: invite links created with [Invite someone](#invite-someone), newest first. SaaS mode: the current team's pending WorkOS invitations.
**Who can call it:** admin API key; dashboard admin.
**Example**
```bash
curl https://api.pushqueue.dev/v1/invites \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{
"invites": [
{
"id": 9,
"kind": "invite",
"email": "sam@example.com",
"role": "member",
"created_at": "2026-11-28T10:00:00Z",
"expires_at": "2026-12-05T10:00:00Z"
}
]
}
```
| Field | Type | Description |
|---|---|---|
| `invites` | array of [invite objects](#the-invite-object) | Pending invites. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | Dashboard accounts are not enabled. |
| 502 | `internal` | SaaS mode: WorkOS is unavailable. |
## Invite someone
`POST /v1/invites`
Invites a person to join with a given role. Self-hosted: returns a single-use link (valid 7 days) that you send them yourself; opening it lets them pick a name and password. Inviting the same email again replaces the earlier invite. SaaS mode: WorkOS emails the invitation, and the role is applied when they join.
**Who can call it:** admin API key; dashboard admin.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | yes | — | Email address to invite. |
| `role` | string | yes | — | `admin`, `member` or `viewer`. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/invites \
-H "Authorization: Bearer $PUSHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "email": "sam@example.com", "role": "member" }'
```
**Response**
`201 Created`. On a self-hosted server:
```json
{
"invite": {
"id": 9,
"kind": "invite",
"email": "sam@example.com",
"role": "member",
"created_at": "2026-11-28T10:00:00Z",
"expires_at": "2026-12-05T10:00:00Z"
},
"path": "/invite#token=pqi_Zr8wK1nQ3yT0vB6xM2cL9pH4dF7aJ5sE1uG8iO3kYqA"
}
```
In SaaS mode:
```json
{
"invite": {
"id": 9,
"kind": "invite",
"email": "sam@example.com",
"role": "member",
"created_at": "2026-11-28T10:00:00Z",
"expires_at": "2026-12-05T10:00:00Z"
},
"emailed": true
}
```
| Field | Type | Description |
|---|---|---|
| `invite` | [invite object](#the-invite-object) | The new invite. |
| `path` | string | Self-hosted only: the single-use invite link, relative to your server. |
| `emailed` | boolean | SaaS mode only: `true`, WorkOS emailed the invitation. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid email or role. |
| 400 | `failed_precondition` | SaaS mode: WorkOS rejected the invitation; `detail` explains why. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | Dashboard accounts are not enabled. |
| 409 | `already_exists` | Self-hosted: a user with that email already exists. |
| 502 | `internal` | SaaS mode: WorkOS is unavailable. |
## Revoke an invite
`DELETE /v1/invites/{id}`
Cancels a pending invite so its link (or emailed invitation) no longer works.
**Who can call it:** admin API key; dashboard admin.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | integer | yes | — | The invite's `id`. |
**Example**
```bash
curl -X DELETE https://api.pushqueue.dev/v1/invites/9 \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`204 No Content` with an empty body.
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | `id` is not a positive integer. |
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | Not an admin. |
| 404 | `not_found` | No such pending invite. |
| 502 | `internal` | SaaS mode: WorkOS is unavailable. |
## Read more
- [Managing team members](https://pushqueue.dev/docs/guides/team-members/): invite people and choose roles in the dashboard.
- [Auth API reference](https://pushqueue.dev/docs/reference/rest/auth/): sign-in, setup and invite-link endpoints.
- [API keys API reference](https://pushqueue.dev/docs/reference/rest/api-keys/): keys for programs instead of people.
- [Running pushq in SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/): WorkOS teams on your own server.
---
# Auth API reference
> pushq Auth API reference for dashboard sign-in: session info, self-hosted setup, password login and invite links, and hosted email-code and GitHub sign-in.
Source: https://pushqueue.dev/docs/reference/rest/auth/
The Auth API (`/v1/auth/*`) signs people in to the pushq dashboard: it reports the current session, runs first-time setup and password sign-in on self-hosted servers, and handles email-code and GitHub sign-in on the hosted service. They exist mainly for the dashboard's own sign-in pages; programs that call pushq should use an [API key](https://pushqueue.dev/docs/reference/rest/api-keys/) instead of a session. You'd call these directly to build a custom sign-in flow, to script first-time setup of a self-hosted server, or to debug sign-in.
The SDKs don't wrap these endpoints; call them over HTTP.
## Self-hosted vs hosted sign-in endpoints
pushq has two sign-in modes. Endpoints that don't apply to the server's mode return `404 not_found`.
| Endpoint | Self-hosted | Hosted / SaaS mode |
|---|---|---|
| `GET /v1/auth/session` | yes | yes |
| `POST /v1/auth/logout` | yes | yes |
| `POST /v1/auth/setup` | yes | no |
| `POST /v1/auth/login` | yes | no |
| `GET /v1/auth/invites/{token}` | yes | no |
| `POST /v1/auth/invites/{token}:accept` | yes | no |
| `POST /v1/auth/email-code` | no | yes |
| `POST /v1/auth/email-code:verify` | no | yes |
| `GET /v1/auth/email-verification` | yes (always reports nothing pending) | yes |
| `POST /v1/auth/email-verification` | no | yes |
| `GET /v1/auth/workos/login` | no | yes |
| `GET /v1/auth/workos/callback` | no | yes |
*Self-hosted* means email-and-password accounts stored by your server (they also need dashboard accounts enabled; otherwise those endpoints return `404`). *SaaS mode* means WorkOS is configured, as on `https://api.pushqueue.dev`: people sign in with a code sent to their email or with GitHub, and there are no passwords. See [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/) for running it yourself.
## Session cookies, CSRF protection and rate limits
A successful sign-in sets the `pushq_session` cookie: `HttpOnly`, `SameSite=Strict`, `Path=/`, `Secure` when the request came over HTTPS (directly or via `X-Forwarded-Proto: https`). Sessions last 30 days and slide: a session used in its last 15 days is extended to 30 days again and the cookie is re-issued.
Every `POST` to `/v1/auth/*` that doesn't carry an `Authorization` header must send an `X-Requested-With` header with any non-empty value (the dashboard sends `pushq`). Without it the request fails with `403 permission_denied`. Browsers only let same-origin scripts set custom headers, so this blocks cross-site forgery. The examples below send it and keep cookies in a file with `curl -c`/`-b`.
Endpoints that check passwords or codes (`setup`, `login`, invite `:accept`, `email-code`, `email-code:verify`, `POST email-verification`) are rate-limited per client IP: 10 attempts, refilling one every 6 seconds. Over the limit they return `429 rate_limited` with `Retry-After: 6`.
None of these endpoints need credentials.
## The sign-in response
`setup`, `login`, invite `:accept` and `email-code:verify` all answer with the signed-in user:
```json
{
"user": {
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
}
}
```
| Field | Type | Description |
|---|---|---|
| `user.id` | integer | User ID. |
| `user.email` | string | Email address (lowercase). |
| `user.name` | string | Display name; may be empty. |
| `user.role` | string | `admin`, `member` or `viewer`. In SaaS mode this is the stored account role; the team role is in `GET /v1/auth/session`. |
| `user.created_at` | string (RFC 3339) | When the account was created. |
| `user.last_login_at` | string (RFC 3339) | Last sign-in. Omitted if never signed in. |
## Get the current session
`GET /v1/auth/session`
Tells the caller who they are and how this server signs people in. The dashboard calls it on load to decide whether to show first-time setup, the sign-in page, a team picker or the app. It never fails for lack of credentials; it reports `authenticated: false` instead. It also works with an API key, which makes it a handy way to check what a key is allowed to do.
**Who can call it:** anyone. Applies in every mode.
**Example**
```bash
curl https://api.pushqueue.dev/v1/auth/session \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`. For a hosted dashboard user:
```json
{
"mode": "saas",
"setup_required": false,
"setup_requires_key": false,
"authenticated": true,
"kind": "user",
"role": "admin",
"user": {
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
},
"permissions": {
"read": true,
"list": true,
"write": true,
"delete_queue": true,
"manage": true
},
"sso_providers": ["workos"],
"team": { "id": 4, "name": "Acme", "role": "admin" },
"teams": [
{ "id": 4, "name": "Acme", "role": "admin" },
{ "id": 11, "name": "Side project", "role": "viewer" }
],
"needs_team": false
}
```
For a writer API key on a self-hosted server:
```json
{
"mode": "locked",
"setup_required": false,
"setup_requires_key": false,
"authenticated": true,
"kind": "api_key",
"role": "writer",
"key_name": "billing-service",
"permissions": {
"read": true,
"list": false,
"write": true,
"delete_queue": false,
"manage": false
},
"sso_providers": [],
"needs_team": false
}
```
| Field | Type | Description |
|---|---|---|
| `mode` | string | `dev` (authentication disabled), `open` (self-hosted with no API keys and no accounts yet, so no credentials are needed), `locked` (self-hosted, credentials required) or `saas`. |
| `setup_required` | boolean | Self-hosted: no dashboard account exists yet, so the dashboard should offer [first-time setup](#create-the-first-admin-account). Always `false` in SaaS and dev mode. |
| `setup_requires_key` | boolean | Setup is required and the server has config-file API keys, so setup needs one of its admin keys. |
| `authenticated` | boolean | Whether the request carried valid credentials (always `true` in `open` and `dev` mode). |
| `kind` | string | `user` (session cookie), `api_key` or `open`. Omitted when not authenticated. |
| `role` | string | The caller's role: user role, key role, or `admin` when open. In SaaS mode, the role in the current team. Omitted when there is none. |
| `user` | object | The signed-in user ([user fields](#the-sign-in-response)). Omitted for API keys and anonymous callers. |
| `key_name` | string | Name of the API key used (`config file` for keys from the server config). Omitted otherwise. |
| `permissions.read` | boolean | Can view queues, stats, tasks and attempts by name. |
| `permissions.list` | boolean | Can list every queue and read `/metrics`. |
| `permissions.write` | boolean | Can create and change queues and enqueue, run and delete tasks. |
| `permissions.delete_queue` | boolean | Can delete queues. |
| `permissions.manage` | boolean | Can manage members, invites and API keys. |
| `sso_providers` | array of strings | Single sign-on options for the sign-in page: `["workos"]` in SaaS mode, otherwise empty. |
| `team` | object | SaaS mode: the current team (`id`, `name`, `role`). Omitted when there is none. |
| `teams` | array | SaaS mode, signed-in users: every team the user belongs to (`id`, `name`, `role`). Omitted otherwise. |
| `needs_team` | boolean | SaaS mode: the user is signed in but has no current team yet and must create or pick one. Until then they have no queue permissions. |
**Errors**
Only `500 internal` on a server-side failure. See [API error codes](https://pushqueue.dev/docs/reference/errors/).
## Create the first admin account
`POST /v1/auth/setup`
Creates the first dashboard account, as an `admin`, and signs it in. It works only while the server has no accounts at all; after that, add people with [invites](https://pushqueue.dev/docs/reference/rest/teams-and-users/#invite-someone). Creating the first account ends `open` mode: from then on every API request needs a session or an API key. *Self-hosted only.*
If the server's config file defines API keys, the server is already protected, so setup also requires one of those keys with the `admin` role, in `api_key` or in an `Authorization: Bearer` header. This stops anyone who can reach the dashboard from claiming it.
**Who can call it:** anyone (no credentials), subject to the rules above. Rate-limited.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | yes | — | Admin's email address (stored lowercase). |
| `password` | string | yes | — | At least 8 characters and at most 256 bytes. |
| `name` | string | no | `""` | Display name, at most 100 characters. |
| `api_key` | string | only when config-file keys exist | — | An `admin` key from the server config. Can instead be sent as `Authorization: Bearer `. |
**Example**
```bash
curl -X POST https://pushq.example.com/v1/auth/setup \
-c cookies.txt \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "email": "ana@example.com", "name": "Ana Lima", "password": "a-long-passphrase" }'
```
**Response**
`201 Created` with the [sign-in response](#the-sign-in-response) and a `Set-Cookie: pushq_session=...` header.
```json
{
"user": {
"id": 1,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-11-28T12:00:00Z",
"last_login_at": "2026-11-28T12:00:00Z"
}
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON or email, password too short or long, name too long. |
| 400 | `failed_precondition` | Setup is already done (an account exists). |
| 403 | `permission_denied` | Config-file keys exist and no admin config key was given, or the `X-Requested-With` header is missing. |
| 404 | `not_found` | SaaS mode, or dashboard accounts are disabled. |
| 413 | `payload_too_large` | Body over 16 KiB. |
| 429 | `rate_limited` | Too many attempts. |
## Sign in with email and password
`POST /v1/auth/login`
Checks an email and password and starts a session. *Self-hosted only.* Wrong email and wrong password give the same error, so the response doesn't reveal which accounts exist.
**Who can call it:** anyone. Rate-limited.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | yes | — | Account email (case-insensitive). |
| `password` | string | yes | — | Account password. |
**Example**
```bash
curl -X POST https://pushq.example.com/v1/auth/login \
-c cookies.txt \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "email": "ana@example.com", "password": "a-long-passphrase" }'
```
**Response**
`200 OK` with the [sign-in response](#the-sign-in-response) and a `Set-Cookie: pushq_session=...` header.
```json
{
"user": {
"id": 1,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "admin",
"created_at": "2026-11-28T12:00:00Z",
"last_login_at": "2026-11-28T14:21:07Z"
}
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON. |
| 401 | `unauthenticated` | Unknown email or wrong password. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | SaaS mode, or dashboard accounts are disabled. |
| 429 | `rate_limited` | Too many attempts. |
## Sign out
`POST /v1/auth/logout`
Ends the current session on the server and clears the cookie. It succeeds even if there was no session. Applies in every mode.
**Who can call it:** anyone.
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/auth/logout \
-b cookies.txt \
-H "X-Requested-With: pushq"
```
**Response**
`204 No Content` with an empty body and a `Set-Cookie` header that deletes `pushq_session`.
**Errors**
| Status | Code | When |
|---|---|---|
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
## Look up an invite or reset link
`GET /v1/auth/invites/{token}`
Shows what an invite or password-reset link is for, without using it up. The dashboard's `/invite` page calls it to show "You've been invited as member" or "Reset the password for ana@example.com". Invite and reset links look like `https://pushq.example.com/invite#token=pqi_...`; the token is the part after `token=`. *Self-hosted only.*
**Who can call it:** anyone holding the token.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `token` | string | yes | — | The `pqi_...` token from the link. |
**Example**
```bash
curl https://pushq.example.com/v1/auth/invites/pqi_Zr8wK1nQ3yT0vB6xM2cL9pH4dF7aJ5sE1uG8iO3kYqA
```
**Response**
`200 OK`:
```json
{
"id": 9,
"kind": "invite",
"email": "sam@example.com",
"role": "member",
"created_at": "2026-11-28T10:00:00Z",
"expires_at": "2026-12-05T10:00:00Z"
}
```
| Field | Type | Description |
|---|---|---|
| `id` | integer | Invite ID. |
| `kind` | string | `invite` (creates a new account) or `reset` (sets a new password for an existing one). |
| `email` | string | The account email. |
| `role` | string | Role the new account gets. Omitted for `reset`. |
| `created_at` | string (RFC 3339) | When the link was created. |
| `expires_at` | string (RFC 3339) | When it stops working (7 days for invites, 24 hours for reset links). |
**Errors**
| Status | Code | When |
|---|---|---|
| 404 | `not_found` | The link is invalid, already used or expired; or SaaS mode. |
## Accept an invite or reset link
`POST /v1/auth/invites/{token}:accept`
Uses an invite or reset link and signs the person in. For an invite it creates the account with the invited email and role. For a reset link it sets the new password and signs the user out of every other session. Each link works once. *Self-hosted only.*
**Who can call it:** anyone holding the token. Rate-limited.
**Path parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `token` | string | yes | — | The `pqi_...` token from the link. |
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `password` | string | yes | — | New password: at least 8 characters, at most 256 bytes. |
| `name` | string | no | `""` | Display name, at most 100 characters. Used for new accounts; ignored by reset links. |
**Example**
```bash
curl -X POST https://pushq.example.com/v1/auth/invites/pqi_Zr8wK1nQ3yT0vB6xM2cL9pH4dF7aJ5sE1uG8iO3kYqA:accept \
-c cookies.txt \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "name": "Sam Ortiz", "password": "another-long-passphrase" }'
```
**Response**
`200 OK` with the [sign-in response](#the-sign-in-response) and a `Set-Cookie: pushq_session=...` header.
```json
{
"user": {
"id": 8,
"email": "sam@example.com",
"name": "Sam Ortiz",
"role": "member",
"created_at": "2026-11-28T15:00:00Z",
"last_login_at": "2026-11-28T15:00:00Z"
}
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, password too short or long, name too long. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | The link is invalid, already used or expired; or SaaS mode. |
| 409 | `already_exists` | An account with the invited email already exists. |
| 429 | `rate_limited` | Too many attempts. |
## Email a sign-in code
`POST /v1/auth/email-code`
Emails a 6-digit sign-in code to the address. If the email has no account yet, one is created, so this is also how people sign up. The response is the same either way and doesn't reveal whether the address already had an account. Follow up with [Sign in with the emailed code](#sign-in-with-the-emailed-code). *SaaS only.*
**Who can call it:** anyone. Rate-limited.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | yes | — | Email address; must contain `@`, no spaces, at most 254 characters. Case-insensitive. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/auth/email-code \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "email": "ana@example.com" }'
```
**Response**
`200 OK`:
```json
{ "sent": true }
```
| Field | Type | Description |
|---|---|---|
| `sent` | boolean | Always `true` on success. |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON or email. |
| 400 | `failed_precondition` | WorkOS rejected the request; `detail` explains why. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | Not in SaaS mode. |
| 413 | `payload_too_large` | Body over 4 KiB. |
| 429 | `rate_limited` | Too many attempts. |
| 502 | `internal` | WorkOS is unavailable. |
## Sign in with the emailed code
`POST /v1/auth/email-code:verify`
Checks the code from the email and starts a session. Entering the code proves the person owns the inbox, so the email is marked verified. The session starts in the team the user last used (or their first team; `needs_team` in [the session](#get-the-current-session) tells you if they have none). *SaaS only.*
If WorkOS needs a separate email-verification step, this answers `403 email_verification_required` and sets a short-lived `pushq_email_verify` cookie (15 minutes); finish with [Finish a paused sign-in](#finish-a-paused-sign-in).
**Who can call it:** anyone. Rate-limited.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | yes | — | The address the code was sent to. |
| `code` | string | yes | — | The 6-digit code. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/auth/email-code:verify \
-c cookies.txt \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "email": "ana@example.com", "code": "482913" }'
```
**Response**
`200 OK` with the [sign-in response](#the-sign-in-response) and a `Set-Cookie: pushq_session=...` header.
```json
{
"user": {
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "member",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
}
}
```
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON, or email or code missing. |
| 400 | `failed_precondition` | The sign-in can't complete, for example the email is linked to a different account; `detail` explains. |
| 401 | `unauthenticated` | The code is wrong or expired. |
| 403 | `email_verification_required` | WorkOS emailed a verification code; finish with `POST /v1/auth/email-verification`. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | Not in SaaS mode. |
| 429 | `rate_limited` | Too many attempts. |
| 502 | `internal` | WorkOS is unavailable. |
## Check for a paused sign-in
`GET /v1/auth/email-verification`
Reports whether this browser has a sign-in waiting for an email verification code, and which address the code went to. The sign-in page calls it after being sent to `/login?verify=1`. It reads the `pushq_email_verify` cookie, so without that cookie it reports nothing pending.
**Who can call it:** anyone. Works in every mode, but only SaaS mode ever pauses a sign-in.
**Example**
```bash
curl https://api.pushqueue.dev/v1/auth/email-verification \
-b cookies.txt
```
**Response**
`200 OK`:
```json
{ "pending": true, "email": "ana@example.com" }
```
| Field | Type | Description |
|---|---|---|
| `pending` | boolean | A sign-in is waiting for an email verification code. |
| `email` | string | Where the verification code was sent. Empty when nothing is pending. |
**Errors**
None specific to this endpoint.
## Finish a paused sign-in
`POST /v1/auth/email-verification`
Completes a sign-in that was paused for email verification (after `email-code:verify` answered `email_verification_required`, or a GitHub sign-in redirected to `/login?verify=1`). Send the code from the verification email; the paused sign-in is identified by the `pushq_email_verify` cookie. *SaaS only.*
**Who can call it:** anyone with the pending-verification cookie. Rate-limited.
**Request body**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `code` | string | yes | — | The code from the verification email. |
**Example**
```bash
curl -X POST https://api.pushqueue.dev/v1/auth/email-verification \
-b cookies.txt -c cookies.txt \
-H "X-Requested-With: pushq" \
-H "Content-Type: application/json" \
-d '{ "code": "907315" }'
```
**Response**
`200 OK` with a `Set-Cookie: pushq_session=...` header (and the pending-verification cookie cleared):
```json
{
"user": {
"id": 3,
"email": "ana@example.com",
"name": "Ana Lima",
"role": "member",
"created_at": "2026-09-14T08:12:00Z",
"last_login_at": "2026-11-28T09:01:12Z"
},
"next": "/queues"
}
```
| Field | Type | Description |
|---|---|---|
| `user` | object | The signed-in user ([user fields](#the-sign-in-response)). |
| `next` | string | Dashboard path to go to next (from the original sign-in's `next`, or `/`). |
**Errors**
| Status | Code | When |
|---|---|---|
| 400 | `invalid_argument` | Invalid JSON. |
| 400 | `failed_precondition` | No pending verification (cookie missing or older than 15 minutes), or the sign-in can't complete; `detail` explains. |
| 401 | `unauthenticated` | The code is wrong or expired. |
| 403 | `permission_denied` | Missing `X-Requested-With` header. |
| 404 | `not_found` | Not in SaaS mode. |
| 429 | `rate_limited` | Too many attempts. |
| 502 | `internal` | WorkOS is unavailable. |
## Start GitHub sign-in
`GET /v1/auth/workos/login`
Starts a GitHub sign-in through WorkOS. This is a browser navigation, not an API call: link the "Sign in with GitHub" button to it. It sets a short-lived state cookie (10 minutes) and redirects to GitHub's consent screen. *SaaS only.*
**Who can call it:** anyone (a browser).
**Query parameters**
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `provider` | string | yes | — | Sign-in provider. Only `github` is supported. |
| `next` | string | no | `/` | Dashboard path to return to afterwards. Must be a path on the same site (not `//host`, not under `/v1/`); anything else becomes `/`. |
**Example**
```bash
curl -i "https://api.pushqueue.dev/v1/auth/workos/login?provider=github&next=/queues"
```
**Response**
`302 Found` with a `Location` header pointing at GitHub. An unknown `provider` redirects to `/login?error=Unknown%20sign-in%20option.` instead.
**Errors**
| Status | Code | When |
|---|---|---|
| 404 | `not_found` | Not in SaaS mode. |
## Handle the GitHub sign-in callback
`GET /v1/auth/workos/callback`
Where WorkOS sends the browser back after GitHub. It checks the state cookie set by [Start GitHub sign-in](#start-github-sign-in), exchanges the code with WorkOS, creates the session and redirects into the dashboard. You don't call it yourself, but its URL must be registered as a redirect URI in your WorkOS dashboard when you run [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/). *SaaS only.*
**Who can call it:** the browser, coming from WorkOS.
**Query parameters**
Set by WorkOS, not by you.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `code` | string | yes | — | Authorization code from WorkOS. |
| `state` | string | yes | — | Must match the state cookie. |
| `error` | string | no | — | Set by WorkOS when sign-in was cancelled or failed. |
| `error_description` | string | no | — | Human-readable reason for `error`. |
**Response**
Always `302 Found`:
| Redirect target | When |
|---|---|
| The `next` path from the login step (default `/`) | Signed in; `Set-Cookie: pushq_session=...` is included. |
| `/login?verify=1` | WorkOS requires email verification first; finish with [Finish a paused sign-in](#finish-a-paused-sign-in). |
| `/login?error=` | State cookie missing or expired, state mismatch, cancelled at GitHub, or WorkOS rejected the sign-in. |
**Errors**
| Status | Code | When |
|---|---|---|
| 404 | `not_found` | Not in SaaS mode. |
## Read more
- [Using the dashboard](https://pushqueue.dev/docs/guides/dashboard/): what people see after signing in.
- [Teams & users API reference](https://pushqueue.dev/docs/reference/rest/teams-and-users/): invites, roles and teams.
- [Running pushq in SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/): set up WorkOS email-code and GitHub sign-in.
- [Self-hosted server configuration](https://pushqueue.dev/docs/self-hosting/configuration/): config-file API keys and dev mode.
---
# Health, metrics and version endpoints
> pushq system endpoints: /healthz and /readyz health checks, Prometheus /metrics, /v1/version, and the /openapi.json spec with its /docs Swagger UI.
Source: https://pushqueue.dev/docs/reference/rest/system/
pushq's system endpoints sit outside the queue and task API: liveness and readiness health checks, Prometheus metrics, the server version, and the OpenAPI spec with its Swagger UI. Use them for load-balancer health checks, Prometheus scraping, checking which server version you're talking to, and generating clients or browsing the API interactively. Most matter when you [run pushq yourself](https://pushqueue.dev/docs/self-hosting/operations/); `/v1/version`, `/openapi.json` and `/docs` are useful against the hosted API too.
The SDKs don't wrap these endpoints; call them over HTTP.
| Endpoint | Auth | Purpose |
|---|---|---|
| `GET /healthz` | none | Liveness: the process is up. |
| `GET /readyz` | none | Readiness: the database is reachable. |
| `GET /metrics` | none by default (configurable) | Prometheus metrics. |
| `GET /v1/version` | API key or session | Server version and database type. |
| `GET /openapi.json` | none | OpenAPI 3 document for the API. |
| `GET /docs` | none | Interactive API reference (Swagger UI). |
## Check liveness (healthz)
`GET /healthz`
Answers `ok` as long as the process is running and serving HTTP. It doesn't touch the database. Use it as a liveness probe: if it stops answering, restart the process.
**Who can call it:** anyone, no credentials.
**Example**
```bash
curl https://api.pushqueue.dev/healthz
```
**Response**
`200 OK` with `Content-Type: text/plain` and the body:
```text
ok
```
**Errors**
None; if the process can't answer, the request fails at the network level.
## Check readiness (readyz)
`GET /readyz`
Pings the database and reports this replica's role. Use it as a readiness probe or load-balancer health check, so traffic only goes to replicas that can reach the database.
**Who can call it:** anyone, no credentials.
**Example**
```bash
curl https://api.pushqueue.dev/readyz
```
**Response**
`200 OK`:
```json
{ "role": "leader", "dialect": "postgres" }
```
| Field | Type | Description |
|---|---|---|
| `role` | string | `leader` on the replica currently running the dispatcher, `follower` on replicas waiting to take over, `stopped` while the dispatcher is shutting down, or `api` when the server runs without a dispatcher. |
| `dialect` | string | Database backend: `sqlite` or `postgres`. |
**Errors**
| Status | Code | When |
|---|---|---|
| 503 | `internal` | The database is unreachable (`detail`: `database unreachable`). |
See [API error codes](https://pushqueue.dev/docs/reference/errors/) for the error format.
## Scrape Prometheus metrics
`GET /metrics`
Serves Prometheus metrics in the text exposition format: dispatch counts by response class, errors by kind, dispatch latency, retries, dead-lettered tasks, expired leases, in-flight dispatches and active queues, plus standard Go runtime and process metrics. Use it to scrape a self-hosted server into Prometheus or Grafana. For per-queue numbers, use [queue stats](https://pushqueue.dev/docs/reference/rest/queues/#get-queue-stats) instead.
**Who can call it:** anyone by default. When `metrics.public` is turned off in the server config (`PUSHQ_METRICS_PUBLIC=false`), it needs the **list** permission: an `admin` API key, or a dashboard viewer, member or admin. In SaaS mode with metrics not public, only the operator's config-file API keys can read it, since metrics cover every team on the instance. See [server configuration](https://pushqueue.dev/docs/self-hosting/configuration/).
**Example**
```bash
curl https://pushq.example.com/metrics \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK` with Prometheus text format (abridged):
```text
# HELP pushq_dispatches_total Task dispatch attempts by response code class.
# TYPE pushq_dispatches_total counter
pushq_dispatches_total{code_class="2xx"} 15320
pushq_dispatches_total{code_class="5xx"} 41
# HELP pushq_dispatch_errors_total Failed dispatch attempts by error kind.
# TYPE pushq_dispatch_errors_total counter
pushq_dispatch_errors_total{error_kind="non_2xx"} 41
pushq_dispatch_errors_total{error_kind="timeout"} 3
# HELP pushq_dispatch_inflight Dispatches currently in flight.
# TYPE pushq_dispatch_inflight gauge
pushq_dispatch_inflight 7
```
| Metric | Type | Description |
|---|---|---|
| `pushq_dispatches_total{code_class}` | counter | Dispatch attempts by response class: `2xx`, `3xx`, `4xx`, `5xx`, or `error` when no response arrived. |
| `pushq_dispatch_errors_total{error_kind}` | counter | Failed attempts by error kind (`non_2xx`, `timeout`, `connect`, `dns`, `tls`, `config`). |
| `pushq_dispatch_duration_seconds` | histogram | Dispatch round-trip latency. |
| `pushq_tasks_claimed_total` | counter | Tasks leased by the dispatcher. |
| `pushq_task_retries_total` | counter | Attempts rescheduled for retry. |
| `pushq_tasks_dead_lettered_total` | counter | Tasks copied to a dead-letter queue. |
| `pushq_leases_expired_total` | counter | Leases reclaimed by the sweeper. |
| `pushq_dispatch_inflight` | gauge | Dispatches currently in flight. |
| `pushq_active_queues` | gauge | Queues tracked by the scheduler. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | Metrics aren't public and no valid credentials were sent. |
| 403 | `permission_denied` | The caller lacks the list permission (for example a writer key), or, in SaaS mode, isn't an operator key. |
## Get the server version
`GET /v1/version`
Returns the server's version, the commit it was built from, and its database backend. Use it to confirm which release you're talking to after an upgrade, or to include in bug reports.
**Who can call it:** any API key (writer or admin) or dashboard user (viewer, member or admin).
**Example**
```bash
curl https://api.pushqueue.dev/v1/version \
-H "Authorization: Bearer $PUSHQ_API_KEY"
```
**Response**
`200 OK`:
```json
{ "version": "1.0.0", "commit": "3f9c2ab", "dialect": "postgres" }
```
| Field | Type | Description |
|---|---|---|
| `version` | string | Release version (`dev` for local builds). |
| `commit` | string | Git commit the binary was built from (`none` for local builds). |
| `dialect` | string | Database backend: `sqlite` or `postgres`. |
**Errors**
| Status | Code | When |
|---|---|---|
| 401 | `unauthenticated` | No valid credentials. |
| 403 | `permission_denied` | The caller has no read permission (for example a SaaS user with no team selected). |
## Download the OpenAPI spec
`GET /openapi.json`
Returns the OpenAPI document for the API, generated from the running server's routes, so it always matches the version you're calling. Use it to generate a client in a language without an SDK, to import the API into Postman or Insomnia, or to diff API changes between releases.
**Who can call it:** anyone, no credentials.
**Example**
```bash
curl https://api.pushqueue.dev/openapi.json -o pushq-openapi.json
```
**Response**
`200 OK` with `Content-Type: application/json` (abridged):
```json
{
"openapi": "3.1.0",
"info": { "title": "pushq API", "version": "1.0.0" },
"components": {
"securitySchemes": {
"apiKey": { "type": "http", "scheme": "bearer" },
"session": { "type": "apiKey", "in": "cookie", "name": "pushq_session" }
}
},
"paths": { "/v1/queues": { "get": { "summary": "List queues" } } }
}
```
The document describes every route on this site's REST reference: paths, parameters, request and response schemas, and which endpoints need an API key or session.
**Errors**
None specific to this endpoint.
## Browse the interactive API docs
`GET /docs`
Serves Swagger UI for `/openapi.json`, so you can browse every endpoint and try requests from the browser. Click **Authorize** and paste an API key to call the API. If you're signed in to the dashboard on the same server, "Try it out" also works with your session. The hosted version is at [api.pushqueue.dev/docs](https://api.pushqueue.dev/docs).
**Who can call it:** anyone, no credentials. The requests you make from it need credentials as usual.
**Example**
```bash
open https://api.pushqueue.dev/docs
```
**Response**
`200 OK` with an HTML page (`Content-Type: text/html`).
**Errors**
None specific to this endpoint.
## Read more
- [Operating a self-hosted server](https://pushqueue.dev/docs/self-hosting/operations/): health checks, metrics and upgrades.
- [Deploy pushq](https://pushqueue.dev/docs/self-hosting/deploy/): wire `/healthz` and `/readyz` into your platform.
- [Going to production](https://pushqueue.dev/docs/guides/going-to-production/): monitoring and alerting checklist.
- [REST API overview](https://pushqueue.dev/docs/reference/api/): authentication and conventions for every endpoint.