# API overview

> The HTTP API of adTraces, compatible with the traces.com v1 API.

Base URL: `https://adtraces.adfactory.app`. The machine-readable description is at [`/openapi.json`](https://adtraces.adfactory.app/openapi.json).

## Authentication

Send `Authorization: Bearer <token>` where the token is an API key (`trk_...`) or a CLI device token. Keys are bound to one namespace and carry scopes: `traces:read`, `traces:write`, `namespace:read`, `surfaces:write`. See [Sharing via API key](/docs/sharing/api-key).

## Responses

Every JSON response uses one envelope:

```json
{ "ok": true, "data": { } }
{ "ok": false, "error": { "code": "forbidden", "message": "Missing required scope: traces:write", "details": { "requiredScope": "traces:write" } } }
```

Common codes: `unauthorized` (401), `forbidden` (403), `not_found` (404), `conflict` (409), `payload_too_large` (413), `invalid_request` (400), and 429 with a `Retry-After` header when rate limited.

## Endpoints

| Area | Endpoints | Page |
| --- | --- | --- |
| Namespaces | `GET/POST /v1/namespaces`, `GET /v1/namespaces/{slug}`, members, invites | [Namespaces](/docs/api/namespaces) |
| Traces | `/v1/traces`, `/v1/traces/{externalId}`, transfer, `/v1/namespaces/{slug}/traces` | [Traces](/docs/api/traces) |
| Messages | `/v1/traces/{externalId}/messages`, `.../batch`, `.../{messageId}` | [Messages](/docs/api/messages) |
| Surfaces | `/v1/surfaces`, `/v1/surfaces/{key}`, uploads, `/v1/pinned-surfaces` | [Publishing surfaces](/docs/surfaces/publishing) |
| Session and login | `/v1/session`, `/v1/session/switch`, `/v1/auth/providers`, `/v1/auth/cli/*` | used by the CLI |
| Download | `GET /api/v1/traces/{id}/download?format=jsonl` or `markdown` | |
| Health | `GET /api/health` | no authentication |
| MCP | `POST /mcp` | [MCP](/docs/mcp) |

Paths under `/v1` and `/api` are excluded from search engines in `robots.txt`.
