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

# Download a file



## OpenAPI

````yaml /openapi-public.yaml get /files
openapi: 3.1.0
info:
  title: E2B API
  version: 0.1.0
  description: >-
    Complete E2B developer API. Platform endpoints are served on api.e2b.app.
    Sandbox endpoints (envd) are served on the shared sandbox host
    (sandbox.e2b.app); target a specific sandbox with the E2b-Sandbox-Id and
    E2b-Sandbox-Port headers.
servers:
  - url: https://api.e2b.app
    description: E2B Platform API
security: []
tags:
  - name: Sandboxes
  - name: Templates
  - name: Tags
  - name: Volumes
  - name: Envd
  - name: Filesystem
  - name: Process
  - name: Teams
  - name: Secrets
  - name: Events
  - name: Webhooks
paths:
  /files:
    servers:
      - url: https://sandbox.e2b.app
        description: Sandbox API (envd) - routes using sandbox ID and port headers
    get:
      tags:
        - Filesystem
      summary: Download a file
      operationId: downloadFile
      parameters:
        - name: E2b-Sandbox-Id
          in: header
          required: true
          description: >-
            Identifier of the target sandbox. Routes the request to that
            sandbox's envd over the shared sandbox host.
          schema:
            type: string
        - name: E2b-Sandbox-Port
          in: header
          required: true
          description: Port envd listens on inside the sandbox (default 49983).
          schema:
            type: integer
            default: 49983
          example: 49983
        - $ref: '#/components/parameters/FilePath'
        - $ref: '#/components/parameters/User'
        - $ref: '#/components/parameters/Signature'
        - $ref: '#/components/parameters/SignatureExpiration'
        - name: Range
          in: header
          description: Byte range to download.
          schema:
            type: string
          example: bytes=2-5
        - name: If-Modified-Since
          in: header
          description: Return 304 if the file has not changed since this HTTP date.
          schema:
            type: string
          example: Tue, 01 Jan 2030 00:00:00 GMT
        - name: Accept-Encoding
          in: header
          description: >-
            Supported transfer encodings include gzip and identity. Range and
            conditional requests require acceptable identity encoding.
          schema:
            type: string
          example: identity
      responses:
        '200':
          description: >-
            Entire file downloaded successfully. The Content-Type depends on the
            file. A gzip response uses the file extension's media type, or
            application/octet-stream as fallback.
          content:
            '*/*':
              schema:
                type: string
                format: binary
          headers:
            Accept-Ranges:
              schema:
                type: string
                example: bytes
            Last-Modified:
              schema:
                type: string
              description: File modification time as an HTTP date.
            Content-Length:
              schema:
                type: integer
              description: Response length when known.
        '206':
          description: >-
            Partial file content for a satisfiable Range request. Content-Type
            depends on the file, or is multipart/byteranges for multiple ranges.
          headers:
            Accept-Ranges:
              schema:
                type: string
                example: bytes
            Last-Modified:
              schema:
                type: string
              description: File modification time as an HTTP date.
            Content-Length:
              schema:
                type: integer
              description: Response length when known.
            Content-Range:
              description: Range returned for a single-range response.
              schema:
                type: string
                example: bytes 2-5/10
          content:
            '*/*':
              schema:
                type: string
                format: binary
        '304':
          description: >-
            The file has not changed according to the conditional request. No
            response body.
          headers:
            Last-Modified:
              schema:
                type: string
              description: File modification time as an HTTP date.
        '400':
          description: >-
            Invalid path The sandbox proxy rejects missing or invalid routing
            information.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: path '/home/user/docs' is a directory
                code: 400
            text/plain:
              schema:
                type: string
              examples:
                missingRoutingHeader:
                  summary: >-
                    The sandbox proxy rejects missing or invalid routing
                    information.
                  value: |
                    missing header
        '401':
          description: >-
            Invalid user Sandbox access-token or signature authentication
            failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                upstream:
                  value:
                    message: >-
                      error looking up user 'nonexistent': user: unknown user
                      nonexistent
                    code: 401
                sandboxAuthentication:
                  summary: Missing or invalid sandbox credentials
                  value:
                    code: 401
                    message: missing signature query parameter
        '404':
          description: File not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: path '/home/user/missing.txt' does not exist
                code: 404
        '406':
          description: Requested encoding is not supported
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unsupportedEncoding:
                  value:
                    code: 406
                    message: >-
                      error parsing Accept-Encoding: no acceptable encoding
                      found, supported: [gzip]
                rangeRequiresIdentity:
                  value:
                    code: 406
                    message: >-
                      identity encoding not acceptable for Range or conditional
                      request
        '416':
          description: >-
            The requested byte range is invalid or does not overlap the file.
            This is a plain-text error from the file server.
          headers:
            Content-Range:
              description: File length for an unsatisfiable range.
              schema:
                type: string
                example: bytes */10
          content:
            text/plain:
              schema:
                type: string
              examples:
                rangeDoesNotOverlap:
                  value: |
                    invalid range: failed to overlap
        '500':
          description: >-
            Internal server error The sandbox proxy encountered an unexpected
            routing error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: 'error opening file ''/home/user/file.txt'': permission denied'
                code: 500
            text/plain:
              schema:
                type: string
              examples:
                routingFailure:
                  summary: The sandbox proxy encountered an unexpected routing error.
                  value: |
                    Unexpected error when routing request: invalid sandbox port
        '502':
          description: >-
            The sandbox proxy could not find the sandbox. Browser navigation may
            receive an HTML error page.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxRoutingError'
              examples:
                sandboxNotFound:
                  value:
                    sandboxId: sandbox-id
                    message: The sandbox was not found
                    code: 502
            text/html:
              schema:
                type: string
      security:
        - SandboxAccessTokenAuth: []
