> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trunk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy API

> The legacy API, authenticated with the organization API token. New integrations should use the API.

> [!WARNING]
>
> The legacy API will be deprecated. Use [the API](https://docs.trunk.io/api.md) for new integrations. To move existing code, see [Migrate Merge Queue from the legacy API](https://docs.trunk.io/api/v1/migrate-merge-queue.md) and [Migrate Flaky Tests from the legacy API](https://docs.trunk.io/api/v1/migrate-flaky-tests.md).

The legacy API is at `https://api.trunk.io/v1`. Endpoint paths in this section don't include `/v1`, so add it to the base URL. For example, send `POST https://api.trunk.io/v1/submitPullRequest`.

## Authentication

Send your organization API token in the `x-api-token` header:

```bash theme={"system"}
curl -X POST https://api.trunk.io/v1/getQueue \
  -H "x-api-token: $TRUNK_ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "repo": { "host": "github.com", "owner": "my-org", "name": "my-repo" }, "targetBranch": "main" }'
```

The organization API token works only with the legacy API, and API keys don't work with it. To find or rotate the token, see [Legacy API authentication](https://docs.trunk.io/api/authentication/legacy.md).

## Request format

Most endpoints are `POST` and take a JSON body. A request body can't be larger than 20 MiB. Legacy endpoints address a repository by its coordinates, not by an ID:

| Field | Description |
| - | - |
| `repo.host` | The repository host, such as `github.com`. |
| `repo.owner` | The repository owner or organization. |
| `repo.name` | The repository name. |
| `targetBranch` | The branch the merge queue targets. Merge Queue endpoints only. |
| `pr.number` | The pull request number. Pull request endpoints only. |

Each endpoint page shows its exact fields.
