# Download a file (/docs/api-reference/filesystem/download-a-file)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 1256 · updated: 2026-07-30 -->
Related: [Upload a file and ensure the parent directories exist. If the file exists, it will be overwritten.](/docs/api-reference/filesystem/upload-a-file-and-ensure-the-parent-directories-exist-if-the-file-exists-it-will-be-overwritten.md), [CreateWatcher](/docs/api-reference/filesystem/createwatcher.md), [GetWatcherEvents](/docs/api-reference/filesystem/getwatcherevents.md), [ListDir](/docs/api-reference/filesystem/listdir.md), [MakeDir](/docs/api-reference/filesystem/makedir.md), [Move](/docs/api-reference/filesystem/move.md)

# Download a file

`GET /files`

Download a file

## OpenAPI

```json
{
  "security": [
    {
      "SandboxAccessTokenAuth": []
    }
  ],
  "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
      }
    },
    {
      "name": "path",
      "in": "query",
      "required": false,
      "description": "Path to the file, URL encoded. Can be relative to user's home directory.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "username",
      "in": "query",
      "required": false,
      "description": "User used for setting the owner, or resolving relative paths.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "signature",
      "in": "query",
      "required": false,
      "description": "Signature used for file access permission verification.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "signature_expiration",
      "in": "query",
      "required": false,
      "description": "Signature expiration used for defining the expiration time of the signature.",
      "schema": {
        "type": "integer"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Entire file downloaded successfully.",
      "content": {
        "application/octet-stream": {
          "schema": {
            "type": "string",
            "format": "binary",
            "description": "The file content"
          }
        }
      }
    },
    "400": {
      "description": "Invalid path",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "401": {
      "description": "Invalid user",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "404": {
      "description": "File not found",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "500": {
      "description": "Internal server error",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "502": {
      "description": "Sandbox not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "sandboxID",
              "message",
              "code"
            ],
            "properties": {
              "message": {
                "type": "string",
                "description": "Error message"
              },
              "code": {
                "type": "integer",
                "description": "Error code"
              },
              "sandboxID": {
                "type": "string",
                "description": "Identifier of the sandbox"
              }
            }
          }
        }
      }
    }
  }
}
```
