---
title: "API overview"
description: "The machine surface: base path, credentials, conventions, and the contract TRUSTIVAN keeps with a pipeline."
---

The TRUSTIVAN API is the surface a pipeline uses. Everything a person can do
from the dashboard is available here, subject to the scopes granted to the
credential presenting the request.

## Base path

Every documented endpoint lives under `/api/v1`, relative to the origin your
deployment is served from.

```bash
curl -s https://app.trustivan.com/api/v1/findings?order=recent \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

Two endpoints sit outside that prefix, deliberately: `GET /health` and
`GET /ready`. They are operational probes rather than product surface, they
take no credential, and they are described in
[Endpoints](/api-reference/endpoints).

## The two credentials

| Mechanism | Who holds it | Ambient | CSRF header |
|---|---|---|---|
| `Authorization: Bearer twk_…` | machines | no | not required |
| `trustivan_session` cookie | the dashboard | yes | required on unsafe methods |

These are not two spellings of the same thing. A cookie is ambient (the
browser attaches it to any request to this origin, including one a hostile page
caused), and therefore needs a header no other origin can produce. An API key
is not ambient: nothing attaches it for you, so it needs no such ceremony.
[Authentication](/api-reference/authentication) sets out the whole
mechanism, including why an API key is never honoured from a cookie.

A machine principal has **no role**. Its authority is exactly the set of scopes
its credential was granted, and nothing else. See
[Scopes](/api-reference/scopes).

## What the API is built for

The flow the machine surface exists to serve is a build deciding whether to
ship:

```text
POST /scans                     request a scan, with an idempotency key
GET  /scans/{id}                poll until the status is terminal
POST /scans/{id}/verdict        ask the policy whether this passes
```

Enumeration (walking a backlog, reconciling state, exporting findings) is the
second flow:

```text
GET  /findings?order=recent     cursor-paginated, exhaustive traversal
POST /findings/bulk             one action across up to 500 findings
```

Reading posture is the third: grades (`GET /stats/grades`,
`GET /assets/{id}/grade`), where an image runs (`GET /assets/{id}/runtime`),
the check catalogue (`GET /catalogue/checks`), signed evidence packs
(`/compliance/evidence-packs`) and the certificate inventory (`/certificates`).

The [`trustivan` CLI](/cli-reference/trustivan) wraps the first flow
(`trustivan gate`) and serves a subset of all three to an AI assistant
(`trustivan mcp`, see [MCP server](/integrations/mcp-server)). Everything else
is `curl` against a scoped key, which is why every example in this reference is
one you can paste into a shell.

## Conventions

**Content type.** Request bodies are `application/json`. Responses are
`application/json`, including error responses.

**Identifiers** are UUIDs. A path identifier that is not a well-formed UUID is
a `400`; one that is well formed but names nothing you may see is a `404`,
and so is one that belongs to another organisation, byte for byte. The
reasoning is in [Errors and limits](/api-reference/errors).

**Listings** are cursor-paginated on every high-volume collection, and report
whether their ordering guarantees an exhaustive traversal. See
[Pagination](/api-reference/pagination).

**Retries** are made safe by an `Idempotency-Key` on the two endpoints that do
expensive or irreversible work. See
[Idempotency](/api-reference/idempotency).

**Errors** are always `{"error": "…", "code": "…"}`: a sentence for a person and
a stable token for a program. A `403` from a scope check carries two
extra fields so a client can report which scope was missing rather than
"forbidden". See [Errors and limits](/api-reference/errors).

## Results live in the body, not the status line

Two endpoints make this explicit, and both are ones a pipeline branches on.

`POST /scans/{id}/verdict` returns `201` when it records a decision and `200`
when it replays one. A **failing** verdict is still a successful request. A
pipeline that treated a policy failure as an HTTP error could not distinguish
"the build should stop" from "TRUSTIVAN is unreachable", and those two demand
opposite reactions: the first fails the build, the second retries. Branch on
`blocking` in the body.

`POST /findings/bulk` returns `200` whenever the request itself was valid, even
when individual items were rejected. `207 Multi-Status` is a WebDAV code most
HTTP clients treat as an error, so the per-item outcomes are counted in the
body instead.

## What this API does not do

Stated plainly, because a security product that is vague about its boundary is
worse than one with a narrow boundary:

- **No scan of a virtual machine image.** A *scan* subject is a container
  image, a Git repository, or (where the operator has permitted a directory) a
  filesystem path or an SBOM document; infrastructure-as-code in a repository or
  filesystem is checked when the misconfiguration scanner is on
  ([IaC scanning](/configuration/iac-scanning)). Connecting a cloud account or a
  Kubernetes cluster is a different operation, and each collection checks what
  it read: see `cloud` and `kubernetes` below, and
  [Cloud and Kubernetes](/configuration/cloud-and-kubernetes).
- **Organisation management is human-only.** Creating, renaming, exporting and
  deleting an organisation all exist under the `orgs` tag, and none of them is
  reachable with an API key: `organization:manage` and `organization:delete`
  are both ungrantable, so each needs a browser session.
- **Billing is read-mostly plus two redirects.** `/api/v1/billing` reports the
  tenant's entitlements and the plan catalogue. With a payment provider
  configured, `POST /billing/checkout` and `POST /billing/portal` mint a URL at
  the provider and write nothing; the plan itself changes only when the
  provider reports the purchase over a signature-verified webhook. With
  `BILLING_PROVIDER=manual`, the default, both answer that the deployment does
  not sell.
- **`POST /github/webhook` verifies the signature and records the pull
  request.** A background task then asks GitHub for what it needs and queues
  the scans, for repositories with checks turned on. See
  [Pull request checks](/integrations/pull-request-checks).

## Where to go next

- [Authentication](/api-reference/authentication): credentials, their
  lifecycle, and rotation.
- [Scopes](/api-reference/scopes): what a key may be granted, and what
  it may never be granted.
- [Endpoints](/api-reference/endpoints): the complete route list.
