> ## Documentation Index
> Fetch the complete documentation index at: https://docs.draftt.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest a code SBOM

> Ingests an SBOM as one project (`project`), or as all the projects it contains (`repository` only).



## OpenAPI

````yaml https://api.draftt.io/swagger post /code/sbom
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /code/sbom:
    post:
      tags:
        - Code
      summary: Ingest a code SBOM
      description: >-
        Ingests an SBOM as one project (`project`), or as all the projects it
        contains (`repository` only).
      operationId: IngestCodeSbom
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IngestSbomRequest'
            examples:
              projectMode:
                summary: Project mode
                value:
                  project:
                    identifier: https://github.com/acme/payments
                    name: payments
                  projectInformation:
                    programmingLanguage: javascript
                    dependencyManager: npm
                    runtimeVersion: '20'
                    tags:
                      team: payments
                  sbom:
                    bomFormat: CycloneDX
                    specVersion: '1.5'
                    version: 1
                    metadata:
                      component:
                        bom-ref: payments
                        type: application
                        name: payments
                        purl: pkg:npm/payments@3.2.0
                    components:
                      - bom-ref: pkg:npm/express@4.21.2
                        type: library
                        name: express
                        version: 4.21.2
                        purl: pkg:npm/express@4.21.2
                    dependencies:
                      - ref: payments
                        dependsOn:
                          - pkg:npm/express@4.21.2
              repositoryMode:
                summary: Repository mode
                value:
                  repository:
                    identifier: https://github.com/acme/orders
                    name: orders
                  repositoryInformation:
                    runtimeVersion: '20'
                    tags:
                      team: payments
                  projects:
                    - match:
                        purl: pkg:npm/orders-api
                      name: Orders API
                      projectInformation:
                        runtimeVersion: '22'
                    - match:
                        path: apps/ui/package.json
                      projectInformation:
                        customTags:
                          owner: web
                    - match:
                        name: orders-e2e
                      name: Orders E2E
                      projectInformation: {}
                  sbom:
                    bomFormat: CycloneDX
                    specVersion: '1.5'
                    version: 1
                    metadata:
                      component:
                        type: application
                        name: orders
                        components:
                          - bom-ref: orders-api
                            type: application
                            name: orders-api
                            purl: pkg:npm/orders-api@1.4.0
                          - bom-ref: orders-ui
                            type: application
                            name: orders-ui
                            purl: pkg:npm/orders-ui@2.0.1
                            evidence:
                              occurrences:
                                - location: apps/ui/package.json
                          - bom-ref: orders-e2e
                            type: application
                            name: orders-e2e
                            purl: pkg:npm/orders-e2e@1.0.0
                    components:
                      - bom-ref: pkg:npm/express@4.21.2
                        type: library
                        name: express
                        version: 4.21.2
                        purl: pkg:npm/express@4.21.2
                      - bom-ref: pkg:npm/react@18.3.1
                        type: library
                        name: react
                        version: 18.3.1
                        purl: pkg:npm/react@18.3.1
                    dependencies:
                      - ref: orders-api
                        dependsOn:
                          - pkg:npm/express@4.21.2
                      - ref: orders-ui
                        dependsOn:
                          - pkg:npm/react@18.3.1
                      - ref: orders-e2e
                        dependsOn: []
      responses:
        '202':
          description: SBOM accepted for ingestion
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    IngestSbomRequest:
      oneOf:
        - $ref: '#/components/schemas/IngestSbomProjectModeRequest'
        - $ref: '#/components/schemas/IngestSbomRepositoryModeRequest'
    IngestSbomProjectModeRequest:
      type: object
      title: Project mode
      description: The whole SBOM becomes one project
      properties:
        project:
          $ref: '#/components/schemas/SbomResourceIdentifyingInformation'
        repository:
          $ref: '#/components/schemas/SbomResourceIdentifyingInformation'
        sbom:
          type: object
        projectInformation:
          $ref: '#/components/schemas/SbomProjectInformation'
      required:
        - project
        - sbom
    IngestSbomRepositoryModeRequest:
      type: object
      title: Repository mode
      description: Every project in the SBOM is ingested under the repository
      properties:
        repository:
          $ref: '#/components/schemas/SbomResourceIdentifyingInformation'
        sbom:
          type: object
        repositoryInformation:
          description: The repository's tags, and the default values of every project
          allOf:
            - $ref: '#/components/schemas/SbomProjectInformation'
        projects:
          type: array
          description: >-
            Per-project overrides, each matching one project by its purl,
            manifest path or name
          items:
            $ref: '#/components/schemas/SbomProjectOverride'
          example:
            - match:
                purl: pkg:npm/orders-api
              name: Orders API
              projectInformation:
                runtimeVersion: '22'
            - match:
                path: apps/ui/package.json
              projectInformation:
                customTags:
                  owner: web
            - match:
                name: orders-e2e
              name: Orders E2E
              projectInformation: {}
      required:
        - repository
        - sbom
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    SbomResourceIdentifyingInformation:
      type: object
      properties:
        identifier:
          type: string
        name:
          type: string
      required:
        - identifier
    SbomProjectInformation:
      type: object
      properties:
        programmingLanguage:
          type: string
          enum:
            - javascript
            - java
            - python
            - go
            - csharp
            - php
            - ruby
            - rust
        dependencyManager:
          type: string
          enum:
            - gradle
            - maven
            - npm
            - pip
            - poetry
            - pipenv
            - pdm
            - uv
            - gomod
            - nuget
            - composer
            - bundler
            - cargo
            - container-image-technology
        runtimeVersion:
          type: string
        tags:
          type: object
        customTags:
          type: object
    SbomProjectOverride:
      type: object
      properties:
        match:
          description: >-
            Identifies the project by exactly one of its purl, manifest path or
            name
          oneOf:
            - type: object
              title: By purl
              properties:
                purl:
                  type: string
                  description: The project purl, with or without its version
              required:
                - purl
              additionalProperties: false
            - type: object
              title: By path
              properties:
                path:
                  type: string
                  description: The project's manifest path, e.g. apps/api/package.json
              required:
                - path
              additionalProperties: false
            - type: object
              title: By name
              properties:
                name:
                  type: string
                  description: The project name
              required:
                - name
              additionalProperties: false
        name:
          type: string
        projectInformation:
          $ref: '#/components/schemas/SbomProjectInformation'
      required:
        - match
        - projectInformation
      example:
        match:
          purl: pkg:npm/orders-api
        name: Orders API
        projectInformation:
          runtimeVersion: '22'
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.