# HTTP API reference

Base URL for the standalone sample: `http://127.0.0.1:9070`. The sample has no authentication. Keep it on loopback; clustered authentication has a separate configuration contract.

## Endpoint summary

| Method | Path | Request | Success |
| --- | --- | --- | --- |
| POST | `/write` | ILP, `text/plain` | 204 after local durable application |
| POST | `/query` | JSON with `sql` | 200 with query result |
| POST | `/scan` | JSON with table/range | 200 with points and stats |
| POST | `/compact` | Empty body | 200 with compaction counters or a no-op |
| GET | `/healthz` | None | 200 while HTTP serving is alive |
| GET | `/readyz` | None | 200 after recovery when ready |
| GET | `/metrics` | None | Prometheus text |
| GET | `/debug/stats` | None | Optional JSON state, loopback only |

No content encoding or query parameters are accepted on write/scan. Use the documented JSON body instead. Explicit compaction is available only on loopback.

## Minimal request bodies

Query:

```json
{"sql":"SELECT device, value FROM temperature LIMIT 10"}
```

Scan:

```json
{"table":"temperature","columns":["device","value"]}
```

## Write errors

Application errors carry `error` and `outcome`. The same status can have different outcomes.

| Status | Cause | Outcome |
| --- | --- | --- |
| 400 | Invalid ILP, schema/key conflict, unsupported parameter | `not_written` |
| 408 | Body timeout before enqueue | `not_written` |
| 413 | Body, line, or point-count bound exceeded | `not_written` |
| 415 | Unsupported content type or encoding | `not_written` |
| 429 | Queue, catalog, WAL, or admission capacity | `not_written` |
| 503 | Recovering, draining, or failed writer before acceptance | `not_written` |
| 503 | Write deadline, lost reply, or append/sync failure | `unknown` |

A transport failure without an application response is uncertain. Accepted work is not cancelled by disconnecting. There are no automatic server-side retries.

## Read and maintenance outcomes

Scan errors use `read_only`. Scan admission, decoder, or result limits can return 429. Invalid input returns 400; storage unavailability or deadline expiry can return 503.

Compaction errors use `not_compacted` when rejected before work and `maintenance_unknown` when publication or response is uncertain. A compaction timeout does not prove the job was cancelled.

## Health versus readiness

`/healthz` indicates that the HTTP process is alive. `/readyz` indicates recovery has completed and the writer is operational. Even a ready node can reject an individual request at a capacity limit. Monitor all three: liveness, readiness, and request outcomes.
