API reference

The CLI uses this API. Most integrations should use the CLI, which hashes files and uploads the new ones for you. Coding agents use the MCP server, which covers everything the web app does.

All requests go to https://api.visualci.com/api/v1 with Authorization: Bearer <project token> (vci_...), or a personal access token (vcu_...) where it says so. Bodies and responses are JSON. A body with a field the endpoint doesn't take is refused (422, naming the field and the ones it takes), so a misspelt field never passes unnoticed. The MCP server's tools do the same. Numbers may be sent as JSON numbers or as strings holding them ("2").

Create a build

POST /api/v1/builds

{
  "commit": "3f9c2e1…",
  "branch": "add-tax-breakdown",
  "pr_number": 412,
  "base_branch": "main",
  "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: the build compares with the approved build of the nearest one. base_branch is the branch a pull request merges into: without an approved build in the history sent, the build compares with that branch's newest approved build, and with the default branch's when it names none or that branch has none. Only an approved build is ever compared with. Builds created with the same nonce are the same build. config is the repository's visualci.yml as JSON: its fields override the project's settings for this build, and a build with an invalid one is refused. The response is a build (below).

Add snapshots

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

{
  "snapshots": [
    {
      "name": "invoice_typical",
      "platform": "",
      "kind": "document",
      "fingerprint": "…",
      "sha256": "…",
      "size": 48213,
      "content_type": "application/pdf"
    }
  ]
}
  • kind is document (a PDF), image or text.
  • sha256 is the SHA-256 of the file's bytes. fingerprint is optional: 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). Without it, VisualCI uses the fingerprint it computed for the file before, or computes it once the file is uploaded. The CLI sends images by their hash alone and lets VisualCI fingerprint them, and sends each PDF's fingerprint: a PDF's bytes change on every run (its creation date and ID) while what it draws doesn't, so without the fingerprint every PDF would be uploaded on every run.
  • Optional: threshold, ignore_anti_aliasing, engine (pdfbox or mutool), format (text, json or html; without it the content type decides), ignore ({"json_paths": [...], "text_patterns": [...]}, set in the test, for this snapshot only).

The response lists each snapshot with an upload_url. PUT the file's bytes there with its content_type, within 15 minutes (register again for a fresh link). upload_url is null when VisualCI already has the file. A file can be at most 64 MiB, and its bytes must match its sha256: anything else is discarded and reported missing.

A test that crashed before it wrote its file sends the snapshot with error and no file: {"name": "invoice_typical", "kind": "document", "error": "AttributeError: ..."} (kind defaults to document; leave out sha256, size and content_type). The build shows the snapshot as failed with that error, under its own name, instead of removed, and the build fails. The error is at most 16 KB. The last approved version stays the baseline.

A name (with its platform) is one snapshot per build. Registering it again with the same file is fine (a retried job does), but other content under a name already in the build is refused with 409 Conflict naming the snapshot: names must be unique across a build's jobs and shards.

Send many files as one bundle

When a request's snapshots need many new files (the CLI does this past 200), send them as one bundle instead of a PUT each:

  1. POST /api/v1/builds/{id}/bundles with each file's SHA-256 and size, and the bundle's size:

    { "files": [{ "sha256": "…", "size": 48213 }], "compressed_size": 1830211 }
    

    The answer is {"id": "…", "upload_url": "…"}.

  2. PUT the bundle to upload_url within 15 minutes. The URL takes exactly compressed_size bytes.

  3. POST /api/v1/builds/{id}/bundles/{bundle id}/complete. The answer is {"id": "…", "state": "uploaded"}.

Both requests are safe to retry. Declaring the same files and size again before completing returns the same bundle with a new URL, and completing it again answers with its state. A bundle not completed within an hour expires, and completing it then answers 409.

A bundle is a tar archive compressed with zstd (.tar.zst). It holds one regular file per declared file, named by its SHA-256 alone, with no folders. The rules:

  • At most 1,000 files and 1 GiB unpacked, each file at most 64 MiB, and each one the file of a snapshot registered in this build.
  • compressed_size can't be more than the files could take: their sizes, plus 1,536 bytes a file, plus 64 KiB.
  • VisualCI checks the whole bundle before it stores anything. Every file must be one it declared, of its declared size, with bytes matching its SHA-256, and every declared file must be there. Links, folders, devices and paths outside are refused.
  • A file can be in only one open bundle of a build: declaring a different bundle with a file an open one holds answers 409.
  • A bundle that breaks any rule stores nothing, and the build fails with the reason.
  • The build waits for its bundles once it's finalized.

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. A build that was sent no snapshots fails; send "allow_empty": true when it's empty on purpose, or "empty_reason": "inputs unchanged", which implies it and puts the reason in the build's summary with the build its baseline came from. A CI subset build finalized empty this way passes on its baseline only when the branch's last build of the suite is approved or had nothing to approve; while that build is being compared, waiting for review, rejected or failed (or superseded by a review that wasn't an approval), the empty build shows its result, with a warning naming it, and follows it.

