Requires a credential holding scans:create and scans:read.

Queue it

202 is work accepted, not work done. 200 means an existing scan was returned instead, which is how a client tells a deduplicated retry from a new scan. The two look the same in the body, so branch on the status here. The image reference is untrusted input and is validated at the boundary. Private and link-local registries, embedded credentials, URL schemes and traversal segments are all refused with a message naming the rule. TRUSTIVAN pulls remotely from the registry. A registry that requires a login needs a credential stored against its host (see Scan an image from a private registry), and the scan carries a reference to it, never the secret itself.

Make the retry safe

Idempotency-Key is a header, or idempotency_key in the body. Use something your pipeline already has and will reproduce on a retry (a build ID, a job ID), not a random value. The key is reserved before any work begins, so two concurrent retries cannot both queue a scan. A completed request replays its stored response verbatim with Idempotent-Replay: true. Reusing the same key with a different body is 409, never a replay: returning the first response would tell you that work succeeded which was never attempted. Records are kept for 30 days.

Poll to a terminal state

Terminal statuses are succeeded and failed. Anything else means keep polling. Two seconds between attempts is reasonable; give the loop a ceiling, because pulling and unpacking a large image takes minutes and an unbounded poll loop is a build that hangs rather than one that reports a problem. A retryable failure returns the scan to queued rather than reporting failed, so a failed status is genuinely terminal.

Check database_state before you trust the result

It reports how fresh the advisory data behind the result was. A scan run against stale data reports “no vulnerabilities” with exactly the same confidence as a correct one, which is why the age is surfaced rather than hidden, and why a sufficiently old database fails the scan outright instead of producing a clean-looking report.

Scan something other than an image

image is shorthand for a container image. For anything else, send kind and target:
Four things to know before you rely on this:
  • ref is not part of the asset’s identity. A repository scanned on two branches is one asset with one backlog.
  • scanners narrows or widens one request. The names are vulnerability, secret, misconfiguration, license, sbom, sast and quality. One the deployment’s engine cannot run is refused. misconfiguration, sast and quality need the operator setup in IaC scanning, Static analysis and Code quality.
  • A filesystem or SBOM path must sit inside your own organization’s directory under a scan root the operator configured. A deployment with no scan root refuses both kinds. To add a supplier’s bill of materials without one, import it instead.
  • A private repository needs a stored credential. See Scan a private repository.
The contract also names vm and cloud_account. No shipped engine scans either; a cloud account is connected and collected, not scanned. See Cloud and Kubernetes.

Gotchas

  • Concurrency is capped per tenant (default 4). Work over the cap stays queued; nothing is dropped, but a burst of scans will not all start at once.
  • findings_total of zero on a real image is a signal, not a result. Check database_state and the scan’s recorded scanners before believing it.
  • A 404 on the scan means “no such scan, or not yours”. The two are byte-identical on purpose.
  • Defaults differ by target kind. A repository scan runs vulnerability, secret and SBOM scanning by default; a container image scan runs vulnerability scanning only. Rather than passing other scanners (static analysis, misconfiguration, secrets for images) per request, set them once for a target kind with PUT /api/v1/settings/scanners/{kind}, or for repositories in Settings → Data and evidence → Repository scanners; their findings appear in the dashboard like any other. Licences need no scanner at all. Read them from /api/v1/licenses.

See also