# SBOM Generator & Validator (CycloneDX / SPDX) API

> Generate a CycloneDX 1.6 or SPDX 2.3 SBOM from package-lock, yarn, pnpm, poetry, composer, go.sum or Cargo.lock; validate, convert, diff and merge SBOMs.

- Endpoint: `POST https://apibox.io.vn/v1/sbom-tools`
- Category: Security & Crypto
- HTML docs: https://apibox.io.vn/docs/sbom-tools/ (Vietnamese: https://apibox.io.vn/vi/docs/sbom-tools/)
- Online tool: https://apibox.io.vn/tools/sbom-tools/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

A Software Bill of Materials lists every component inside your software. The EU Cyber Resilience Act makes SBOMs mandatory for products sold in the EU (vulnerability reporting from 11 September 2026, full obligations from 11 December 2027), and US federal buyers already ask for them. `action=generate` builds one from a lockfile: `package-lock.json` / `npm-shrinkwrap.json`, `yarn.lock` (v1 and Berry), `pnpm-lock.yaml`, `requirements.txt` (pinned `==` lines), `poetry.lock`, `Pipfile.lock`, `composer.lock`, `go.sum` / `go.mod`, `Cargo.lock` and `Gemfile.lock`. Each component gets a package URL (purl), the lockfile hash (npm SHA-512 integrity, Cargo SHA-256 checksum, Composer SHA-1), the licence when the lockfile has it (normalised to an SPDX expression) and the dependency graph when the lockfile records it.

Output is CycloneDX 1.6 JSON (default) or SPDX 2.3 JSON (`output=spdx`); `download=1` returns the file itself. `action=validate` checks a CycloneDX (1.2–1.7) or SPDX 2.x JSON document: required fields, enumerations, unique bom-refs / SPDXIDs, references that resolve, hash length, purl syntax, SPDX licence expressions, plus the NTIA minimum elements (supplier, name, version, unique identifier, dependencies, author, timestamp) with coverage percentages. `action=convert` turns CycloneDX into SPDX and back, `action=diff` compares two SBOMs (added, removed, upgraded, downgraded, licence changes) and `action=merge` combines up to 20.

