Snyk Tests API

The Tests API from Snyk — 3 operation(s) for tests.

OpenAPI Specification

snyk-tests-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Snyk AccessRequests Tests API
  version: REST
servers:
- description: Snyk REST API
  url: https://api.snyk.io/rest
security:
- APIToken: []
- BearerAuth: []
tags:
- name: Tests
paths:
  /orgs/{org_id}/test_jobs/{job_id}:
    get:
      description: 'Get a test job.


        The Test API is Asynchronous, and Tests begun through the API

        are assigned a Job ID which references the in-progress Test. The

        Job ID is provided in a successful response from the CreateTest

        endpoint.


        This endpoint is used to poll for the status of a Test using its

        associated Job ID.


        When the Job is Finished and the Test is ready for consumption,

        the Related link will be populated in the response with a link

        to the finished Test entity.


        #### Required permissions


        - `View Organization (org.read)`'
      operationId: getJob
      parameters:
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.request_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.interaction_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.version'
      - description: 'Snyk Org ID under which to run or query information

          about a Job or Test.'
        in: path
        name: org_id
        required: true
        schema:
          format: uuid
          type: string
      - description: Job ID returned from the Test API to query.
        in: path
        name: job_id
        required: true
        schema:
          format: uuid
          type: string
      responses:
        '200':
          content:
            application/vnd.api+json:
              schema:
                properties:
                  data:
                    description: JobData represents a Job resource object.
                    properties:
                      attributes:
                        description: JobAttributes represents the attributes of a Job resource
                        properties:
                          created_at:
                            description: Creation time of the job resource
                            format: date-time
                            type: string
                          status:
                            allOf:
                            - enum:
                              - pending
                              - started
                              - finished
                              - errored
                              type: string
                            description: State of the test, whether it is pending, running, complete or errored.
                        required:
                        - status
                        - created_at
                        type: object
                      id:
                        format: uuid
                        type: string
                      relationships:
                        properties:
                          test:
                            allOf:
                            - properties:
                                data:
                                  properties:
                                    id:
                                      format: uuid
                                      type: string
                                    type:
                                      enum:
                                      - tests
                                      type: string
                                  required:
                                  - id
                                  - type
                                  type: object
                              required:
                              - data
                              type: object
                            description: Test resource associated with the finished Job.
                        required:
                        - test
                        type: object
                      type:
                        enum:
                        - test_jobs
                        type: string
                    required:
                    - id
                    - attributes
                    - type
                    type: object
                  jsonapi:
                    $ref: '#/components/schemas/io.snyk.api.common.JsonApi'
                  links:
                    additionalProperties:
                      $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    properties:
                      related:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                      self:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    type: object
                  meta:
                    $ref: '#/components/schemas/io.snyk.api.common.Meta'
                required:
                - data
                - jsonapi
                - links
                type: object
          description: Successful API response with a single resource
          headers:
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
        '303':
          content:
            application/vnd.api+json:
              schema:
                properties:
                  data:
                    description: JobData represents a Job resource object.
                    properties:
                      attributes:
                        description: JobAttributes represents the attributes of a Job resource
                        properties:
                          created_at:
                            description: Creation time of the job resource
                            format: date-time
                            type: string
                          status:
                            allOf:
                            - enum:
                              - pending
                              - started
                              - finished
                              - errored
                              type: string
                            description: State of the test, whether it is pending, running, complete or errored.
                        required:
                        - status
                        - created_at
                        type: object
                      id:
                        format: uuid
                        type: string
                      relationships:
                        properties:
                          test:
                            allOf:
                            - properties:
                                data:
                                  properties:
                                    id:
                                      format: uuid
                                      type: string
                                    type:
                                      enum:
                                      - tests
                                      type: string
                                  required:
                                  - id
                                  - type
                                  type: object
                              required:
                              - data
                              type: object
                            description: Test resource associated with the finished Job.
                        required:
                        - test
                        type: object
                      type:
                        enum:
                        - test_jobs
                        type: string
                    required:
                    - id
                    - attributes
                    - type
                    type: object
                  jsonapi:
                    $ref: '#/components/schemas/io.snyk.api.common.JsonApi'
                  links:
                    additionalProperties:
                      $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    properties:
                      related:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                      self:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    type: object
                  meta:
                    $ref: '#/components/schemas/io.snyk.api.common.Meta'
                required:
                - data
                - jsonapi
                - links
                type: object
          description: Redirect to another resource after async processing.
          headers:
            deprecation:
              schema:
                type: string
            location:
              required: true
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
        '400':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/io.snyk.api.common.ErrorDocument'
          description: Invalid input
          headers:
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
      summary: Get a test job. (Early Access)
      tags:
      - Tests
      x-snyk-api-lifecycle: released
      x-snyk-api-releases:
      - 2024-10-15~beta
      x-snyk-api-resource: tests
      x-snyk-api-stability: beta
      x-snyk-api-version: 2024-10-15~beta
      x-stability-level: beta
  /orgs/{org_id}/tests:
    post:
      description: 'Create a new test.


        Provide the items to be tested by Snyk as well as any configuration

        parameters for the test to be run.


        Currently, scans using the Open Source (SCA) and Code Analysis (SAST)

        scanners can be run using the Test API.


        Tests begun through the Test API yield lists of Findings when

        finished. These Findings can be retrieved using the ListFindings endpoint.


        Successfully creating a new Test will yield a Job ID that can be used

        to poll for the Test''s completion via the GetJob endpoint.


        #### Required permissions


        - `View Organization (org.read)`


        - `Test packages (org.package.test)`'
      operationId: createTest
      parameters:
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.request_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.interaction_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.version'
      - description: 'Snyk Org ID under which to run or query information

          about a Job or Test.'
        in: path
        name: org_id
        required: true
        schema:
          format: uuid
          type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/TestRequestBody'
        required: true
      responses:
        '202':
          content:
            application/vnd.api+json:
              schema:
                properties:
                  data:
                    properties:
                      attributes:
                        description: JobAttributes represents the attributes of a Job resource
                        properties:
                          created_at:
                            description: Creation time of the job resource
                            format: date-time
                            type: string
                          status:
                            allOf:
                            - enum:
                              - pending
                              - started
                              - finished
                              - errored
                              type: string
                            description: State of the test, whether it is pending, running, complete or errored.
                        required:
                        - status
                        - created_at
                        type: object
                      id:
                        format: uuid
                        type: string
                      type:
                        enum:
                        - test_jobs
                        type: string
                    required:
                    - type
                    - id
                    - attributes
                    type: object
                  jsonapi:
                    $ref: '#/components/schemas/io.snyk.api.common.JsonApi'
                  links:
                    additionalProperties:
                      $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    properties:
                      related:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                      self:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    type: object
                  meta:
                    $ref: '#/components/schemas/io.snyk.api.common.Meta'
                required:
                - data
                - jsonapi
                - links
                type: object
          description: The request has been accepted for processing, but processing has not yet completed.
          headers:
            content-location:
              description: A pointer to the newly created Test resource
              required: true
              schema:
                format: string
                type: string
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
        '400':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/io.snyk.api.common.ErrorDocument'
          description: Invalid input
          headers:
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
      summary: Create a new test. (Early Access)
      tags:
      - Tests
      x-snyk-api-lifecycle: released
      x-snyk-api-releases:
      - 2024-10-15~beta
      x-snyk-api-resource: tests
      x-snyk-api-stability: beta
      x-snyk-api-version: 2024-10-15~beta
      x-stability-level: beta
  /orgs/{org_id}/tests/{test_id}:
    get:
      description: 'Get a test.


        A Test returned through this endpoint is intended to

        be a completed Test with results. The data returned through

        this endpoint does not contain the Findings for the Test, but

        a description of the Test that was run and its status.


        Tests that completed successfully are marked with an appropriate

        outcome according to the configured Thresholds.


        Facts about the Test (e.g. how many dependencies were present in

        a Tested SBOM) are attached to this response as well as a summary

        of the Findings uncovered during the Test.


        Any Errors or Warnings that occurred during the Test will be present in the

        response from this endpoint.


        The response will also contain a link to the first page of the Test''s

        Findings.


        #### Required permissions


        - `View Organization (org.read)`'
      operationId: getTest
      parameters:
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.request_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.interaction_id'
      - $ref: '#/components/parameters/io.snyk.api.request.SnykApiRequest.version'
      - description: 'Snyk Org ID under which to run or query information

          about a Job or Test.'
        in: path
        name: org_id
        required: true
        schema:
          format: uuid
          type: string
      - $ref: '#/components/parameters/TestIdParam'
      responses:
        '200':
          content:
            application/vnd.api+json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/TestData'
                  jsonapi:
                    $ref: '#/components/schemas/io.snyk.api.common.JsonApi'
                  links:
                    additionalProperties:
                      $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    properties:
                      related:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                      self:
                        $ref: '#/components/schemas/io.snyk.api.common.LinkProperty'
                    type: object
                  meta:
                    $ref: '#/components/schemas/io.snyk.api.common.Meta'
                required:
                - data
                - jsonapi
                - links
                type: object
          description: Successful API response with a single resource
          headers:
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
        '400':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/io.snyk.api.common.ErrorDocument'
          description: Invalid input
          headers:
            deprecation:
              schema:
                type: string
            snyk-request-id:
              schema:
                type: string
            snyk-version-lifecycle-stage:
              schema:
                type: string
            snyk-version-requested:
              schema:
                type: string
            snyk-version-served:
              schema:
                type: string
            sunset:
              description: 'A header containing the date of when the underlying endpoint will be removed. This header is only present if the endpoint has been deprecated. For information purposes only. Returned as a date in the format: YYYY-MM-DD'
              example: '2021-08-02'
              schema:
                format: date
                type: string
      summary: Get a test. (Early Access)
      tags:
      - Tests
      x-snyk-api-lifecycle: released
      x-snyk-api-releases:
      - 2024-10-15~beta
      x-snyk-api-resource: tests
      x-snyk-api-stability: beta
      x-snyk-api-version: 2024-10-15~beta
      x-stability-level: beta
