# Check the API is up

Answers `{ ok: true }` when the server is running and its database answers.

GET `/api/healthz`

**cURL**

```shell
curl 'https://www.prufy.dev/api/healthz'
```

**Node.js**

```javascript
const response = await fetch("https://www.prufy.dev/api/healthz")
const data = await response.json()
```

**Python**

```python
import requests

response = requests.get("https://www.prufy.dev/api/healthz")
data = response.json()
```

Response 200 OK

```json
{
  "ok": true,
  "database": {
    "ok": true,
    "latencyMs": 3
  }
}
```

It runs one query against the database, with a two-second limit, so a monitor pointed here finds out when claims can't be read or written. It doesn't look up DNS: a slow resolver isn't an outage.

It isn't versioned and never moves, so a monitor's address stays good. The failure never says why, because the reason can name internal hosts.

## Authentication

No credential needed. [How sessions work](https://www.prufy.dev/docs/authentication.md).

## Response

`200 OK`, with every field below present. Times are ISO 8601 strings in UTC.

- `ok` true

  Always true. Anything else is an error response.
- `database` object

  The one dependency every route needs.

  - `ok` true

    The database answered a query.
  - `latencyMs` integer

    How long that query took, in milliseconds.

## Errors

| Status | Kind | When |
| --- | --- | --- |
| 503 | `unavailable` | The database didn't answer within two seconds, or refused the query. A 503 with `retryAfter`. |

Any route can also answer `500` with `internal_error`. Every error has the same shape, described in [Errors](https://www.prufy.dev/docs/errors.md).

---

Every page of these docs, as a list: https://www.prufy.dev/llms.txt
