DocsAPI ReferenceSBOM Import API

SBOM Import API

Upload the SBOM your CI pipeline produces (CycloneDX or SPDX JSON) so its components feed the software inventory and the vulnerability matcher.


Endpoint

POST /api/v1/software/sbom/ receives the SBOM document as the raw request body (no envelope). Accepted Content-Type values: application/json, application/vnd.cyclonedx+json and application/spdx+json (any other type gets 415). The body may be gzip-compressed with Content-Encoding: gzip. The target of the SBOM is passed in the query string. Every component is stored with origin=sbom and its package URL in details.purl, so it shows up in Components (filter origin=sbom) and is evaluated by the vulnerability matcher like the components reported by the agent.

curl -X POST "https://idp.example.com/api/v1/software/sbom/?asset_uid=dc-01:server:web-01" \
  -H "Authorization: Token $IDP_API_TOKEN" \
  -H "Content-Type: application/vnd.cyclonedx+json" \
  --data-binary @sbom.cdx.json

# Response
{
  "target": { "asset_uid": "dc-01:server:web-01" },
  "format": "cyclonedx",
  "spec_version": "1.5",
  "assets": 1,
  "created": 412,
  "updated": 1870,
  "removed": 9,
  "discarded": 37
}

Authentication

Use an API token with the write:sbom scope (see API Tokens, /docs/api/api-tokens): an admin creates it under API Tokens with a new service account as owner (the service account gets the manager role because write:sbom is a write scope) and stores the value once as a masked CI secret, e.g. IDP_API_TOKEN. The job sends it as Authorization: Token <value>: no password login, no MFA, no personal credentials. The token can only upload SBOMs: the same token on GET /api/v1/security/findings/ or any other endpoint gets 403. The owner must be a manager or admin (401 without a valid token, 403 with a viewer owner or without the write:sbom scope).

Note: The JWT of a manager or admin user (Authorization: Bearer <access>) is still accepted, e.g. for a one-off manual upload, but do not use a personal account or a password login in pipelines. Give each pipeline its own token with an expiry and revoke it when the pipeline is retired.

# IDP_API_TOKEN: masked CI secret holding the idpt_... value (shown once at creation)
curl --fail-with-body -X POST "$IDP_URL/api/v1/software/sbom/?asset_uid=$IDP_ASSET_UID" \
  -H "Authorization: Token $IDP_API_TOKEN" \
  -H "Content-Type: application/vnd.cyclonedx+json" \
  --data-binary @sbom.cdx.json

Target

Pass exactly one of the two query parameters (400 when both or none are given):

  • asset_uid=<uid>: an active asset (404 otherwise). The components are stored on that asset with path=sbom.
  • image_digest=sha256:<64 hex> (or sha512:<128 hex>): the image build. The components are stored on every asset currently running that digest (the host of a running container, or the pod itself) with path=image:<digest> and details.image_ref / details.image_digest, exactly like the Trivy image components: findings carry the image, the image filter and the actionable (third-party) classification apply.

Note: With SECURITY_IMAGE_FINDINGS_SOURCE=trivy the SBOM components of an image are still evaluated by the OSV matcher, so a CVE found by both Trivy and the SBOM can appear twice (source trivy and source osv).

Warning: An image_digest SBOM is accepted only while the image is running: with no running asset the upload gets 404 ("no running asset") and the components already stored for that digest stay as they are. Upload it after the deploy, or target the host with asset_uid. The running container appears in the inventory only after the agent or relay has reported it (its next collection after the deploy), so the CI examples below retry on 404 for a few minutes. A new SBOM for a digest also clears (is_present=false) the components of that digest on hosts that no longer run it; assets in the response counts only the assets that run it.

Formats and limits

Only JSON documents are accepted (no XML, no SPDX tag-value, no multipart):

  • CycloneDX: bomFormat "CycloneDX" with specVersion 1.4 or later. components[] (including nested components, up to 32 levels) are read; metadata.component (the application itself) is ignored.
  • SPDX: spdxVersion "SPDX-2.3". packages[] are read, with the purl taken from externalRefs[] (referenceType purl, category PACKAGE-MANAGER or PACKAGE_MANAGER).
  • Size: at most 20 MB (SBOM_MAX_BYTES), also after gzip decompression; 413 above it.
  • Components: at most 50000 valid components (SBOM_MAX_COMPONENTS); above it the SBOM is rejected with 400 and nothing is written (it is never truncated).

Supported ecosystems

The ecosystem, name and version come from the package URL (pkg:type/namespace/name@version?qualifiers). Supported types: deb, rpm, apk, pypi, npm, gem, composer, cargo, golang. Components without a purl, with an invalid purl or with another type (maven, oci, generic...) are skipped and counted in discarded, as are duplicates.

  • npm names keep their scope (@babel/core); golang and composer names are namespace/name.
  • deb and rpm versions get the epoch qualifier as epoch:version.
  • arch and distro come from the qualifiers of the same name; the deb/apk source package comes from upstream, the rpm one from the source rpm.
  • When the purl has no version, the CycloneDX version or the SPDX versionInfo is used.

Replacement rule

A new SBOM for the same target replaces the previous one: components of that target missing from the new SBOM become is_present=false (with removed_at), components present in both are confirmed. Other targets (the asset_uid SBOM and each image_digest SBOM of the same host are separate), and components from other origins (agent, Kubernetes, Trivy) are never touched. An SBOM with no components clears its target.

Response and errors

The 200 response reports the target, the detected format and spec version, the number of assets written and the counts:

  • created: new components; updated: already known components confirmed again; removed: components of the target set to is_present=false (including those on hosts no longer running the digest); discarded: elements skipped.
  • 400: missing or double target, invalid digest, body that is not JSON (or nested too deeply), unknown format or unsupported version, components/packages that is not a list, too many components.
  • 401 / 403: no valid token / owner not a manager or admin, or API token without write:sbom. 404: unknown or inactive asset, or digest not running. 413: body too large. 415: unsupported Content-Type or Content-Encoding.