`vulns=1` looks every component up on OSV.dev and adds the advisories (CycloneDX `vulnerabilities`, SPDX security references). The code is APIBox's own (no CycloneDX library); validation follows the specifications' rules but is not a full JSON Schema run. An SBOM built from a lockfile cannot see vendored code, native libraries or OS packages.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `action` | body | string | no | `generate` | `generate`, `validate`, `convert`, `diff` or `merge` (alias `op`). |
| `lockfile` | body | string | no |  | generate: lockfile text (or upload it as `file`, or send it as the raw body). |
| `file` | body | file | no |  | Lockfile or SBOM file upload (multipart). |
| `filename` | body | string | no |  | Lockfile name when the format cannot be detected (e.g. `poetry.lock`). |
| `output` | body | string | no | `cyclonedx` | `cyclonedx` (1.6 JSON) or `spdx` (2.3 JSON). |
| `name` | body | string | no |  | Name of your application (root component, alias `app_name`); `version`, `supplier`, `author`, `license` too. |
| `include_dev` | body | boolean | no | `true` | `false` leaves out dev dependencies. |
| `vulns` | body | boolean | no |  | `1`: add known vulnerabilities from OSV.dev. |
| `sbom` | body | object | no |  | validate / convert: the SBOM (JSON object or text). |
| `sbom_a` | body | object | no |  | diff: the old SBOM; `sbom_b` the new one. merge: `sboms` array. |
| `download` | body | boolean | no |  | `1`: return the SBOM file instead of JSON with a summary. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/sbom-tools" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"generate","lockfile":"# yarn lockfile v1\n\n\"@babel/code-frame@^7.0.0\":\n  version \"7.12.13\"\n  resolved \"https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz\"\n  integrity sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==\n  dependencies:\n    \"@babel/highlight\" \"^7.12.13\"\n\n\"@babel/highlight@^7.12.13\":\n  version \"7.13.10\"\n  integrity sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==\n  dependencies:\n    js-tokens \"^4.0.0\"\n\njs-tokens@^4.0.0:\n  version \"4.0.0\"\n  integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==\n","name":"my-app","version":"1.0.0"}'
```

## Example response

```json
{
  "action": "generate",
  "input_format": "yarn.lock",
  "output": "CycloneDX 1.6 JSON",
  "summary": {
    "components": 3,
    "direct": 1,
    "with_hashes": 3,
    "with_licence": 0,
    "by_type": {
      "npm": 3
    },
    "licences": {
      "unknown": 3
    }
  },
  "note": "Built from the lockfile only: vendored code, native libraries and system packages are not visible. Licences come from the lockfile when it has them (package-lock, composer.lock).",
  "sbom": {
    "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
    "bomFormat": "CycloneDX",
    "specVersion": "1.6",
    "serialNumber": "urn:uuid:da83b698-18a4-4fb0-adb4-731efa0d9901",
    "version": 1,
    "metadata": {
      "timestamp": "2026-11-15T16:20:25Z",
      "lifecycles": [
        {
          "phase": "build"
        }
      ],
      "tools": {
        "components": [
          {
            "type": "application",
            "name": "APIBox sbom-tools",
            "version": "1.0",
            "externalReferences": [
              {
                "type": "website",
                "url": "https://apibox.io.vn/docs/sbom-tools/"
              }
            ]
          }
        ]
      },
      "component": {
        "type": "application",
        "bom-ref": "root-component",
        "name": "my-app",
        "version": "1.0.0"
      }
    },
    "components": [
      {
        "type": "library",
        "bom-ref": "pkg:npm/%40babel/code-frame@7.12.13",
        "group": "@babel",
        "name": "code-frame",
        "version": "7.12.13",
        "hashes": [
          {
            "alg": "SHA-512",
            "content": "1d5d429b443766ba4247dded9163988ae60880bc595d91551b65602be3015a352a653ba776ea5b7f1d9a5daad7bb0e4aa3968c723b4981b4ace2f506052e6fea"
          }
        ],
        "purl": "pkg:npm/%40babel/code-frame@7.12.13",
        "externalReferences": [
          {
            "type": "distribution",
            "url": "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz"
          }
        ]
      },
      "…"
    ],
    "dependencies": [
      {
        "ref": "root-component",
        "dependsOn": [
          "pkg:npm/%40babel/code-frame@7.12.13"
        ]
      },
      {
        "ref": "pkg:npm/%40babel/code-frame@7.12.13",
        "dependsOn": [
          "pkg:npm/%40babel/highlight@7.13.10"
        ]
      },
      {
        "ref": "pkg:npm/%40babel/highlight@7.13.10",
        "dependsOn": [
          "pkg:npm/js-tokens@4.0.0"
        ]
      },
      {
        "ref": "pkg:npm/js-tokens@4.0.0",
        "dependsOn": []
      }
    ]
  }
}
```

## Use cases

- Ship the SBOM that EU customers ask for under the Cyber Resilience Act
- Add an SBOM step to CI from the lockfile, without installing extra tooling
- Check a supplier's SBOM for missing fields before accepting a delivery
- Compare the SBOMs of two releases to see what changed

## FAQ

### CycloneDX or SPDX?

Both are accepted by most tools and regulators. CycloneDX is common in security tooling (OWASP); SPDX is an ISO standard (ISO/IEC 5962) often used for licence compliance. You can convert between them here.

### Why are licences missing for npm packages?

npm lockfiles usually do not store licences. Composer locks do. Run the spdx-license or dep-audit endpoints with latest=1 to look licences up from the registries.

### Is my lockfile stored?

No. It is parsed in memory and the SBOM is returned in the response; nothing is logged.
