> ## 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.

# Get file tree

> Get file tree snapshot. Either one of workspace, branch or commit ID needs to be specified as ref ID



## OpenAPI

````yaml get /repos/{repo_id}/trees/{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}/trees/{ref_id}:
    get:
      tags:
        - Repository Manipulation
      summary: >-
        Get file tree snapshot. Either one of workspace, branch or commit ID
        needs to be specified as ref ID.
      operationId: src.handlersv2.tree.filetree
      parameters:
        - $ref: '#/components/parameters/RepoParam'
        - $ref: '#/components/parameters/RefParam'
        - $ref: '#/components/parameters/FileWalkRecurseParam'
        - $ref: '#/components/parameters/PageSkip'
        - $ref: '#/components/parameters/FileEntriesLimit'
        - $ref: '#/components/parameters/DirOffsetItemName'
        - $ref: '#/components/parameters/IncludeDeletedItemsParam'
        - $ref: '#/components/parameters/WorkspaceJournalOrdinalIdParam'
        - $ref: '#/components/parameters/TreeItemNameQueryParam'
        - $ref: '#/components/parameters/DirsOnlyParam'
      responses:
        '200':
          $ref: '#/components/responses/FileEntryList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '412':
          $ref: '#/components/responses/PreconditionFailed'
        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.
    FileWalkRecurseParam:
      in: query
      name: recurse
      schema:
        type: boolean
        default: true
      description: Specifies if to recursively iterate file tree to next directory levels
    PageSkip:
      in: query
      name: skip
      schema:
        type: integer
        example: 17
        minimum: 0
      description: Skip a number of items returned from a listing api
    FileEntriesLimit:
      in: query
      name: limit
      schema:
        type: integer
        example: 17
        minimum: 1
      description: Limit the number of entries returned from walk
    DirOffsetItemName:
      in: query
      name: offset
      schema:
        type: string
        example: file.ext
      description: Offset item name in directory when iterating its entries (non-inclusive)
    IncludeDeletedItemsParam:
      in: query
      name: include_deleted
      schema:
        type: boolean
        default: false
      description: Should the tree contain also deleted items or omit them from response
    WorkspaceJournalOrdinalIdParam:
      in: query
      name: workspace_journal_ordinal_id
      schema:
        $ref: '#/components/schemas/WorkspaceJournalOrdinalId'
      description: The ordinal ID of the journal entry the walk references, if applicable
    TreeItemNameQueryParam:
      in: query
      name: item_name_query
      schema:
        type: string
        example: abcd
        minLength: 3
        maxLength: 32
      description: >-
        A query string to test against item name, only matching items will be
        collected
    DirsOnlyParam:
      in: query
      name: dirs_only
      schema:
        type: boolean
        default: false
      description: Return only directories in the file tree walk
  responses:
    FileEntryList:
      description: Success
      content:
        application/json:
          schema:
            type: object
            properties:
              object:
                type: string
                enum:
                  - FileEntry
              items:
                type: array
                items:
                  $ref: '#/components/schemas/FileEntry'
              workspace_journal_ordinal_id:
                $ref: '#/components/schemas/WorkspaceJournalOrdinalId'
            required:
              - object
              - items
    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'
    PreconditionFailed:
      description: The specified resource is no longer up to date
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    WorkspaceJournalOrdinalId:
      type: integer
      format: uint64
      description: An ordinal ID of a workspace journal entry
    FileEntry:
      type: object
      properties:
        path:
          type: string
          example: hello.cc
        prev_path:
          type: string
          description: Optional hint in case the item was renamed or moved
        status:
          $ref: '#/components/schemas/ObjectStatus'
        mode:
          $ref: '#/components/schemas/FileMode'
        mtime:
          type: string
          format: date-time
        blob:
          type: object
          properties:
            storage_uri:
              $ref: '#/components/schemas/StorageUri'
            storage_backend:
              $ref: '#/components/schemas/StorageBackend'
            size:
              type: integer
              format: int64
              description: Size in bytes
            sha:
              type: string
          required:
            - storage_uri
            - storage_backend
            - size
            - sha
      required:
        - path
        - status
        - size
        - mode
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 403
        detail:
          type: string
          example: User not authorized to perform the requested action on the resource
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
    ObjectStatus:
      type: integer
      enum:
        - 1
        - 2
        - 3
        - 4
      description: 'One of: 1 - INTACT, 2 - ADDED, 3 - MODIFIED, 4 - DELETED'
      x-ogen-enum-naming:
        '1': ObjectStatus_INTACT
        '2': ObjectStatus_ADDED
        '3': ObjectStatus_MODIFIED
        '4': ObjectStatus_DELETED
    FileMode:
      type: integer
      description: The file mode (as Unix mode)
      enum:
        - 16877
        - 33188
        - 33261
        - 40960
      x-ogen-enum-naming:
        '16877': FileMode_TREE
        '33188': FileMode_FILE
        '33261': FileMode_EXECUTABLE
        '40960': FileMode_SYMLINK
    StorageUri:
      type: string
      description: Coupled with storage_backend, a uri to storage location
      example: repo_id/2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
    StorageBackend:
      type: integer
      enum:
        - 1
        - 2
      description: 'One of: 1 - EFS, 2 - S3'
      x-ogen-enum-naming:
        '1': StorageBackend_EFS
        '2': StorageBackend_S3
  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

````