docs/api.md
This document covers the HTTP API surface and authentication flows. For WebSocket updates and event payloads, see protocol.md. For encryption boundaries and encoding details, see encryption.md.
We intentionally avoid the full REST verb palette because many operations span multiple entities or have non-CRUD semantics.
Most endpoints require Authorization: Bearer <token>.
Auth flows:
POST /v1/auth
{ publicKey, challenge, signature } (base64 strings){ success, token }.POST /v1/auth/request
{ publicKey, supportsV2? }{ state: "requested" } or { state: "authorized", token, response }.GET /v1/auth/request/status?publicKey=...
{ status: "not_found" | "pending" | "authorized", supportsV2 }.POST /v1/auth/response
{ response, publicKey } (requires Bearer auth)POST /v1/auth/account/request
{ publicKey }POST /v1/auth/account/response
{ response, publicKey } (requires Bearer auth)GET /v1/sessionsGET /v2/sessions/active?limit=...GET /v2/sessions?cursor=cursor_v1_<id>&limit=...&changedSince=...POST /v1/sessions (create or load by tag)GET /v1/sessions/:sessionId/messagesDELETE /v1/sessions/:sessionIdPOST /v1/machines (create or load by id)GET /v1/machinesGET /v1/machines/:idGET /v1/artifactsGET /v1/artifacts/:idPOST /v1/artifactsPOST /v1/artifacts/:id (versioned update)DELETE /v1/artifacts/:idGET /v1/access-keys/:sessionId/:machineIdPOST /v1/access-keys/:sessionId/:machineIdPUT /v1/access-keys/:sessionId/:machineIdGET /v1/kv/:keyGET /v1/kv?prefix=...&limit=...POST /v1/kv/bulkPOST /v1/kv (batch mutate)GET /v1/account/profileGET /v1/account/settingsPOST /v1/account/settingsPOST /v1/usage/queryPOST /v1/push-tokensDELETE /v1/push-tokens/:tokenGET /v1/push-tokensGET /v1/connect/github/paramsGET /v1/connect/github/callbackPOST /v1/connect/github/webhookDELETE /v1/connect/githubPOST /v1/connect/:vendor/register (vendor in openai | anthropic | gemini)GET /v1/connect/:vendor/tokenDELETE /v1/connect/:vendorGET /v1/connect/tokensGET /v1/user/:idGET /v1/user/search?query=...POST /v1/friends/addPOST /v1/friends/removeGET /v1/friendsGET /v1/feedPOST /v1/versionPOST /v1/voice/tokenPOST /logs-combined-from-cli-and-mobile-for-simple-ai-debugging (only if enabled)packages/happy-server/sources/app/api/routespackages/happy-server/sources/app/auth/auth.ts