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

# Read a file or list a directory

> **Without `list`:** downloads the file at `path` as raw bytes (`application/octet-stream`), following a symlink. Its length is declared in `Content-Length` before the content: **a response shorter than its `Content-Length` was cut** (the sandbox stopped answering, the file shrank while it was read, or the time budget ran out); retry. A file over 64 MiB is `file_too_large`, sent before any content. A directory is `path_type_mismatch` (list it with `list=true`), and so is anything that's neither a file nor a directory (a device, FIFO or socket). Files of at most 1 MiB, pseudo-files included (`/proc`, `/sys`), are read whole inside the sandbox first, so their real length is declared; reading a pseudo-file can use up to 64 MiB of the sandbox's own memory.

**With `list=true`:** lists the directory at `path` (a symlink there is followed) as JSON, sorted by name in byte order and paged with `page[number]` and `page[size]`. `.` and `..` aren't listed; hidden entries are. Symlinks inside are listed as `symlink`, with their own size and time, never followed; devices, FIFOs and sockets are `other`. A directory with more than 100000 entries is `directory_too_large`. Each page is a fresh listing, so entries can move between pages while the directory changes. Names that aren't valid UTF-8 are shown with each invalid byte replaced by U+FFFD, so they can't be addressed through these endpoints (use an exec). Listing a file is `path_type_mismatch`.

`path` is absolute, at most 4096 bytes in UTF-8, and must be valid UTF-8 once percent-decoded; it's taken as the sandbox's kernel resolves it (`.`, `..` and `//` included). A path holding a NUL byte is `invalid_path`.

The sandbox must be running (else `sandbox_not_running`); file calls keep working during the stop's grace period, so you can fetch results from a sandbox that's ending. They run as the sandbox's own user, with its permissions: what that user may not do, or a read-only file system, is `permission_denied`. Another refusal by the sandbox's file system (no space, a name too long, a busy file or mount point, a symlink loop, an I/O error) is `file_operation_failed`, with a fixed text naming the reason. File calls don't count as activity for `idle_timeout`.

