curl --request GET \
--url https://sandbox.{domain}/files \
--header 'E2b-Sandbox-Id: <e2b-sandbox-id>' \
--header 'E2b-Sandbox-Port: <e2b-sandbox-port>' \
--header 'X-Access-Token: <api-key>'import requests
url = "https://sandbox.{domain}/files"
headers = {
"E2b-Sandbox-Id": "<e2b-sandbox-id>",
"E2b-Sandbox-Port": "<e2b-sandbox-port>",
"X-Access-Token": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'E2b-Sandbox-Id': '<e2b-sandbox-id>',
'E2b-Sandbox-Port': '<e2b-sandbox-port>',
'X-Access-Token': '<api-key>'
}
};
fetch('https://sandbox.{domain}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.{domain}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"E2b-Sandbox-Id: <e2b-sandbox-id>",
"E2b-Sandbox-Port: <e2b-sandbox-port>",
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.{domain}/files"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("E2b-Sandbox-Id", "<e2b-sandbox-id>")
req.Header.Add("E2b-Sandbox-Port", "<e2b-sandbox-port>")
req.Header.Add("X-Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://sandbox.{domain}/files")
.header("E2b-Sandbox-Id", "<e2b-sandbox-id>")
.header("E2b-Sandbox-Port", "<e2b-sandbox-port>")
.header("X-Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.{domain}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["E2b-Sandbox-Id"] = '<e2b-sandbox-id>'
request["E2b-Sandbox-Port"] = '<e2b-sandbox-port>'
request["X-Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body"<string>"{
"message": "path '/home/user/docs' is a directory",
"code": 400
}{
"message": "error looking up user 'nonexistent': user: unknown user nonexistent",
"code": 401
}{
"message": "path '/home/user/missing.txt' does not exist",
"code": 404
}{
"message": "no acceptable encoding found, supported: [identity, gzip]",
"code": 406
}{
"message": "error opening file '/home/user/file.txt': permission denied",
"code": 500
}{
"message": "<string>",
"code": 123,
"sandboxID": "<string>"
}Download a file
curl --request GET \
--url https://sandbox.{domain}/files \
--header 'E2b-Sandbox-Id: <e2b-sandbox-id>' \
--header 'E2b-Sandbox-Port: <e2b-sandbox-port>' \
--header 'X-Access-Token: <api-key>'import requests
url = "https://sandbox.{domain}/files"
headers = {
"E2b-Sandbox-Id": "<e2b-sandbox-id>",
"E2b-Sandbox-Port": "<e2b-sandbox-port>",
"X-Access-Token": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'E2b-Sandbox-Id': '<e2b-sandbox-id>',
'E2b-Sandbox-Port': '<e2b-sandbox-port>',
'X-Access-Token': '<api-key>'
}
};
fetch('https://sandbox.{domain}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.{domain}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"E2b-Sandbox-Id: <e2b-sandbox-id>",
"E2b-Sandbox-Port: <e2b-sandbox-port>",
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.{domain}/files"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("E2b-Sandbox-Id", "<e2b-sandbox-id>")
req.Header.Add("E2b-Sandbox-Port", "<e2b-sandbox-port>")
req.Header.Add("X-Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://sandbox.{domain}/files")
.header("E2b-Sandbox-Id", "<e2b-sandbox-id>")
.header("E2b-Sandbox-Port", "<e2b-sandbox-port>")
.header("X-Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.{domain}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["E2b-Sandbox-Id"] = '<e2b-sandbox-id>'
request["E2b-Sandbox-Port"] = '<e2b-sandbox-port>'
request["X-Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body"<string>"{
"message": "path '/home/user/docs' is a directory",
"code": 400
}{
"message": "error looking up user 'nonexistent': user: unknown user nonexistent",
"code": 401
}{
"message": "path '/home/user/missing.txt' does not exist",
"code": 404
}{
"message": "no acceptable encoding found, supported: [identity, gzip]",
"code": 406
}{
"message": "error opening file '/home/user/file.txt': permission denied",
"code": 500
}{
"message": "<string>",
"code": 123,
"sandboxID": "<string>"
}Authorizations
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).
Headers
Identifier of the target sandbox. Routes the request to that sandbox's envd over the shared sandbox host.
Port envd listens on inside the sandbox (default 49983).
Query Parameters
Path to the file, URL encoded. Can be relative to the user's home directory (e.g. "file.txt" resolves to ~/file.txt).
User for setting file ownership and resolving relative paths. Defaults to the sandbox's default user.
Signature used for file access permission verification.
Unix timestamp (seconds) after which the signature expires. Only used with the signature parameter.
Response
Entire file downloaded successfully.
The raw file content
Was this page helpful?