components:
  parameters:
    FilePath:
      name: path
      in: query
      required: false
      description: >-
        Path to the file, URL encoded. Can be relative to the user's home
        directory (e.g. "file.txt" resolves to ~/file.txt).
      schema:
        type: string
    User:
      name: username
      in: query
      required: false
      description: >-
        User for setting file ownership and resolving relative paths. Defaults
        to the sandbox's default user.
      schema:
        type: string
    Signature:
      name: signature
      in: query
      required: false
      description: Signature used for file access permission verification.
      schema:
        type: string
    SignatureExpiration:
      name: signature_expiration
      in: query
      required: false
      description: >-
        Unix timestamp (seconds) after which the signature expires. Only used
        with the signature parameter.
      schema:
        type: integer
  schemas:
    Error:
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
          description: Error code
        error_code:
          type: string
          description: >-
            Machine-readable semantic error code. Not a closed set; initial
            values: sandbox_capacity_unavailable, sandbox_placement_timeout,
            sandbox_no_compatible_node, sandbox_create_failed,
            internal_server_error.
        message:
          type: string
          description: Error
      type: object
    SandboxRoutingError:
      type: object
      required:
        - sandboxId
        - message
        - code
      properties:
        sandboxId:
          type: string
        message:
          type: string
        code:
          type: integer
  securitySchemes:
    SandboxAccessTokenAuth:
      type: apiKey
      in: header
      name: X-Access-Token
      description: >-
        Sandbox access token (`envdAccessToken`) for authenticating requests to
        a running sandbox. Returned by: [POST
        /sandboxes](/api-reference/sandboxes/create-sandbox) (on create), [POST
        /sandboxes/{sandboxID}/connect](/api-reference/sandboxes/connect-to-sandbox)
        (on connect), [POST
        /sandboxes/{sandboxID}/resume](/api-reference/sandboxes/resume-sandbox)
        (on resume), and [GET
        /sandboxes/{sandboxID}](/api-reference/sandboxes/get-sandbox) (for
        running or paused sandboxes).

````