Abort

POST /api/v1/builds/{id}/abort, with {"message": "uploading snapshots failed: 409 Conflict"} or an empty body, when the CI job sending the build fails and won't finalize it. A build still receiving fails at once, with error_code aborted and the error "The CI job sending this build failed, so VisualCI closed it:" followed by your message (trimmed, at most 1,000 characters), or by "the CI job stopped before visualci build finalize" without one. Its check and pages follow. A build that's already processing, completed or failed is left as it is, so calling it again is safe. The response is the build. It takes the same tokens as finalize. Every shard and job sends to the same build, so one job's abort closes it for all of them: the others' later uploads are refused with a message saying to re-run the CI job.

A CI build that's never finalized or aborted times out once nothing has arrived for it for the project's receive_timeout_minutes (60 by default), counted from its last upload, or from its creation before the first one: it fails with error_code timed_out, the error "Timed out: no uploads for 60 minutes, so VisualCI closed this build…", and its GitHub check completes as timed out. A timed-out build isn't charged. A later empty rerun of the suite can still finalize an aborted or timed-out build and follow it.

Keep a build open

POST /api/v1/builds/{id}/alive, with an empty body, when the job is still working on the build but hasn't anything to send yet (a long test suite that uploads at the end): the receive timeout counts from now. A build that isn't receiving is left as it is. The response is the build. It takes the same tokens as finalize. visualci test calls it every 5 minutes while its test command runs.

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.
error_code What kind of failure: timed_out (nothing arrived for the project's receive timeout), aborted (its CI job closed it), out_of_credits, config_invalid or bundle_refused. null otherwise.
blocked Set when the build can't be compared because the organization is out of credits: reason (out_of_credits), credits_used, credits_limit, pack_credits, renews_at, fixes (each an action such as upgrade, buy_pack or turn_on_auto_buy, a label and the billing url) and message, one line to show a person. On a build still receiving files too. resolved: true once the organization has credits again.

Follow a build

GET /api/v1/live/builds/{id} follows the build as server-sent events instead of polling. The first event, snapshot, is the build as GET /api/v1/builds/{id} returns it now, so a client that connects after the build finished has the result at once. Each build event after that is the build again after it changed. A comment arrives every 15 seconds while nothing changes. The stream ends after 30 minutes: connect again, and the new stream starts with a snapshot. Too many open streams get a 429 with Retry-After; poll GET /api/v1/builds/{id} meanwhile. Personal tokens and MCP clients' OAuth tokens may follow any build of their organizations' projects.

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.

Download a build's images

POST /api/v1/builds/{id or number}/downloads with a filter (all fields optional) puts the build's images in one tar.zst:

Field Meaning
state Which snapshots: changed (the default), added, removed, unchanged or all.
sides Which images of each page: base, head, diff, regions (the head cropped to the changed regions). Default: base, head and diff.
glob Only snapshots whose name matches, like v2/pdfjs/**.

The response is the download: id, state (pending, building, ready or failed), and once it's ready a url to the archive (it lasts an hour), files, bytes and a summary (how many snapshots of each state, the first names). While it's pending or building, progress says how far the archive has got ({"files": 120, "total": 1200}; total is null until it's counted), and it's null once the download is ready or failed. GET /api/v1/downloads/{id} reads it again until it's ready. The same build and filter within the hour return the same download. An archive over 2 GB stops with an error that suggests a narrower glob. Downloads are free.

The archive holds <name>[@platform][/page-N]/{base,head,diff,regions}.png and manifest.json, which lists each snapshot's name, platform, state, path and pages (changed fraction, regions and files).

POST /api/v1/versions with {"version": "v2.0.0", "commit": "<sha>", "parent_commits": ["<sha>", …]} records what the project's gallery published at that commit as a version: the answer is {"key", "label", "commit", "released_at", "manifest"}, 201 when it's recorded, 200 when the same version was recorded at that commit before. A version that isn't up to 64 letters, digits and ._+- (or is latest) is a 400, the same version recorded at another commit a 409, and a commit the gallery published nothing at a 422, as is a new version once the project has 500. GET /api/v1/versions lists the project's versions, newest first, as {"versions": [...]}.

Organizations

GET /api/v1/organizations/{org} returns the organization as MCP's get_organization does: its projects with each one's latest build, its plan and credits used this month, and (for a personal token) its members. A project token sees its own project and the plan and usage, not the members or the other projects.

PATCH /api/v1/organizations/{org} changes its name or slug, with a personal access token (vcu_...) of one of its admins; a project token is refused (403).

{ "name": "Acme Ltd", "slug": "acme-hq" }

Both fields are optional, and one left out stays as it is. The answer is the organization, as the GET returns it. A new slug renames the organization, as its settings page does: the old slug keeps working, so links to its pages and galleries redirect to the new one, and the API, MCP and tokens accept project names with either. {org} may be the old slug too. Errors are the settings page's: 403 for a member who isn't an admin, 422 for a slug that isn't lowercase letters, digits and dashes or is a reserved word (such as api), or a name that isn't 1 to 100 characters, and 409 for a slug another organization has or had. MCP's update_organization does the same.

Feedback

POST /api/v1/support/feedback: see Support.

Project settings

Each project's settings are on its Settings tab, and get_project and update_project read and change them over MCP. They're defaults: a build's visualci.yml overrides them field by field.

Setting Meaning
slug The project's slug, in its address and in org/slug. Changing it renames the project; its builds, baselines and tokens stay, and the old address and org/old-slug stop working.
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).
receive_timeout_minutes How long a CI build may go without an upload before VisualCI closes it as timed out, 10 to 360 minutes (60 by default). Its CI job most likely stopped before finalizing. Local builds aren't affected: they're compared as a subset after an hour.
approvers_mode Who reviews (approves, rejects, accepts variants, ignores changes): except (the default: every member with Write or Admin except cant_approve) or only (only approvers). Admins change it; see Who can approve. A change that would leave nobody able to approve is refused.
cant_approve GitHub or GitLab logins of members (admins too) who can't review in this project, for except mode. Replaces the list.
approvers Logins, and GitHub teams as @org/team, who review in only mode. Replaces the list.
tokens_can_approve Whether the project's tokens may approve, accept variants and ignore changes (off by default: tokens upload, reject and comment, and people approve).
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: a list of {snapshots, json_paths, text_patterns}. snapshots is a required glob over snapshot names (api/invoices/**, or ** for every snapshot), json_paths are like $.generated_at, $.items[*].id or $..request_id, and text_patterns are regular expressions. Matches are replaced with [ignored] before comparing.
repository_url The repository the project tests (https://github.com/owner/repo); an empty string unlinks it. Linking needs the VisualCI GitHub App installed on the repository and you to be its admin or maintainer. Its pull requests then get VisualCI's check, and access to the organization follows people's permission on it. The settings also show forge and forge_app_installed.