Authentication
APEX authenticates every request with an X-API-Key header. Keys are hashed at rest, returned once at creation, and validated on each request; a validation failure denies access rather than erroring.
Every APEX endpoint except GET /health and GET /openapi.yaml requires an API key in the
X-API-Key header. This is the APEX-specific auth; shared conventions (errors, versioning)
are in API conventions.
curl https://apex.tovr.eu/api/v1/analytics/overview \
-H "X-API-Key: apex_3f2a9c41d88e0b7a5c6e1f9d2b4a8c0e1133557799aabbcc"How keys work
- Keys look like
apex_followed by 48 hex characters, generated server-side from 24 bytes of cryptographic randomness. - Only a SHA-256 hash of the key is stored. The raw key is returned exactly once at creation and cannot be recovered — losing it means issuing a new one.
- On every request the middleware hashes the presented key and looks it up among active keys. The key's last-used timestamp is updated asynchronously so validation never blocks on a write.
- A backend failure during validation denies access (
403, never5xx) — an unverifiable key is treated as invalid.
Getting a key
Keys are issued by TOVR operators. Each key carries a name (identifies the consumer in usage stats), an organization label (attached to request context for logging), and a per-minute request budget (see Rate limiting).
Revocation is a soft delete: the key is deactivated immediately and the record is kept for audit. There is no automatic rotation — issue a new key, switch your deployment, then revoke the old one.
Auth errors
| HTTP | Code | Meaning |
|---|---|---|
| 401 | KEY_MISSING | No X-API-Key header. |
| 403 | KEY_INVALID | Key hash not found, or the key was revoked. |
| 403 | KEY_VALIDATION_ERROR | Backend unreachable during validation — access denied as a precaution. Safe to retry once. |
The full catalog is in Errors.
Security practices
- Server-to-server only — never embed keys in client-side code or repositories.
- Store keys in a secret manager or environment variables.
- Use a separate key per environment/service so usage stats stay attributable.
- Watch last-used and per-key usage to find dead or runaway keys.
- Rotate after any suspected exposure (issue → switch → revoke).
Reference
The APEX API reference — base URL, authentication, price estimation and batch, corridors, the 18 analytics endpoints, errors, configuration, and known limitations.
Rate limiting
Each APEX key has a per-minute request budget enforced in a fixed one-minute window. Responses carry the budget state in X-RateLimit headers; exceeding it returns 429 with Retry-After.