Skip to main content

Base URL

Locally (see Quickstart):
Every route documented in this section is prefixed /v1/, except the gateway (/gateway/v1/*, see its dedicated page) and /health.

Authentication

string
required
Bearer hk_.... Required on every /v1/* endpoint (except /v1/keys and /v1/orgs, which have their own auth logic) and on /gateway/v1/*, when HAKI_AUTH_REQUIRED=true (default).
A key is bound to one org_id + one project_id. Any request whose project_id (in the body or the query) differs from the key’s is rejected with 403 forbidden_scope — a generic message, never revealing the existence of other projects. HAKI_AUTH_REQUIRED=false = open dev mode (never in production, a warning is logged at API startup). See Security for the full model (Row-Level Security, Policy Engine, key bootstrap).

Error format

Every business error shares the same shape, never a vague invalid request:
string
required
A stable, machine-readable identifier — see the table below.
string
required
Human-readable message.
string | null
The offending field, when identifiable (events.0.subject_id, budget_tokens…).

All error types

A consistent principle across the codebase: a resource from another scope (project, subject) returns exactly the same error as a non-existent resource. Never a leak hinting “it exists, just not for you.”