# API reference

> VisualCI's CI API (builds, snapshots, finalize), its project settings, and the MCP server for everything else.

Source: https://visualci.com/docs/reference/api/
All of VisualCI's documentation: https://visualci.com/llms.txt

The CLI uses this API. Most integrations should use the CLI, which fingerprints files and uploads them for you. Coding agents use the [MCP server](https://visualci.com/docs/agents.md), which covers everything the web app does.

All requests go to `https://api.visualci.com/api/v1` with `Authorization: Bearer <project token>` (`vci_...`). Bodies and responses are JSON.

## Create a build

`POST /api/v1/builds`

```json
{
  "commit": "3f9c2e1…",
  "branch": "add-tax-breakdown",
  "pr_number": 412,
  "parent_commits": ["a81b0c4…", "77de2f9…"],
  "mode": "ci",
  "name": "default",
  "shard_total": 1,
  "subset": false,
  "nonce": null
}
```

`commit` and `branch` are required. `parent_commits` are ancestor commits, nearest first, for finding the baseline. Builds created with the same `nonce` are the same build. The response is a build (below).

## Add snapshots

`POST /api/v1/builds/{id}/snapshots`, with up to 1,000 snapshots per request:

```json
{
  "snapshots": [
    {
      "name": "invoice_typical",
      "platform": "",
      "kind": "document",
      "fingerprint": "…",
      "sha256": "…",
      "size": 48213,
      "content_type": "application/pdf"
    }
  ]
}
```

- `kind` is `document` (a PDF), `image` or `text`.
- `fingerprint` is the PDF fingerprint for documents, the pixel fingerprint for images, and the SHA-256 of the text for text. `visualci fingerprint <file>` prints the first two.
- Optional: `threshold`, `ignore_anti_aliasing`, `engine` (`pdfbox` or `mutool`), `format` (`text`, `json` or `html`; without it the content type decides).

The response lists each snapshot with an `upload_url`. PUT the file's bytes there with its `content_type`. `upload_url` is `null` when VisualCI already has the file.

## Finalize

`POST /api/v1/builds/{id}/finalize`, with an empty body or `{"shard": 0}`. VisualCI compares the build once every shard has finalized. The response is the build.

## Read a build

`GET /api/v1/builds/{id}` returns the build:

| Field | Meaning |
| --- | --- |
| `id`, `number`, `project`, `url` | Which build, and its page in the web app. |
| `state` | `receiving`, `processing`, `completed` or `failed`. |
| `conclusion` | `unchanged`, `changes` or `failed`, once completed. |
| `review_state` | `pending`, `approved`, `auto_approved` or `rejected`, or `none` for local builds. |
| `ci_mode` | The project's CI mode. |
| `passed` | Whether CI should pass under that mode. `null` while running, or while waiting for review in `wait` mode. |
| `stats` | Counts: `total`, `unchanged`, `changed`, `added`, `removed`, `ignored`, `failed`, `pending`. |
| `error` | Why the build failed, when it did. |

`GET /api/v1/builds/{id}/snapshots` lists the build's snapshots: `id`, `name`, `platform`, `kind`, `state`, `review` and `error`. Add `?state=changes` for the changed, added and removed ones, or any single state.

## Feedback

`POST /api/v1/support/feedback`: see [Support](https://visualci.com/docs/support.md).

## Project settings

Each project's settings are on its **Settings** tab, and `get_project` and `update_project` read and change them over MCP:

| Setting | Meaning |
| --- | --- |
| `default_branch` | The branch whose builds become the baseline automatically. |
| `ci_mode` | `review` (the default: CI passes and the check waits for review), `strict` (CI fails on unreviewed changes) or `wait` (`finalize --wait` waits for a review). |
| `renderer` | `pdfbox` or `mutool`, for PDFs. |
| `dpi` | Render resolution for PDFs, 36 to 600. |
| `threshold` | 0 is exact; above 0, the colour difference below which two pixels count as the same. |
| `ignore_anti_aliasing` | Skip pixels that look like anti-aliasing. |
| `ignore_rules` | Values in text snapshots that change on every run: `json_paths` (`$.generated_at`, `$.items[*].id`, `$..request_id`) and `text_patterns` (regular expressions). Matches are replaced with `[ignored]` before comparing. |
| `github_repo`, `github_installation_id` | The GitHub repository that gets VisualCI's check, and the VisualCI GitHub App's installation. |
