---
title: "Import and export SBOMs"
sidebarTitle: "Import and export SBOMs"
description: "Export an asset's software inventory as CycloneDX or SPDX, import a bill of materials a supplier gave you, and read the provenance record of both."
keywords: ["SBOM", "CycloneDX", "SPDX", "bill of materials", "import", "export", "provenance", "software inventory"]
---

Every asset has one software inventory. A scan writes to it, an imported bill
of materials writes to it, and an export renders it. This page covers the two
directions and the record TRUSTIVAN keeps of each document.

| Action | Permission |
|---|---|
| Export, and read provenance | `assets:read` |
| Import | `scans:create`, because an import changes the inventory |

## Export an asset's inventory

```bash
curl -s "https://app.trustivan.com/api/v1/assets/$ASSET_ID/sbom?format=cyclonedx&download=true" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  -D headers.txt \
  -o asset.cdx.json
```

| Parameter | Values |
|---|---|
| `format` | `cyclonedx` (the default, CycloneDX 1.5) or `spdx` (SPDX 2.3). Both are JSON |
| `download` | `true` adds a `Content-Disposition` attachment header |

The response carries `X-TrustIvan-SBOM-Digest`, the SHA-256 of the body.
Compare it with the file you saved to confirm you hold the bytes that were
recorded:

```bash
grep -i x-trustivan-sbom-digest headers.txt
sha256sum asset.cdx.json
```

The document is built completely before any of it is sent. A bill of materials
cut short is not a smaller inventory; it is a document claiming an estate is
smaller than it is.

In the dashboard, the same exports are under
**Settings → Data and evidence → Bills of materials**.

## Scan a bill of materials for vulnerabilities

Use an upload when you have an SBOM and want to know what is wrong with it: a
supplier's product, a build you cannot give TRUSTIVAN access to. In the
dashboard, choose **New scan → SBOM file**. Over the API, the request body is
the document itself:

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/sbom/uploads?name=billing-api" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @billing-api.cdx.json
```

The upload is a scan like any other: it counts against your plan's scans and
assets, and the findings join the same backlog as your images and repositories,
filterable with `?asset_kind=sbom`.

- **The name is the asset.** `name` defaults to what the document says it
  describes. Upload the next version under the same name and triage and SLA
  clocks carry over, a package it no longer lists leaves the inventory, and a
  vulnerability it no longer has is resolved.
- **Set a schedule to catch new advisories.** Software nobody rebuilds still
  gains vulnerabilities. The newest document is rescanned on the asset's
  **Scheduled rescans** card.
- **Matching needs identifiers.** A component with no purl cannot be matched. An
  operating system package is matched only if the document also names the
  operating system, as most SBOM generators do for a container image. A document
  that names neither returns no findings, which does not mean the software is
  clean.

The document may be up to 8 MB, in CycloneDX or SPDX JSON.

## Import a bill of materials

Use an import when you want to add to what a scan of an existing asset found, as
inventory. **An import finds no vulnerabilities**; for that, upload it as above.
The request body is **the document itself**, not a JSON envelope around it:

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/assets/$ASSET_ID/sbom" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @vendor-sbom.json
```

The format is detected from the content. You can declare it with
`?format=cyclonedx` or `?format=spdx`; a declared format that disagrees with
the content is refused, and so is a document that declares both.

### What an import does to the inventory

- **It adds and corrects. It never removes.** Components an import wrote are
  not removed by a later scan, and an import does not remove what a scan
  found.
- **Identity is the Package URL.** A component exported and imported again is
  the same row, not a second one.
- **Entries that cannot be stored are dropped and counted**, not allowed to
  fail the whole import.

Read the response before you rely on the result:

```json
{
  "document": { "id": "…", "direction": "import", "format": "cyclonedx",
                "components_total": 412, "components_imported": 410,
                "components_dropped": 2, "drop_reasons": { "…": 2 } },
  "applied": { "components_created": 398, "components_updated": 12, "edges": 655, "skipped": 0 },
  "partial": true
}
```

`partial` is `true` whenever anything was refused, and `document.drop_reasons`
says why. Check it every time: an inventory that is silently incomplete is
worse than one that was refused.

### Refusals

| Status | Meaning |
|---|---|
| `400` | The document is malformed, its format is unsupported or ambiguous, or it holds no storable components |
| `404` | The asset does not exist or is not yours |
| `413` | The document is over the accepted size (8 MiB). The response carries `max_bytes` |
| `501` | This deployment does not store a software inventory |

## Read the provenance

TRUSTIVAN records every document it imported **and** every document it
exported, because a supply-chain review asks both where an inventory came from
and who it was given to.

```bash
curl -s "https://app.trustivan.com/api/v1/sbom/documents?asset_id=$ASSET_ID&direction=import" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

Filter with `asset_id` and `direction` (`import` or `export`). Each record
carries the `format` and `spec_version`, the `content_digest` and
`content_bytes`, the `producer`, and the component counts. Read one with
`GET /api/v1/sbom/documents/{id}`.

<Note>
  An import's bytes are not kept. The SHA-256 is, which answers "is the file you
  are holding the one you gave us?" without TRUSTIVAN storing a second copy of a
  file you already have. An upload is different: the newest document per asset
  is held so the scanner can read it and a schedule can rescan it. It is replaced
  by the next upload and deleted with the asset or the organization.
</Note>

## See also

- [Find where a package is used](/how-to/find-where-a-package-is-used):
  search the inventory an import adds to.
- [Export a licence compliance inventory](/how-to/export-license-inventory):
  the licence view of the same components.
- [Supply chain security](/security/supply-chain): the SBOM and provenance
  of TRUSTIVAN's own images.
