# API reference

> Every operation you can call with an API key, with curl and TypeScript examples, generated from the OpenAPI document.

The Taggor API is a REST API over HTTPS at `https://api.taggor.dev`. These pages are generated from its OpenAPI document, so every operation, parameter and field is the one the API has. This reference lists the 106 operations you can call with an API key. The document itself is at [https://api.taggor.dev/v1/openapi.json](https://api.taggor.dev/v1/openapi.json).

## Operations

| Page | What it covers | Operations |
| --- | --- | --- |
| [Components](https://taggor.dev/docs/reference/api/components.md) | Create, list, update and archive components, and the shared folders they use. | 18 |
| [Versions and channels](https://taggor.dev/docs/reference/api/versions.md) | Publish immutable versions and move the staging and production channels. | 13 |
| [Builds](https://taggor.dev/docs/reference/api/builds.md) | Read the state, logs and errors of a build. | 5 |
| [Sites](https://taggor.dev/docs/reference/api/sites.md) | Sites, their snippets, domains, attached components and server keys. | 20 |
| [Data](https://taggor.dev/docs/reference/api/data.md) | Collections, submissions and their e-mail notifications. | 10 |
| [Metrics](https://taggor.dev/docs/reference/api/metrics.md) | What the components did on your sites. | 5 |
| [Usage and billing](https://taggor.dev/docs/reference/api/usage-and-billing.md) | Plan limits, usage, overage and the spending limit. | 4 |
| [Clients](https://taggor.dev/docs/reference/api/clients.md) | The clients of an agency workspace. | 5 |
| [Workspaces and members](https://taggor.dev/docs/reference/api/workspaces.md) | Workspaces, members and invitations. | 2 |
| [API keys](https://taggor.dev/docs/reference/api/api-keys.md) | The API keys of a workspace and their scopes. | 3 |
| [Session and permissions](https://taggor.dev/docs/reference/api/session.md) | Who the caller is acting as and what they may do. | 2 |
| [Marketplace](https://taggor.dev/docs/reference/api/marketplace.md) | Bundles, acquisitions, releases, reviews and the publisher profile. | 19 |

## Authentication

Send an API key of your workspace as a bearer token. A person creates API keys in the portal; a key acts in its workspace with the scopes it was created with, and each operation below lists the scopes it needs.

```http
Authorization: Bearer $TAGGOR_API_KEY
```

A request with no valid key gets `401` (`unauthenticated`). A key without the scope an operation needs gets `403` (`insufficient_scope`), and the answer lists the `missing_scopes`. Keep keys out of code that runs in a browser or is committed to a repository.

## Requests and responses

Requests and responses are JSON (`Content-Type: application/json`), and field names are `snake_case`. Ids are opaque strings with a prefix that names the kind (`cmp_` for a component, `ver_` for a version, `bld_` for a build, `site_` for a site).

## Pagination

A list takes `limit` (the page size, 1 to 100 unless the operation says otherwise) and `cursor`. The answer holds `data`, the items, and `next_cursor`: pass it as `cursor` to get the next page, with the same filters. `next_cursor` is `null` on the last page. The cursor is opaque; do not build one.

```json
{
  "data": [],
  "next_cursor": "opaque-cursor"
}
```

## Idempotency

Makes a retry safe: the first response under this key is stored for 24 h and the same request with the same key gets it again (with `Idempotent-Replayed: true`) instead of running twice. 1 to 255 visible ASCII characters; use a fresh UUID per logical request. 5xx responses are not stored, so a retry after one runs again. An operation that accepts the `Idempotency-Key` header lists it in its parameters.

## Rate limits

Each request counts against the limit of its route class (read, write, publish, heavy, approval, diff, metrics or ip). Responses carry two headers:

- `RateLimit-Policy`: The limit of the route class, e.g. `"read";q=600;w=60` (q requests per w seconds). A destructive call by a key or token (a delete, an archive, a disable) also lists the `destructive` limit: `"write";q=120;w=60, "destructive";q=10;w=60`.
- `RateLimit`: Your own budget in that class, e.g. `"read";r=599;t=42`: an estimate of the requests left (r) and the seconds to the window reset (t); the 429 is the authority. A destructive call by a key or token also lists the destructive calls left, counted exactly, and the seconds until one comes back: `"write";r=119;t=60, "destructive";r=9;t=60`.

When a limit is reached the API answers `429` with the `rate_limited` code and a `Retry-After` header: wait that many seconds, then try again.

## Errors

Every error is an [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) `application/problem+json` document. Branch on `code`, which is stable; quote `request_id` when you ask for help. `hint` says what to do next and `docs_url` opens the page of the code in [the error reference](https://taggor.dev/docs/errors.md). A `400` with `validation_failed` lists each invalid field in `errors`.

```json title="A problem document"
{
  "type": "https://docs.taggor.dev/errors/validation_failed",
  "title": "Request validation failed",
  "status": 400,
  "detail": "1 invalid field: body /scopes/0. See errors[].",
  "instance": "/v1/api-keys",
  "code": "validation_failed",
  "hint": "Fix each field listed in errors[] (location and JSON Pointer) and send the request again.",
  "docs_url": "https://docs.taggor.dev/errors/validation_failed",
  "request_id": "3fc92ed2-a3a5-4a34-bb85-849d26ef4633",
  "errors": [
    {
      "location": "body",
      "path": "/scopes/0",
      "code": "invalid_value",
      "message": "Invalid option: expected one of \"components:read\"|\"components:write\"|…"
    }
  ]
}
```
