APIs
OpenAPI and REST endpoints powered by oRPC
Overview
REST endpoints are generated from oRPC procedures that define explicit .route(...) metadata.
Architecture
External Client
-> /api/<path>
-> OpenAPI handler (`@orpc/openapi`)
-> appRouter procedures
-> db/servicesExpose a Procedure as REST
import { authProcedure } from "@/rpc/procedures/rpc";
import { actionResponseSchema } from "@/lib/utils/schema-utils";
import { z } from "zod";
export const todosRouter = createRPCRouter({
list: authProcedure
.meta({ rateLimit: "QUERY", acceptApiKey: true })
.route({
method: "GET",
path: "/todos/list",
tags: ["todos"],
summary: "List todos",
})
.input(z.object({ organizationId: z.string().uuid() }))
.output(actionResponseSchema(z.array(z.object({ id: z.string() }))))
.query(async ({ ctx, input }) => {
const items = await ctx.db.todos.getByOrganizationId(input.organizationId);
return { success: true, payload: items };
}),
});API Key Authentication
For procedures with acceptApiKey: true, send:
x-api-key: pk_...If you do not use API keys, authenticated browser calls can still use session cookies.
Docs Endpoints
- OpenAPI JSON:
/api/openapi.json - Docs selector page:
/api/docs - Scalar UI:
/api/docs/scalar - Swagger UI:
/api/docs/swagger
Docs pages are controlled by:
Config.Auth.DISABLE_OPENAPIConfig.Api.API_DOCS_ENABLED