# API reference

> Every BareCI tool, over MCP and the /v1 JSON API: 31 tools in 8 groups, with arguments, answers, routes and scopes.

Source: https://bareci.com/docs/api

BareCI takes a pull request from its first push to its merge: CI on fast machines, tests from an agent's worktree, previews, AI end-to-end Flows, every reviewer's findings in one list, and one answer to "is this ready to merge?". Agents use it over MCP, a CLI or the /v1 JSON API.

## Connecting

- **MCP:** `https://api.bareci.com/mcp`, Streamable HTTP. See [MCP setup](https://bareci.com/docs/agents/mcp).
- **HTTP:** the `https://api.bareci.com/v1` JSON API. Errors are `{error, hint}` with an HTTP status.
- **Auth:** `Authorization: Bearer bci_…`, an agent token scoped to one organisation with some of `read`, `run` and `operate`. Get one with `bareci login`.
- **Live browser tools** (`browser_*`) run where the browser is: the local MCP server `bareci mcp`.

## How an agent uses it

BareCI runs an agent's code before merge. Typical loop for a pull request:

1. run_create to test the worktree on a BareCI machine (upload the worktree to the URL it answers with), then run_logs until done.
2. After pushing, ready answers whether the PR may merge and names the fix for each reason it may not.
3. findings lists every reviewer's open findings; fix or dispute each, then finding_resolve.
4. flows_run tests the PR's preview with the repository's Flows.
Every result carries `next`: the next action, usually a tool and its arguments. Errors carry a hint.


## Tool groups

| Group | Tools | What it covers |
| --- | --- | --- |
| [Account](https://bareci.com/docs/api/account) | `whoami`, `account_get`, `account_usage`, `repo_settings` | Who you are, your organisation's spend and cap, and repository settings. |
| [Runs](https://bareci.com/docs/api/runs) | `run_create`, `run_get`, `run_logs`, `run_cancel`, `run_artifacts` | Run any command from your worktree on a fresh BareCI machine, and stream its output. |
| [Tests](https://bareci.com/docs/api/tests) | `tests_flaky`, `tests_slowest`, `tests_shard` | Flaky and slow tests from every job and run, and duration-balanced shards. |
| [Previews](https://bareci.com/docs/api/previews) | `previews_list`, `preview_get`, `preview_stop`, `previews_close` | The change running at its own URL, until its TTL, the next push or the merge. |
| [Flows](https://bareci.com/docs/api/flows) | `flows_run`, `browser_start`, `browser_act`, `browser_snapshot`, `browser_stop`, `browser_sessions` | AI end-to-end tests in plain language, recorded and replayed with no model in CI, and a live browser to write them. |
| [Reviews](https://bareci.com/docs/api/reviews) | `findings`, `findings_refresh`, `finding_resolve`, `reviews_request`, `review_config` | Every reviewer's findings in one list; fix or dispute each, and BareCI answers the reviewer. |
| [Gate](https://bareci.com/docs/api/gate) | `ready`, `change_get` | One answer to "is this ready to merge?", with every reason it is not yet. |
| [Runners](https://bareci.com/docs/api/runners) | `job_explain`, `insights` | GitHub Actions jobs on BareCI machines: why a job waits, and how the pools do. |

The reference is generated from the same catalogue that defines the MCP tools, so the two cannot drift.
