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

# Download file tree snapshot

> Get URL to file tree snapshot. Either one of workspace, branch or commit ID needs to be specified as ref ID. If the requested commit doesn't have a snapshot, the endpoint will return the nearest available ancestor snapshot along with the `commit_id` of that snapshot.



## OpenAPI

````yaml get /repos/{repo_id}/tree_snapshot/{ref_id}
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/tree_snapshot/{ref_id}:
    get:
      tags:
        - Repository Manipulation
      summary: Download file tree snapshot
      description: >-
        Get URL to file tree snapshot. Either one of workspace, branch or commit
        ID needs to be specified as ref ID. If the requested commit doesn't have
        a snapshot, the endpoint will return the nearest available ancestor
        snapshot along with the `commit_id` of that snapshot.
      operationId: src.handlersv2.tree_snapshot.tree_snapshot
      parameters:
        - $ref: '#/components/parameters/RepoParam'
        - $ref: '#/components/parameters/RefParam'
      responses:
        '200':
          description: >-
            Pre-signed URL for downloading the tree snapshot stored in
            S3-compatible storage. The `commit_id` indicates which commit's
            snapshot is being returned - this may be an older ancestor commit if
            the requested commit doesn't have a snapshot available.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/DownloadUrl'
                  - $ref: '#/components/schemas/CommitId'
        '303':
          description: Snapshot is not available, client should try a different method
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '405':
          $ref: '#/components/responses/Error'
        default:
          $ref: '#/components/responses/Error'
      security:
        - OAuth2:
            - coreapi/write
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
    RefParam:
      in: path
      name: ref_id
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      required: true
      description: An ID of a workspace, branch or commit.
  schemas:
    DownloadUrl:
      type: object
      description: A pre-signed URL to download a file from S3
      properties:
        url:
          type: string
          format: uri
          description: Pre-signed URL to download the file
      required:
        - url
    CommitId:
      type: object
      properties:
        commit_id:
          type: string
          example: example_id
          minLength: 3
          maxLength: 128
      required:
        - commit_id
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
  responses:
    BadRequest:
      description: The request does not meet the required conditions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````