Skip to main content
POST
/
files
Upload a file and ensure the parent directories exist. If the file exists, it will be overwritten.
curl --request POST \
  --url https://{port}-{sandboxID}.e2b.app/files \
  --header 'Content-Type: multipart/form-data' \
  --header 'X-Access-Token: <api-key>' \
  --form file='@example-file'
[
  {
    "path": "/home/user/hello.txt",
    "name": "hello.txt",
    "type": "file"
  }
]

Authorizations

X-Access-Token
string
header
required

Sandbox access token (envdAccessToken) for authenticating requests to a running sandbox. Returned by: POST /sandboxes (on create), POST /sandboxes/{sandboxID}/connect (on connect), POST /sandboxes/{sandboxID}/resume (on resume), and GET /sandboxes/{sandboxID} (for running or paused sandboxes).

Query Parameters

path
string

Path to the file, URL encoded. Can be relative to the user's home directory (e.g. "file.txt" resolves to ~/file.txt).

username
string

User for setting file ownership and resolving relative paths. Defaults to the sandbox's default user.

signature
string

Signature used for file access permission verification.

signature_expiration
integer

Unix timestamp (seconds) after which the signature expires. Only used with the signature parameter.

Body

file
file

Response

The file was uploaded successfully.

path
string
required

Path to the file

name
string
required

Name of the file

type
enum<string>
required

Type of the file

Available options:
file,
directory