GitHub Actions example

The build job pushes the image and exposes its digest as a job output; the sbom job runs after the deploy (the digest must be running, 404 otherwise), generates the SBOM with syft (anchore/sbom-action) and uploads it for the image digest, retrying on 404 until the agent or relay has reported the new container. IDP_URL is a repository variable, IDP_API_TOKEN is a secret holding the write:sbom API token, REGISTRY_USER and REGISTRY_PASSWORD are the registry credentials used to push and to pull the image.

# .github/workflows/release.yml
jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      digest: ${{ steps.push.outputs.digest }}
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: registry.acme.it
          username: ${{ secrets.REGISTRY_USER }}
          password: ${{ secrets.REGISTRY_PASSWORD }}
      - id: push
        uses: docker/build-push-action@v6
        with:
          push: true
          tags: registry.acme.it/team/api:${{ github.sha }}

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - run: echo "deploy registry.acme.it/team/api@${{ needs.build.outputs.digest }}"  # your deploy here

  sbom:
    needs: [build, deploy]
    runs-on: ubuntu-latest
    steps:
      - uses: anchore/sbom-action@v0
        with:
          image: registry.acme.it/team/api@${{ needs.build.outputs.digest }}
          format: cyclonedx-json
          output-file: sbom.cdx.json
          upload-artifact: false
          registry-username: ${{ secrets.REGISTRY_USER }}
          registry-password: ${{ secrets.REGISTRY_PASSWORD }}
      - name: Upload SBOM to AsPeekIt
        env:
          IDP_URL: ${{ vars.IDP_URL }}
          IDP_API_TOKEN: ${{ secrets.IDP_API_TOKEN }}
          DIGEST: ${{ needs.build.outputs.digest }}
        run: |
          for attempt in 1 2 3 4 5 6 7 8 9 10; do
            code=$(curl -s -o response.json -w '%{http_code}' -X POST \
              "$IDP_URL/api/v1/software/sbom/?image_digest=$DIGEST" \
              -H "Authorization: Token $IDP_API_TOKEN" \
              -H "Content-Type: application/vnd.cyclonedx+json" \
              --data-binary @sbom.cdx.json)
            [ "$code" != 404 ] && break
            sleep 30  # the container is not in the inventory yet
          done
          cat response.json
          [ "$code" = 200 ]

GitLab CI example

The build job writes IMAGE_DIGEST to a dotenv report, so later jobs receive it as a variable. sbom:host targets a host with asset_uid (an application deployed directly on a server); sbom:image runs after the deploy and targets the image digest, compressed with gzip, retrying on 404 until the agent or relay has reported the new container; syft pulls the image with the GitLab registry credentials (SYFT_REGISTRY_AUTH_*). syft is pinned to a release. IDP_URL, IDP_ASSET_UID and IDP_API_TOKEN (the write:sbom API token) are masked CI/CD variables.

Note: syft emits SPDX 2.3 with -o spdx-json and CycloneDX 1.5 or later with -o cyclonedx-json: both are accepted.

# .gitlab-ci.yml
stages: [build, deploy, post-deploy]

variables:
  SYFT_VERSION: v1.18.1

.idp-upload: &idp-upload
  image: alpine:3.20
  before_script:
    - apk add --no-cache curl
    - curl -sSfL https://raw.githubusercontent.com/anchore/syft/$SYFT_VERSION/install.sh | sh -s -- -b /usr/local/bin $SYFT_VERSION

build:
  stage: build
  image: docker:27
  services: [docker:27-dind]
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
    - echo "IMAGE_DIGEST=$(docker inspect --format '{{index .RepoDigests 0}}' "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" | cut -d@ -f2)" > build.env
  artifacts:
    reports:
      dotenv: build.env

deploy:
  stage: deploy
  script:
    - echo "deploy $CI_REGISTRY_IMAGE@$IMAGE_DIGEST"  # your deploy here

sbom:host:
  <<: *idp-upload
  stage: deploy
  script:
    - syft dir:. -o cyclonedx-json > sbom.cdx.json
    - >
      curl --fail-with-body -X POST
      "$IDP_URL/api/v1/software/sbom/?asset_uid=$IDP_ASSET_UID"
      -H "Authorization: Token $IDP_API_TOKEN"
      -H "Content-Type: application/vnd.cyclonedx+json"
      --data-binary @sbom.cdx.json

sbom:image:
  <<: *idp-upload
  stage: post-deploy
  needs: [build, deploy]
  variables:
    SYFT_REGISTRY_AUTH_AUTHORITY: $CI_REGISTRY
    SYFT_REGISTRY_AUTH_USERNAME: $CI_REGISTRY_USER
    SYFT_REGISTRY_AUTH_PASSWORD: $CI_REGISTRY_PASSWORD
  script:
    - syft "$CI_REGISTRY_IMAGE@$IMAGE_DIGEST" -o spdx-json | gzip > sbom.spdx.json.gz
    - |
      for attempt in 1 2 3 4 5 6 7 8 9 10; do
        code=$(curl -s -o response.json -w '%{http_code}' -X POST \
          "$IDP_URL/api/v1/software/sbom/?image_digest=$IMAGE_DIGEST" \
          -H "Authorization: Token $IDP_API_TOKEN" \
          -H "Content-Type: application/spdx+json" \
          -H "Content-Encoding: gzip" \
          --data-binary @sbom.spdx.json.gz)
        [ "$code" != 404 ] && break
        sleep 30  # the container is not in the inventory yet
      done
      cat response.json
      [ "$code" = 200 ]