Trialmile docs

API reference

Every procedure of the Trialmile server, generated from the oRPC OpenAPI export.

The pages in this section are generated at build time from apps/fumadocs/openapi/trialmile.json, the OpenAPI document exported from the oRPC router in packages/api. Nothing here is written by hand: run bun run openapi in apps/fumadocs after changing a procedure, or let bun run build do it.

Calling the API

Every procedure is a POST with a JSON body under the /api-reference prefix of the server:

curl -X POST http://localhost:3720/api-reference/campaigns/list \
  -H "Content-Type: application/json" \
  --cookie "better-auth.session_token=…" \
  -d '{}'
  • Authentication: a Better Auth session cookie (/api/auth/*). Organization-scoped procedures use the session's active organization; the caller must be a member.
  • Admin: admin.* requires the admin role. dev.* additionally requires DEV_TOOLS=1 and is absent on stage/prod.
  • Errors: oRPC error envelopes (UNAUTHORIZED, FORBIDDEN, NOT_FOUND, BAD_REQUEST, …). Cross-organization ids answer NOT_FOUND.
  • Soft deletes: delete sets deleted_at, restore clears it; list/get accept includeDeleted.

The same document backs the server's own reference at http://localhost:3720/api-reference (/spec.json for the raw spec).

On this page