# api

Authorized operations and shared contracts: responsibilities, supported exports and extension points.

## Purpose [#purpose]

The server defines oRPC procedures, domain routers, the assistant/MCP catalog and scheduled jobs. Public schema subpaths validate wire data; `client` exports only the router client type.

## Public exports [#public-exports]

| Subpath                          | Target                                  |
| -------------------------------- | --------------------------------------- |
| `./client`                       | `./src/client.ts`                       |
| `./rpc-scope`                    | `./src/rpc-scope.ts`                    |
| `./context`                      | `./src/context.ts`                      |
| `./routers/index`                | `./src/routers/index.ts`                |
| `./routers/admin.schema`         | `./src/routers/admin.schema.ts`         |
| `./routers/audit.schema`         | `./src/routers/audit.schema.ts`         |
| `./routers/flags.schema`         | `./src/routers/flags.schema.ts`         |
| `./routers/todo.schema`          | `./src/routers/todo.schema.ts`          |
| `./routers/proposals.schema`     | `./src/routers/proposals.schema.ts`     |
| `./routers/integrations.schema`  | `./src/routers/integrations.schema.ts`  |
| `./routers/billing.schema`       | `./src/routers/billing.schema.ts`       |
| `./billing-plans`                | `./src/lib/billing-plans.ts`            |
| `./billing/web-http`             | `./src/billing/web-http.ts`             |
| `./mcp/server`                   | `./src/mcp/server.ts`                   |
| `./mcp/context`                  | `./src/mcp/context.ts`                  |
| `./mcp/protocol`                 | `./src/mcp/protocol.ts`                 |
| `./mcp/guard`                    | `./src/mcp/guard.ts`                    |
| `./webhooks/events`              | `./src/webhooks/events.ts`              |
| `./jobs/run`                     | `./src/jobs/run.ts`                     |
| `./uploads/workflow`             | `./src/uploads/workflow.ts`             |
| `./routers/imports.schema`       | `./src/routers/imports.schema.ts`       |
| `./ai/http`                      | `./src/ai/http.ts`                      |
| `./routers/assistant.schema`     | `./src/routers/assistant.schema.ts`     |
| `./ai/catalog.schema`            | `./src/ai/catalog.schema.ts`            |
| `./routers/documents.schema`     | `./src/routers/documents.schema.ts`     |
| `./documents/lifecycle-plugin`   | `./src/documents/lifecycle-plugin.ts`   |
| `./routers/links.schema`         | `./src/routers/links.schema.ts`         |
| `./routers/links.window`         | `./src/routers/links.window.ts`         |
| `./links/image`                  | `./src/links/image.ts`                  |

These paths come from `packages/api/package.json`. A `.` entry is the package root. Conditional targets distinguish platform or type resolution; consumers should import the subpath, not its source file.

## How to extend [#how-to-extend]

Add the operation to a feature router and register it in the root router. Keep authorization in the procedure and resource scope in the query. Add a specific schema export when another package needs the contract. For AI/MCP tools, extend the single catalog after reading ADR-0007.

Read the [authorized operations and shared contracts guide](/docs/features/api) for the full flow.

## Key files [#key-files]

- [`packages/api/package.json`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/packages/api/package.json)

