# A34 API quick reference

All routes use `/aichat34/api/` and a dedicated `aichat34-api` Worker with D1 binding `AICHAT34_DB`.

Core routes: `/auth/me`, `/auth/google`, `/auth/logout`, `/chat`, `/custom-games/list`, `/custom-games/detail`, `/custom-games/create`, `/custom-games/delete`, `/cgame2/list`, `/cgame2/save`, `/cgame2/delete`, `/cgame2/plans`, `/admin/cgame2/plans`, `/share/*`, `/generate-image`, `/payment/*`, `/credits/spend`, `/admin/conversations`, `/admin/conversations/refund`.

Authentication uses the `a34sid` HttpOnly cookie. User/game/chat/credit tables are created empty in a new A34-only D1 database; only the public game catalog migration is copied. No A31 account IDs, private chat history, credits, payment rows or secrets are migrated.

`OPENROUTER_API_KEY` is a Cloudflare Worker Secret and is never included in source files. If it is not configured, the AI path should fail safely without charging credits. Payment endpoints require their own credentials and must not be enabled until configured.


The refund endpoint accepts a saved conversation record ID, requires one of the three allowlisted verified Google identities, returns that record's recorded spend once, and writes both a credit ledger entry and an operator access audit. Conversation content is available only for users who opted in to 90-day storage.

`GET/POST/DELETE /cgame2/plans` uses the authenticated `a34sid` session to list, save/update, load, and delete only the caller's Studio 2 text drafts. The server ignores submitted owner IDs and enforces ownership in D1. Uploaded images are not included. `GET /admin/cgame2/plans` allows only the same three verified Google identities and records each query in `conversation_admin_access`.
