# 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.
