> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openinary.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Health

> Check server and database availability

## Server health

```
GET /health
```

**Auth:** Public (rate limited)

Quick liveness check, use this for load balancer health probes or uptime monitoring.

### Response

```json theme={null}
{
  "status": "ok",
  "timestamp": "2024-03-15T10:30:00.000Z",
  "service": "openinary-api"
}
```

**Status codes:** `200` healthy

### Example

```bash theme={null}
curl http://localhost:3000/health
```

***

## Database health

```
GET /health/database
```

**Auth:** API Key required

Detailed diagnostic, checks the SQLite database connection, file permissions, and table record counts.

### Response

```json theme={null}
{
  "status": "ok",
  "timestamp": "2024-03-15T10:30:00.000Z",
  "database": {
    "connected": true,
    "path": "/app/data/openinary.db",
    "size": "2.4 MB",
    "permissions": "0644",
    "tables": {
      "user": 1,
      "session": 3,
      "account": 1,
      "verification": 0,
      "apiKey": 2
    }
  }
}
```

<ResponseField name="database.connected" type="boolean">
  Whether the database connection is active.
</ResponseField>

<ResponseField name="database.path" type="string">
  Absolute path to the database file.
</ResponseField>

<ResponseField name="database.size" type="string">
  Database file size.
</ResponseField>

<ResponseField name="database.permissions" type="string">
  Octal file permissions.
</ResponseField>

<ResponseField name="database.tables" type="object">
  Record counts per table. Useful for verifying migrations applied correctly.
</ResponseField>

<ResponseField name="database.warning" type="string">
  Optional warning (e.g. unusual permissions).
</ResponseField>

<ResponseField name="database.security_warning" type="string">
  Optional warning when the database file's permissions are less restrictive
  than `600`.
</ResponseField>

<ResponseField name="database.file_error" type="string">
  Optional error message if the database file's permissions or size couldn't be
  read.
</ResponseField>

<ResponseField name="database.table_error" type="string">
  Optional error message if table record counts couldn't be retrieved.
</ResponseField>

**Status codes:** `200` healthy · `503` database connection failed

### Example

```bash theme={null}
curl http://localhost:3000/health/database \
  -H "Authorization: Bearer <api_key>"
```