Each call has a 64 MiB limit and a time budget of about 12 s for its whole transfer, so a full-size file needs about 5.3 MiB/s between you and the API to read, and about 6.4 MiB/s to write (a write's body must arrive 2 s before the budget ends). Move larger data through Cloud Storage from an exec.



## OpenAPI

````yaml /openapi/source/external/sandboxes/sandboxes.json get /ai/sandboxes/{sandbox_id}/files
openapi: 3.1.0
info:
  title: Telnyx API
  version: 1.0.0
  description: >-
    Run a container image of your choice on a whole GPU node, each sandbox in
    its own virtual machine, for seconds or indefinitely. Run commands inside
    it, move files in and out, stream its logs, read its metrics, and pay per
    second while it runs.


    ## Preview


    GPU Sandboxes is in an invite-only preview. `GET /ai/sandbox-access` tells
    whether it is enabled for your organization.


    ## Authentication


    All endpoints require a Telnyx API key sent as a Bearer token in the
    `Authorization` header.


    ## Retries


    Every side-effecting endpoint accepts an `Idempotency-Key` header. Send one
    on `POST /ai/sandboxes` and `POST /ai/sandboxes/{sandbox_id}/execs`, so a
    retry after a lost response doesn't start (and bill) a second workload.


    ## Errors


    Errors use the standard Telnyx error body. General errors carry their
    5-digit `code` (e.g. `10009`); Sandboxes-specific errors are identified by
    their name in `title` (e.g. `quota_exceeded`).
  contact:
    email: support@telnyx.com
  x-latency-category: responsive
  x-endpoint-cost: light
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
    description: >-
      Create, find, wait for, tag and terminate sandboxes, and close the main
      process's stdin.
  - name: Sandbox execs
    description: Run commands in a running sandbox.
  - name: Sandbox files
    description: Read, write, list and delete files inside a running sandbox.
  - name: Sandbox logs
    description: The main process's stored and live output.
  - name: Sandbox metrics
    description: CPU, network, memory, disk and GPU usage.
  - name: Sandbox GPU types
    description: What you can rent, and at what price.
  - name: Sandbox access
    description: Whether Sandboxes is enabled for your organization.
paths:
  /ai/sandboxes/{sandbox_id}/files:
    get:
      tags:
        - Sandbox files
      summary: Read a file or list a directory
      description: >-
        **Without `list`:** downloads the file at `path` as raw bytes
        (`application/octet-stream`), following a symlink. Its length is
        declared in `Content-Length` before the content: **a response shorter
        than its `Content-Length` was cut** (the sandbox stopped answering, the
        file shrank while it was read, or the time budget ran out); retry. A
        file over 64 MiB is `file_too_large`, sent before any content. A
        directory is `path_type_mismatch` (list it with `list=true`), and so is
        anything that's neither a file nor a directory (a device, FIFO or
        socket). Files of at most 1 MiB, pseudo-files included (`/proc`,
        `/sys`), are read whole inside the sandbox first, so their real length
        is declared; reading a pseudo-file can use up to 64 MiB of the sandbox's
        own memory.


        **With `list=true`:** lists the directory at `path` (a symlink there is
        followed) as JSON, sorted by name in byte order and paged with
        `page[number]` and `page[size]`. `.` and `..` aren't listed; hidden
        entries are. Symlinks inside are listed as `symlink`, with their own
        size and time, never followed; devices, FIFOs and sockets are `other`. A
        directory with more than 100000 entries is `directory_too_large`. Each
        page is a fresh listing, so entries can move between pages while the
        directory changes. Names that aren't valid UTF-8 are shown with each
        invalid byte replaced by U+FFFD, so they can't be addressed through
        these endpoints (use an exec). Listing a file is `path_type_mismatch`.


        `path` is absolute, at most 4096 bytes in UTF-8, and must be valid UTF-8
        once percent-decoded; it's taken as the sandbox's kernel resolves it
        (`.`, `..` and `//` included). A path holding a NUL byte is
        `invalid_path`.


        The sandbox must be running (else `sandbox_not_running`); file calls
        keep working during the stop's grace period, so you can fetch results
        from a sandbox that's ending. They run as the sandbox's own user, with
        its permissions: what that user may not do, or a read-only file system,
        is `permission_denied`. Another refusal by the sandbox's file system (no
        space, a name too long, a busy file or mount point, a symlink loop, an
        I/O error) is `file_operation_failed`, with a fixed text naming the
        reason. File calls don't count as activity for `idle_timeout`.


        Each call has a 64 MiB limit and a time budget of about 12 s for its
        whole transfer, so a full-size file needs about 5.3 MiB/s between you
        and the API to read, and about 6.4 MiB/s to write (a write's body must
        arrive 2 s before the budget ends). Move larger data through Cloud
        Storage from an exec.
      operationId: ReadSandboxFile
      parameters:
        - description: Sandbox ID (`sb-…`).
          in: path
          name: sandbox_id
          required: true
          schema:
            maxLength: 64
            minLength: 1
            type: string
          example: sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e
        - description: >-
            Absolute path inside the sandbox, e.g. `/app/out.txt`, at most 4096
            bytes in UTF-8.
          in: query
          name: path
          required: true
          schema:
            maxLength: 4096
            minLength: 1
            pattern: ^/
            type: string
          example: /app/out/results.json
        - description: List the directory at `path` instead.
          in: query
          name: list
          required: false
          schema:
            default: false
            type: boolean
        - description: Page number (1-based).
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            minimum: 1
            type: integer
        - description: Number of items per page (max 100).
          in: query
          name: page[size]
          required: false
          schema:
            default: 20
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          description: >-
            The file's bytes (`application/octet-stream`, with `Content-Length`;
            a shorter body was cut), or with `list=true` the directory listing
            (`application/json`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileListRespData'
              example:
                data:
                  - name: results.json
                    path: /app/out/results.json
                    type: file
                    size_bytes: 18234
                    modified_at: '2026-11-13T10:42:17Z'
                  - name: checkpoints
                    path: /app/out/checkpoints
                    type: directory
                    size_bytes: 4096
                    modified_at: '2026-11-13T10:40:02Z'
                meta:
                  page_number: 1
                  page_size: 20
                  total_pages: 1
                  total_results: 2
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            Validation error: the standard Telnyx validation errors (codes such
            as 10004 missing parameter, 10015 bad request, 10025 invalid string
            length, 10026 invalid type).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
        '401':
          description: Missing or invalid API key (code 10009).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: Could not find any usable credentials in the request.
        '403':
          description: >-
            - `sandboxes_require_verification`: your account isn't fully
            verified.

            - `sandboxes_not_whitelisted`: Sandboxes isn't enabled for your
            organization (invite-only preview); `GET /ai/sandbox-access` tells
            whether it is.

            - `permission_denied`: the sandbox's user may not do this at the
            path, or its file system is read-only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: sandboxes_not_whitelisted
                    detail: The organization isn't whitelisted.
        '404':
          description: >-
            Not found (code 10005): the resource doesn't exist or belongs to
            another organization. The detail says what's missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: Sandbox not found.
        '409':
          description: >-
            - `sandbox_not_running`: the operation needs a running sandbox.

            - `path_type_mismatch`: the path is a directory where a file was
            expected, or the reverse (a parent that's a file included), or
            neither a file nor a directory.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: path_type_mismatch
                    detail: The path is a directory.
        '413':
          description: >-
            - `file_too_large`: the file is over the 64 MiB per-request limit;
            move large data through Cloud Storage.

            - `directory_too_large`: the directory has more than 100000 entries,
            so it can't be listed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: file_too_large
                    detail: The file is larger than 64 MiB.
        '422':
          description: >-
            - `invalid_path`: the path holds a NUL byte, or a write or delete
            names the reserved `/.telnyx` directory, ends in a final `.` or
            `..`, or deletes `/`.

            - `file_operation_failed`: the sandbox's file system refused for
            another stated reason: no space, a name too long, a busy file or
            mount point, a symlink loop, or an I/O error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: invalid_path
                    detail: The path is reserved.
        '503':
          description: A dependency can't answer right now (code 10037); retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10037'
                    title: Service unavailable
                    detail: A dependency can't answer right now; retry later.
components:
  schemas:
    FileListRespData:
      description: A directory listing, paged.
      properties:
        data:
          items:
            $ref: '#/components/schemas/FileEntry'
          type: array
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - data
        - meta
      type: object
    TelnyxErrors:
      description: The standard Telnyx error body.
      properties:
        errors:
          description: One or more errors.
          items:
            $ref: '#/components/schemas/TelnyxError'
          type: array
      required:
        - errors
      type: object
    FileEntry:
      description: A file or directory inside the sandbox.
      properties:
        modified_at:
          description: >-
            Last modification time, by the sandbox's own clock, shown within
            years 1–9999.
          format: date-time
          type: string
        name:
          description: Base name, e.g. `out.txt`.
          type: string
        path:
          description: Absolute path, e.g. `/app/out.txt`.
          type: string
        size_bytes:
          description: >-
            The size the sandbox's file system reports for the entry itself, in
            bytes: a file's length, a symlink's target string, a directory's own
            size (often 4096).
          type: integer
        type:
          $ref: '#/components/schemas/FileType'
      required:
        - name
        - path
        - type
        - size_bytes
        - modified_at
      type: object
    Meta:
      description: >-
        Pagination metadata for page-number lists (`page[number]` /
        `page[size]`).
      properties:
        page_number:
          description: The page returned (1-based).
          type: integer
        page_size:
          description: Items per page.
          type: integer
        total_pages:
          description: Number of pages.
          type: integer
        total_results:
          description: Number of items across all pages.
          type: integer
      required:
        - page_number
        - page_size
        - total_pages
        - total_results
      type: object
    TelnyxError:
      description: One error in the standard Telnyx error body.
      properties:
        code:
          description: >-
            Telnyx error code: a 5-digit string for general errors, e.g.
            `10009`. Sandboxes-specific errors are identified by their name in
            `title`.
          type: string
        detail:
          description: Human-readable explanation.
          type:
            - string
            - 'null'
        meta:
          description: Extra information.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorMeta'
            - type: 'null'
        source:
          description: Where the error is.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorSource'
            - type: 'null'
        title:
          description: >-
            Short, constant summary of the error. For Sandboxes-specific errors,
            the error's name, e.g. `quota_exceeded`.
          type: string
      required:
        - title
      type: object
    FileType:
      description: >-
        What the path is: a regular `file`, a `directory`, a `symlink`, or
        `other`

        (a device, FIFO or socket).
      enum:
        - file
        - directory
        - symlink
        - other
      type: string
    TelnyxErrorMeta:
      description: Extra error information.
      properties:
        url:
          default: null
          description: Documentation page for the error code.
          type:
            - string
            - 'null'
      type: object
    TelnyxErrorSource:
      description: Where in the request the error was found.
      properties:
        parameter:
          default: null
          description: Name of the offending parameter.
          type:
            - string
            - 'null'
        pointer:
          default: null
          description: JSON pointer into the request body, e.g. `/timeout`.
          type:
            - string
            - 'null'
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````