API & badge¶
Most uploads should go through the CLI or its CI wrappers; this is the HTTP endpoint underneath, for anything they don't cover.
Upload¶
POST /api/v1/upload — multipart form, Authorization: Bearer <token>
| part | meaning |
|---|---|
profile |
file: the coverage profile, when there is one. Several files of one format go in repeated profiles fields instead (up to 100, the request up to 64 MB) and are merged into the upload's one report |
repo |
optional; must match the token's repo |
commit |
required commit SHA |
branch |
defaults to the repo's default branch |
pr_id |
optional pull request id |
format |
go, lcov, jacoco, cobertura, clover, simplecov, opencover or xccov; omitted → detected from content |
path_prefix |
maps profile paths to repo paths for diff coverage, e.g. the Go module path (the CLI fills it from go.mod) or the checkout directory of an OpenCover or xccov report (the CLI fills it from git) |
part |
optional; names one slice of the commit's coverage (backend, frontend, e2e, …) uploaded from a separate CI job. Normalized to a lowercase slug ([a-z0-9._-], ≤64); omitted or blank → default. Re-uploading a part replaces it. See Parts |
ignore |
optional, repeatable; a glob pattern (or a comma/newline-separated list) for files to leave out of this upload, applied on top of the repo's own patterns. At most 100 patterns of 200 characters; an invalid one is a 400. See Ignoring files |
Returns 201 with {id, total_pct, covered_stmts, total_stmts,
delta_pct, build_status, gate_failed, part, parts} — the totals and delta are the commit's merged report, part is this upload's
normalized part name and parts lists, sorted, every part the totals were merged from so far — plus
carried, the parts among parts taken from earlier commits as {part, commit, upload_id}, when the repository
carries any forward, files when the upload merged more than one coverage file, ignored_files when ignore patterns dropped any and warnings, a list of
sentences, when the commit's merged report was built with a caveat. Uploads carrying a pr_id additionally get
diff_pct, diff_covered_lines, diff_total_lines, diff_status and
pr_comment when the repo's workspace is connected to its forge.
The response also says how the commit's merged report fared against the repository's
coverage gate, in two fields. gate_failed is the one to branch on: true when the commit failed
its gate, false when it passed or the repository has no gate. gate is the same verdict in words, passed or
failed: <reasons>, and is left out when the repository has no gate. A server from before gate_failed sends only
gate; there, a verdict that starts with failed is a failed gate.
Uploads are refused with 422 when the ignore patterns, matched against this report's file paths, would cost more
work than one upload is allowed (ignore patterns are too costly to match against this report's file paths): use
fewer or simpler patterns, or shorter paths. Uploads without the Authorization header (the OIDC and tokenless
paths below) may get a 503 with Retry-After while the server is already reading many such uploads at once; retry
after the delay. Every upload must finish sending its body within two minutes.
OIDC uploads¶
A request without the Authorization header may instead carry a forge-minted OIDC identity token in an
oidc_token form part. The server verifies the token's signature against the forge's published keys and checks:
- the issuer is one it trusts (GitHub Actions, Bitbucket Pipelines, and GitLab CI — plus any self-managed GitLab issuers the operator configured);
- the audience equals this server's URL — a token minted for another audience is rejected;
- the repository claim falls under a registered workspace on that forge, and the request's own
repopart (if sent) agrees with it. A repo not yet tracked is registered by this upload, as a workspace token's first upload would register it; the workspace itself must already exist.
On success the upload proceeds like a token upload — fully verified, published through the workspace's forge
connection. Refusals are explicit: 403 oidc_bad_audience, 403 oidc_unknown_issuer, 403 oidc_repo_mismatch,
401 oidc_invalid_token, and 404 for a repo under no registered workspace. A Bitbucket token names its repository
only by id, so it is accepted only for repos in the workspace whose pipelines minted it: a repo in another
workspace, or one Bitbucket does not have, gets 403 oidc_repo_mismatch like a repo the token does not name. See
GitHub Actions.
Tokenless fork-PR uploads¶
A request without the Authorization header or an oidc_token may instead authenticate as a running GitHub Actions pull_request
workflow — the fork-PR path. It carries three extra parts, and repo,
commit (the PR head SHA) and pr_id become required:
| part | meaning |
|---|---|
run_id |
$GITHUB_RUN_ID of the workflow run doing the upload |
run_attempt |
$GITHUB_RUN_ATTEMPT |
head_repo |
the fork the PR head is on (pull_request.head.repo.full_name) |
The server verifies the claim with GitHub through the repo's App installation; the repo must be public, tracked, and
its workspace connected. Refusals are explicit: 403 with the reason, 404 for an untracked repo, 409 when the
same (run_id, run_attempt, part) already uploaded, 429 past the per-repo hourly limit. The limit counts
verifications, not uploads: the further parts of a run already verified, and a claim repeated within a few minutes,
get the same answer without counting again. It is per repo rather than per caller, so once it is reached tokenless
uploads to that repo wait for the next hour; token and OIDC uploads are never affected.
Reading a report¶
GET /api/v1/reports/{forge}/{workspace}/{repo} — a commit's merged report, for tools and coding agents: what a
change left untested, without scraping the report page. The
gocov report command calls it for you.
Without a credential it answers for repos whose reports are public (and for every repo on a
self-hosted instance without sign-in). Any private repo is read with what its upload authenticates with, sent as
Authorization: Bearer <credential>:
- the repo's upload token, or its workspace's token;
- in CI, the forge's OIDC identity token for this server, which names the repo it was minted for.
Anything else gets 404, the same 404 as for a repo that does not exist, and so does a credential for
another repo. A credential that is not one at all (an unknown token, or an OIDC token that does not verify) gets
401 or 403 with the reason, as an upload would.
| query | meaning |
|---|---|
commit |
the commit SHA, as it was uploaded |
branch |
without commit: the newest report on this branch. Without either: the repo's default branch |
pr_id |
with commit: a pull request id, to read the commit as that PR's build saw it (see below); one that did not build it changes nothing |
{
"repo": {"forge": "github", "slug": "acme/widgets"},
"commit": "7aa8f0162ab5…", "branch": "feature", "pr_id": "247",
"updated_at": "2026-10-28T08:11:36Z",
"parts": 2, "carried": [],
"coverage": 88.04, "covered_statements": 5765, "total_statements": 6550,
"gate_failed": false,
"base": {"commit": "c54dc2c0b7d6…", "coverage": 87.65}, "delta": 0.39,
"diff": {
"coverage": 82.6, "covered_lines": 19, "total_lines": 23,
"uncovered": [
{"path": "cmd/gocov/oidc.go", "lines": "49-50, 57-58", "spans": [[49, 50], [57, 58]]}
],
"unmatched_files": []
},
"report_url": "https://app.gocov.dev/uploads/1114?parts=merged"
}
- The numbers are the commit's report with every part merged;
partscounts the parts the commit has uploaded, andupdated_atis the latest upload, so poll until the parts you expect have arrived.carriedlists, as{part, commit}, the parts the repository carries forward that the commit took from an earlier one instead — they count in the numbers but not inparts, so a part still uploading is not mistaken for one that arrived. baseanddeltacompare with the report the commit is measured against, as on the report page; both arenullwhen there is nothing to compare with.diffis the diff coverage of a pull-request commit,nullotherwise.uncoveredlists only the changed files with changed lines no test ran, as the humanlinesand as inclusive[start, end]spans;unmatched_filesare changed source files the coverage data does not mention, in a language it measures.branchandpr_idname the build the answer speaks for, andreport_urlis that build's page. A commit the default branch has built stays that branch's when a PR builds it too, so by its SHA alone it reads as the default branch's build, with nodiffand the gate judged without one. Withpr_idit reads as the PR's build, as its pull-request comment did: the PR's branch and diff, and the verdict that diff gives.baseanddeltastay the commit's own either way.404also answers a commit with no report yet, or a branch with none.
Fields are only ever added: a client should ignore the ones it does not know.
MCP¶
/mcp serves the read API as a remote MCP server over Streamable HTTP, for
clients that are given a URL rather than a command to run. Coding agents
shows how to add it. It offers one tool, get_report:
| argument | meaning |
|---|---|
forge |
required: github, gitlab or bitbucket |
repo |
required: the repo slug, workspace/repo |
commit |
the commit SHA. Without it, the newest report on branch |
branch |
the branch to read the newest report on; the repo's default branch when left out |
pr_id |
with commit: a pull request id, to read the commit as that PR's build saw it, as pr_id above |
format |
text (default), the lines gocov report prints, or json, the answer above |
On an instance without sign-in it answers for every repo, to anyone. With sign-in, its client signs in first, as
the MCP authorization spec has it: a
message without an access token gets 401 with a WWW-Authenticate header that points at
/.well-known/oauth-protected-resource/mcp, which names this server as the authorization server. The client
registers itself at /mcp/register, sends its user to /mcp/authorize, where they sign in to gocov as they
always do and approve it, and exchanges the code for a token at /mcp/token, under PKCE (S256). A request
gocov cannot accept (no PKCE, a response type other than code, a foreign resource) is shown on that page with
the reason and a button back to the client; the browser never returns there by itself. The token reads
what its user may see on the report pages, the repos of their workspaces and public reports, and nothing else:
it changes nothing, and it opens no web session. It lasts 30 days, then the client signs in again.
A repo the caller may not read gets the same answer as one that does not exist. The transport keeps no sessions.
POST carries one JSON-RPC message, a notification gets 202, and GET gets 405, since it opens no stream.
Badge¶
[](https://app.gocov.dev/repos/github/myworkspace/myrepo?ref=badge)
The link lands on the repo's report page — for a public repo that is a page anyone can read;
on a private repo, visitors get the sign-in page. The path names the forge first (github, gitlab or
bitbucket), then the workspace and repo as the forge spells them: a project mirrored to two forges has two report
pages. A self-hosted instance serves the same paths from its own host. Either way there is nothing to assemble by
hand: the repo page shows the finished snippet with a copy button.
Red below 50%, yellow 50–75%, green above 75%. Shows the latest upload on the repo's default branch. Badges are served without authentication even when web UI sign-in is enabled.