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

# Get snapshot

> Get a snapshot for an environment.

`snapshot_expression` can be specified as follows:
- `N`: the Nth snapshot, counting from 1. Negative values count from the latest snapshot i.e. -1 is the latest snapshot.
    example: 42
- `~N`: the Nth snapshot behind the latest, at the time of the request
    example: ~5
- `@{YYYY-MM-DDTHH:MM:SS}`: the snapshot at specific moment in time in UTC
    example: @{2023-10-02T12:00:00}
- `@{N.<hours|days|weeks|months>.ago}`: the snapshot at a time relative to the time of the request. N is a positive integer.
    example: @{2.hours.ago}
- `@{now}`: the snapshot at the time of the request
    example: @{now}



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json get /snapshots/{org}/{env_name}/{snapshot_expression}
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /snapshots/{org}/{env_name}/{snapshot_expression}:
    get:
      tags:
        - Snapshots
      summary: Get snapshot
      description: >-
        Get a snapshot for an environment.


        `snapshot_expression` can be specified as follows:

        - `N`: the Nth snapshot, counting from 1. Negative values count from the
        latest snapshot i.e. -1 is the latest snapshot.
            example: 42
        - `~N`: the Nth snapshot behind the latest, at the time of the request
            example: ~5
        - `@{YYYY-MM-DDTHH:MM:SS}`: the snapshot at specific moment in time in
        UTC
            example: @{2023-10-02T12:00:00}
        - `@{N.<hours|days|weeks|months>.ago}`: the snapshot at a time relative
        to the time of the request. N is a positive integer.
            example: @{2.hours.ago}
        - `@{now}`: the snapshot at the time of the request
            example: @{now}
      operationId: get_snapshot
      parameters:
        - name: env_name
          in: path
          required: true
          schema:
            type: string
            title: Env Name
        - name: snapshot_expression
          in: path
          required: true
          schema:
            type: string
            title: Snapshot Expression
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSnapshotResponse'
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    GetSnapshotResponse:
      properties:
        index:
          type: integer
          title: Index
          description: The index of the snapshot
        is_latest:
          type: boolean
          title: Is Latest
          description: True if this snapshot is the most recent
        next_snapshot_timestamp:
          anyOf:
            - type: number
            - type: 'null'
          title: Next Snapshot Timestamp
          description: The creation timestamp of the next snapshot if one exists
        artifact_compliance_count:
          additionalProperties:
            type: integer
          type: object
          title: Artifact Compliance Count
          description: The number of compliant and non-compliant artifacts in the snapshot
        timestamp:
          type: number
          title: Timestamp
          description: The timestamp of the snapshot creation
        type:
          type: string
          title: Type
          description: The type of the environment
        compliant:
          type: boolean
          title: Compliant
          description: Whether the snapshot is compliant
        html_url:
          type: string
          title: Html Url
          description: The HTML URL to the snapshot
        artifacts:
          items:
            $ref: '#/components/schemas/SnapshotArtifact'
          type: array
          title: Artifacts
          description: The list of artifacts in the snapshot
        applied_policies:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Applied Policies
          description: The list of policies applied to this snapshot
      type: object
      required:
        - index
        - is_latest
        - artifact_compliance_count
        - timestamp
        - type
        - compliant
        - html_url
        - artifacts
        - applied_policies
      title: GetSnapshotResponse
    SnapshotArtifact:
      properties:
        name:
          type: string
          title: Name
          description: The name of the artifact
        compliant:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Compliant
          description: >-
            Whether the artifact is compliant in the snapshot. None if the
            artifact status is 'unknown'
        deployments:
          items:
            type: integer
          type: array
          title: Deployments
          description: 'Deprecated: The list of deployments'
        policy_decisions:
          anyOf:
            - items:
                $ref: '#/components/schemas/PolicyEvaluationResponse'
              type: array
            - type: 'null'
          title: Policy Decisions
          description: >-
            The list of compliance decisions made from the attached policies to
            the environment at the time of snapshot creation
        reasons_for_incompliance:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Reasons For Incompliance
          description: 'Deprecated: The list of reasons for non-compliance of an artifact'
        fingerprint:
          anyOf:
            - type: string
              pattern: ^[a-f0-9]{64}$
            - type: string
              const: ''
          title: Fingerprint
          description: The fingerprint of an artifact
        creationTimestamp:
          items:
            type: integer
          type: array
          title: Creationtimestamp
          description: The list of timestamps when the artifact instances started running
        pods:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Pods
          description: The list of K8S pods if env is of type K8S
        annotation:
          additionalProperties: true
          type: object
          title: Annotation
          description: The annotation of the artifact
        flow_name:
          type: string
          title: Flow Name
          description: The name of the flow to which the artifact belongs
        git_commit:
          type: string
          title: Git Commit
          description: The git commit of the artifact
        commit_url:
          type: string
          title: Commit Url
          description: The URL to the git commit of the artifact
        html_url:
          type: string
          title: Html Url
          description: The HTML URL to the artifact
        flow_html_url:
          type: string
          title: Flow Html Url
          description: The HTML URL to the flow to which the artifact belongs
        deployment_diff:
          anyOf:
            - $ref: '#/components/schemas/DeploymentDiff'
            - type: 'null'
          description: >-
            The deployment_diff of the first entry in flows. Always present, and
            null when nothing was replaced: the first artifact from this flow to
            run in this environment, or an artifact with no provenance
        commit_lead_time:
          anyOf:
            - type: number
            - type: 'null'
          title: Commit Lead Time
          description: >-
            The lead time of the commit; the diff between the commit timestamp
            and the time the artifact started running
        flows:
          items:
            $ref: '#/components/schemas/SnapshotArtifactFlow'
          type: array
          title: Flows
          description: The list of flows in which the artifact was reported
        ecs_context:
          anyOf:
            - $ref: '#/components/schemas/SnapshotArtifactECSContext'
            - type: 'null'
          description: The ECS context of the artifact. Only available for ECS environments
        cloud_run_context:
          anyOf:
            - $ref: '#/components/schemas/SnapshotArtifactCloudRunContext'
            - type: 'null'
          description: >-
            The Cloud Run context of the artifact. Only available for Cloud Run
            environments
      type: object
      required:
        - name
        - fingerprint
        - creationTimestamp
        - annotation
        - flow_name
        - git_commit
        - commit_url
        - html_url
        - flow_html_url
        - flows
      title: SnapshotArtifact
    PolicyEvaluationResponse:
      properties:
        policy_version:
          type: integer
          title: Policy Version
        status:
          type: string
          enum:
            - COMPLIANT
            - NON-COMPLIANT
          title: Status
        rule_evaluations:
          items:
            $ref: '#/components/schemas/RuleEvaluationResponse'
          type: array
          title: Rule Evaluations
          default: []
        policy_name:
          type: string
          title: Policy Name
          readOnly: true
      type: object
      required:
        - policy_version
        - status
        - policy_name
      title: PolicyEvaluationResponse
      description: represents the result of evaluating one artifact against one policy
    DeploymentDiff:
      properties:
        diff_url:
          type: string
          title: Diff Url
          description: >-
            The URL comparing previous_git_commit with the artifact's git
            commit, at the git provider hosting the repository. Empty when the
            commit URL is not recognised as GitHub, GitLab, Bitbucket or Azure
            DevOps
        previous_git_commit:
          type: string
          title: Previous Git Commit
          description: The git commit of the replaced artifact
        previous_git_commit_url:
          type: string
          title: Previous Git Commit Url
          description: The URL to the git commit of the replaced artifact
        previous_fingerprint:
          type: string
          pattern: ^[a-f0-9]{64}$
          title: Previous Fingerprint
          description: The fingerprint of the replaced artifact
        previous_artifact_name:
          type: string
          title: Previous Artifact Name
          description: >-
            The name the replaced artifact was running under in the environment,
            which need not match the name of this artifact
        previous_artifact_compliance_state:
          type: string
          title: Previous Artifact Compliance State
          description: >-
            The compliance state of the replaced artifact in its flow, as of
            this request: COMPLIANT, NON-COMPLIANT or INCOMPLETE
        previous_running:
          type: boolean
          title: Previous Running
          description: >-
            Whether the replaced artifact is still running elsewhere in this
            snapshot
        previous_trail_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Trail Name
          description: The name of the trail the replaced artifact was attested to
        previous_template_reference_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Template Reference Name
          description: The template_reference_name the replaced artifact was reported with
      type: object
      required:
        - diff_url
        - previous_git_commit
        - previous_git_commit_url
        - previous_fingerprint
        - previous_artifact_name
        - previous_artifact_compliance_state
        - previous_running
        - previous_trail_name
        - previous_template_reference_name
      title: DeploymentDiff
      description: |-
        The change from the artifact this one replaced in the environment.

        The replaced artifact is the one from the same flow, and the same
        template_reference_name when this artifact was reported with one, that
        most recently started running in this environment before this artifact
        started, under any name and with a different fingerprint.
    SnapshotArtifactFlow:
      properties:
        flow_name:
          type: string
          title: Flow Name
          description: The name of the flow to which the artifact belongs
        trail_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Trail Name
          description: The name of the trail to which the artifact belongs
        template_reference_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Template Reference Name
          description: The template_reference_name this artifact was reported with
        git_commit:
          type: string
          title: Git Commit
          description: The git commit of the artifact
        commit_url:
          type: string
          title: Commit Url
          description: The URL to the git commit of the artifact
        git_commit_info:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Git Commit Info
          description: The git commit info of the artifact
        html_url:
          type: string
          title: Html Url
          description: The HTML URL to the artifact
        flow_html_url:
          type: string
          title: Flow Html Url
          description: The HTML URL to the flow to which the artifact belongs
        deployment_diff:
          anyOf:
            - $ref: '#/components/schemas/DeploymentDiff'
            - type: 'null'
          description: >-
            The change from the artifact this one replaced in the environment.
            Always present, and null when nothing was replaced: the first
            artifact from this flow to run in this environment, or an artifact
            with no provenance
        commit_lead_time:
          anyOf:
            - type: number
            - type: 'null'
          title: Commit Lead Time
          description: >-
            The lead time of the commit; the diff between the commit timestamp
            and the time the artifact started running
        artifact_compliance_in_flow:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Artifact Compliance In Flow
          description: Whether the artifact is compliant in the flow
        flow_reasons_for_non_compliance:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Flow Reasons For Non Compliance
          description: The list of reasons for non-compliance of an artifact in the flow
      type: object
      required:
        - flow_name
        - git_commit
        - commit_url
        - html_url
        - flow_html_url
      title: SnapshotArtifactFlow
    SnapshotArtifactECSContext:
      properties:
        task_arn:
          anyOf:
            - type: string
            - type: 'null'
          title: Task Arn
          description: The ARN of the ECS task
        cluster_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Cluster Name
          description: The name of the ECS cluster. Only available for ECS environments
        service_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Service Name
          description: The name of the ECS service. Only available for ECS environments
      type: object
      title: SnapshotArtifactECSContext
    SnapshotArtifactCloudRunContext:
      properties:
        kind:
          anyOf:
            - type: string
            - type: 'null'
          title: Kind
          description: 'Cloud Run resource kind: "service" or "job"'
        revision_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Revision Name
          description: The name of the Cloud Run revision (kind=service)
        service_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Service Name
          description: The name of the Cloud Run service (kind=service)
        job_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Job Name
          description: The name of the Cloud Run job (kind=job)
      type: object
      title: SnapshotArtifactCloudRunContext
    RuleEvaluationResponse:
      properties:
        rule:
          $ref: '#/components/schemas/PolicyRuleDefinition'
        satisfied:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Satisfied
        ignored:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Ignored
          default: false
        resolutions:
          items:
            $ref: '#/components/schemas/RuleResolutionResponse'
          type: array
          title: Resolutions
          default: []
      type: object
      required:
        - rule
      title: RuleEvaluationResponse
      description: represents one policy rule evaluation result
    PolicyRuleDefinition:
      properties:
        type:
          type: string
          enum:
            - provenance
            - trail-compliance
            - attestation
          title: Type
        definition:
          anyOf:
            - $ref: '#/components/schemas/RequiredAttestationRule'
            - $ref: '#/components/schemas/BooleanRule'
          title: Definition
      type: object
      required:
        - type
        - definition
      title: PolicyRuleDefinition
    RuleResolutionResponse:
      properties:
        type:
          type: string
          enum:
            - missing_attestation
            - non_compliant_attestation
            - non_compliant_in_trail
            - no_provenance
            - missing_provenance
            - legacy_flow
            - rule_satisfied
            - rule_not_applicable
          title: Type
        context:
          anyOf:
            - $ref: '#/components/schemas/ContextResponse'
            - type: 'null'
      type: object
      required:
        - type
      title: RuleResolutionResponse
    RequiredAttestationRule:
      properties:
        if:
          anyOf:
            - $ref: '#/components/schemas/PolicyExpression'
            - type: 'null'
        name:
          type: string
          title: Name
          description: Attestation name; default * matches any.
          default: '*'
        type:
          anyOf:
            - type: string
              enum:
                - generic
                - junit
                - snyk
                - pull_request
                - jira
                - sonar
            - type: string
              pattern: ^custom:.*$
            - type: string
              enum:
                - decision
                - sbom
            - type: string
              const: '*'
          title: Type
          description: Built-in attestation type, custom:... reference, or wildcard *.
        must_be_compliant:
          type: boolean
          title: Must Be Compliant
          default: true
        for_control:
          anyOf:
            - type: string
            - type: 'null'
          title: For Control
          description: >-
            Control identifier this decision attestation must satisfy. Only
            valid when type is 'decision'.
      additionalProperties: false
      type: object
      required:
        - type
      title: RequiredAttestationRule
    BooleanRule:
      properties:
        required:
          type: boolean
          title: Required
          default: false
        exceptions:
          items:
            $ref: '#/components/schemas/ConditionalRule'
          type: array
          title: Exceptions
          default: []
      additionalProperties: false
      type: object
      title: BooleanRule
    ContextResponse:
      additionalProperties: true
      type: object
    PolicyExpression:
      properties:
        text:
          type: string
          title: Text
      type: object
      required:
        - text
      title: PolicyExpression
      description: >-
        Boolean expression evaluated against flow/artifact context. In YAML this
        is often written as a string wrapped in ${{ ... }}. A missing (None)
        context value never matches: matches() and the ordering comparisons (<,
        >, <=, >=) return false if either operand is missing, and `in` is a
        list-membership test that returns false unless its right-hand side is a
        list containing the left-hand value.
    ConditionalRule:
      properties:
        if:
          anyOf:
            - $ref: '#/components/schemas/PolicyExpression'
            - type: 'null'
      additionalProperties: false
      type: object
      title: ConditionalRule
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````