components:
  schemas:
    TestExecutionStates:
      enum:
      - pending
      - started
      - finished
      - errored
      type: string
    DepGraphSubjectCreate:
      description: '**Deprecated**


        Provide an InlineResource with the DepGraph contents

        and the SCA Scan Configuration instead.


        Test subject representing a Snyk dependency graph (a legacy SBOM format).'
      properties:
        dep_graph:
          allOf:
          - $ref: '#/components/schemas/DepGraphRef'
          description: 'When creating a test, provide the dep-graph contents inline to the request.


            This attribute is only available when creating a new Test.'
        locator:
          allOf:
          - $ref: '#/components/schemas/LocalPathLocator'
          description: 'Source file(s) from which the dependency graph was derived.


            For some managed package ecosystems (examples: Maven, Yarn workspaces),

            Snyk might derive a dependency graph from several files.'
        type:
          enum:
          - dep_graph
          type: string
      required:
      - type
      - dep_graph
      - locator
      type: object
    ScmContext:
      description: 'Additional SCM information about a resource.

        Provides context about where the content came from; the resource itself is the testable item.

        ScmResource does not use this; it identifies SCM via its own fields.'
      properties:
        branch:
          maxLength: 256
          type: string
        commit_ref:
          maxLength: 1024
          type: string
        repo_url:
          maxLength: 1024
          type: string
      type: object
    String256:
      maxLength: 256
      type: string
    TestOutcome:
      description: Outcome of a test; pass or fail.
      properties:
        breached_policies:
          allOf:
          - $ref: '#/components/schemas/PolicyRefSet'
          description: 'Test-level policies which were breached in a failing outcome.


            This array may be truncated for a large number of policies.'
        reason:
          allOf:
          - $ref: '#/components/schemas/TestOutcomeReason'
          description: Reason for the outcome, if applicable.
        result:
          allOf:
          - $ref: '#/components/schemas/PassFail'
          description: Whether the test passed or failed.
      required:
      - result
      type: object
    io.snyk.api.v1testdepgraph.request.Package:
      additionalProperties: {}
      properties:
        id:
          type: string
        info:
          $ref: '#/components/schemas/io.snyk.api.v1testdepgraph.request.PackageInfo'
      required:
      - id
      - info
      type: object
    LocalPathLocator:
      description: 'LocalPathLocator locates a test subject by local file paths, relative to the

        working copy top-level directory of the source code.'
      properties:
        paths:
          description: Local file paths. Limited to 256 characters.
          items:
            $ref: '#/components/schemas/String256'
          minItems: 1
          type: array
        type:
          enum:
          - local_path
          type: string
      required:
      - type
      - paths
      type: object
    SastScanConfiguration:
      description: Scan configuration parameters for the SAST scanner.
      type: object
    io.snyk.api.v1testdepgraph.request.NodeRef:
      additionalProperties: {}
      properties:
        nodeId:
          type: string
      required:
      - nodeId
      type: object
    io.snyk.api.v1testdepgraph.request.Node:
      additionalProperties: {}
      properties:
        deps:
          items:
            $ref: '#/components/schemas/io.snyk.api.v1testdepgraph.request.NodeRef'
          type: array
        nodeId:
          type: string
        pkgId:
          type: string
      required:
      - nodeId
      - pkgId
      - deps
      type: object
    TestSubjectLocator:
      discriminator:
        mapping:
          local_path: '#/components/schemas/LocalPathLocator'
          other: '#/components/schemas/OtherLocator'
          project_entity: '#/components/schemas/ProjectEntityLocator'
          project_name: '#/components/schemas/ProjectNameLocator'
          scm_repo: '#/components/schemas/ScmRepoLocator'
        propertyName: type
      oneOf:
      - $ref: '#/components/schemas/ProjectEntityLocator'
      - $ref: '#/components/schemas/ProjectNameLocator'
      - $ref: '#/components/schemas/ScmRepoLocator'
      - $ref: '#/components/schemas/LocalPathLocator'
      - $ref: '#/components/schemas/OtherLocator'
    DiffResource:
      description: 'DiffResources contain two versions of the same content

        to compare against each other.


        The Base and Compare fields contain Resources representing

        an "existing" (base) version as well as a "new" (compare)

        version. Most commonly these Resources will be of the same type,

        e.g. an ScmResource containing a reference the `main` branch being

        compared to an ScmResource containing a reference to a new

        feature branch.


        Currently no scans are supported through the Test API

        for DiffResources.'
      example:
        base:
          file_patterns: []
          integration_id: 00000000-0000-0000-0000-000000000000
          ref: main
          repo_url: https://github.com/example/repo
          type: scm
        compare:
          file_patterns: []
          integration_id: 00000000-0000-0000-0000-000000000000
          ref: feat/homepage
          repo_url: https://github.com/example/repo
          type: scm
        type: diff
      properties:
        base:
          $ref: '#/components/schemas/BaseResourceVariant'
        compare:
          $ref: '#/components/schemas/BaseResourceVariant'
        type:
          enum:
          - diff
          type: string
      required:
      - type
      - base
      - compare
      type: object
    ScanConfiguration:
      description: 'A map of scanner types to their specific set of

        configuration parameters.


        The presence of a scanner''s configuration in the

        provided ScanConfiguration is used to determine what scans

        to run on the list of Resources provided.


        Note that an empty config object is different than

        omitting the field. An omitted scanner config results in

        that scanner not being run. A provided empty scan config

        will run the scanner if it is possible.'
      example:
        secrets: {}
      properties:
        container:
          $ref: '#/components/schemas/ContainerScanConfiguration'
        iac:
          $ref: '#/components/schemas/IacScanConfiguration'
        sast:
          $ref: '#/components/schemas/SastScanConfiguration'
        sca:
          $ref: '#/components/schemas/ScaScanConfiguration'
        secrets:
          $ref: '#/components/schemas/SecretsScanConfiguration'
      type: object
    BaseResourceCreateItem:
      description: BaseResources contain a single instance of testable content.
      example:
        resource:
          content_type: source
          file_patterns: []
          repository_url: https://github.com/example/repo
          revision_id: 00000000-0000-0000-0000-000000000000
          root_folder_id: .
          type: upload
        type: base
      properties:
        resource:
          allOf:
          - $ref: '#/components/schemas/BaseResourceVariantCreateItem'
          description: The specific representation of what content to test.
        type:
          enum:
          - base
          type: string
      required:
      - type
      - resource
      type: object
    DeepcodeBundleSubject:
      description: '**Deprecated**


        Provide a BundleResource and include the

        SAST Scan Configuration instead.


        Test subject representing source code uploaded to Snyk using DeepCode

        bundle APIs.


        Deepcode bundles are accepted through the API, but are not

        guaranteed to return Findings.'
      properties:
        bundle_id:
          description: Deepcode Bundle ID. These IDs are sha256 digests (32 bytes or 64 hex digits).
          pattern: ^[a-fA-F0-9]{64}$
          type: string
        locator:
          allOf:
          - $ref: '#/components/schemas/LocalPathLocator'
          description: Locate local paths from which the source code bundle was derived.
        type:
          enum:
          - deepcode_bundle
          type: string
      required:
      - type
      - bundle_id
      - locator
      type: object
    TestSubject:
      description: 'The subject of a test, which identifies the asset/project and content references

        necessary to conduct a security test.'
      discriminator:
        mapping:
          deepcode_bundle: '#/components/schemas/DeepcodeBundleSubject'
          dep_graph: '#/components/schemas/DepGraphSubject'
          git_url_coordinates: '#/components/schemas/GitUrlCoordinatesSubject'
          other: '#/components/schemas/OtherSubject'
          sbom: '#/components/schemas/SbomSubject'
          sbom_reachability: '#/components/schemas/SbomReachabilitySubject'
        propertyName: type
      oneOf:
      - $ref: '#/components/schemas/DeepcodeBundleSubject'
      - $ref: '#/components/schemas/DepGraphSubject'
      - $ref: '#/components/schemas/GitUrlCoordinatesSubject'
      - $ref: '#/components/schemas/SbomReachabilitySubject'
      - $ref: '#/components/schemas/OtherSubject'
      - $ref: '#/components/schemas/SbomSubject'
    BaseResourceVariantCreateItem:
      discriminator:
        mapping:
          bundle: '#/components/schemas/BundleResource'
          container: '#/components/schemas/ContainerRepoResource'
          inline: '#/components/schemas/InlineResourceCreateItem'
          scm: '#/components/schemas/ScmResource'
          snyk_ref: '#/components/schemas/SnykReferenceResource'
          upload: '#/components/schemas/UploadResource'
        propertyName: type
      oneOf:
      - $ref: '#/components/schemas/InlineResou

# --- truncated at 32 KB (80 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/snyk/refs/heads/main/openapi/snyk-tests-api-openapi.yml