Skip to main content

Conventions

JSON envelope, IDs, pagination, money, dates, and domain paths.
2 min read

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#

EntityFormat
Platform users.id, profiles.idUUID
Domain entitiesUUID
Better Auth user.idstring (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#

MethodUse
GETRead
POSTCreate / actions (ensure, restore, pin…)
PATCHPartial update
PUTReplace / upsert (e.g. rich-text document, budgets)
DELETEDelete (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_RESOURCE when 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:

  1. The operation in OpenAPI
  2. The handler in delivery/http/*_handlers.go
  3. The client in apps/app/services/<domain>/