Stable conventions help humans and LLMs generate correct clients.
Prefix and versioning#
- API prefix:
/api - There is no external multi-major versioning today; breaking changes are documented in the changelog.
Success envelope#
Go type: dto.Response[T].
| Field | Type | Description |
| --- | --- |
| data | T | Endpoint payload |
| request_id | string | Correlation; also in the X-Request-ID header |
| meta | object? | Cursor pagination when applicable |
Error envelope#
limit_* and required_plan only on plan errors. Details: Errors.
Identifiers#
| Entity | Format |
|---|---|
Platform users.id, profiles.id | UUID |
| Domain entities | UUID |
Better Auth user.id | string (TEXT) |
Always send IDs as UUID strings in JSON/paths.
Profile scope#
HTTP paths use /profiles/{studioId}. Product copy says Studio; storage
and shared modules also use profile. Next.js app services may call
/api/{domain}/studios/... and rewrite to /profiles/ before Go — always
prefer the OpenAPI /profiles/ form when curling api.agata.in or writing
external clients.
Dominant pattern:
Examples:
/api/tasks/profiles/{studioId}/api/finance/profiles/{studioId}/transactions/api/notebook/profiles/{studioId}/notes/{noteId}/document
Exceptions: /users/me/*, /profiles (user listing), public /p/:handle, health, internal.
HTTP methods#
| Method | Use |
|---|---|
GET | Read |
POST | Create / actions (ensure, restore, pin…) |
PATCH | Partial update |
PUT | Replace / upsert (e.g. rich-text document, budgets) |
DELETE | Delete (often soft) |
Money#
- Amounts in cents (integers), not floats.
- Currency follows account / profile settings (see the finance domain).
Dates#
| Type | Format | Use |
| --- | --- |
| Instants | RFC3339 / TIMESTAMPTZ ISO | createdAt, updatedAt |
| Local day | YYYY-MM-DD | check-ins, meal logs, finance day keys (dateKey, dueDateKey) |
Pagination#
Large lists use a cursor by default:
- Request: cursor query param (name per endpoint; see OpenAPI)
- Response:
meta.next_cursor,meta.has_more
Some listings (e.g. inbox tasks) also accept a numbered page when page (+ pageSize) is sent:
- Response:
meta.page,meta.page_size,meta.total,meta.total_pages,meta.has_more
Go utilities: internal/shared/pagination/.
Content-Type#
Idempotency and conflicts#
- Duplicate resources →
409/DUPLICATE_RESOURCEwhen applicable. - Rich-text documents use optimistic version (
expectedVersion) to avoid lost updates.
Naming#
- Paths in English, kebab/restful.
- Domain payloads in camelCase (
studioId,amountCents,createdAt). - The cross-cutting envelope keeps snake_case (
request_id,next_cursor,limit_key). Do not mix both styles at the same payload level.
Where not to invent#
If you are unsure of the exact body shape, open:
- The operation in OpenAPI
- The handler in
delivery/http/*_handlers.go - The client in
apps/app/services/<domain>/