Base URL
All file operations use the sandbox’spublic_host:
Copy
{sandbox_public_host}/files/{operation}
Authentication
Copy
Authorization: Bearer {auth_token}
Endpoints
Read File
Copy
GET /files/read?path=/workspace/file.txt
Copy
curl -H "Authorization: Bearer {auth_token}" \
"https://1761048129dsaqav4n.hopx.dev/files/read?path=/workspace/file.txt"
Copy
import requests
response = requests.get(
f"{sandbox_public_host}/files/read",
headers={"Authorization": f"Bearer {auth_token}"},
params={"path": "/workspace/file.txt"}
)
content = response.json()["content"]
Copy
const response = await fetch(
`${sandboxPublicHost}/files/read?path=${encodeURIComponent('/workspace/file.txt')}`,
{
headers: {
'Authorization': `Bearer ${authToken}`
}
}
);
const data = await response.json();
const content = data.content;
Write File
Copy
POST /files/write
Copy
{
"path": "/workspace/file.txt",
"content": "Hello, World!",
"mode": "0644"
}
Copy
curl -X POST https://1761048129dsaqav4n.hopx.dev/files/write \
-H "Authorization: Bearer {auth_token}" \
-H "Content-Type: application/json" \
-d '{
"path": "/workspace/file.txt",
"content": "Hello, World!"
}'
Copy
data = {
"path": "/workspace/file.txt",
"content": "Hello, World!",
"mode": "0644"
}
response = requests.post(
f"{sandbox_public_host}/files/write",
headers={"Authorization": f"Bearer {auth_token}"},
json=data
)
Copy
await fetch(`${sandboxPublicHost}/files/write`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${authToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
path: '/workspace/file.txt',
content: 'Hello, World!'
})
});
List Directory
Copy
GET /files/list?path=/workspace
Copy
curl -H "Authorization: Bearer {auth_token}" \
"https://1761048129dsaqav4n.hopx.dev/files/list?path=/workspace"
Copy
response = requests.get(
f"{sandbox_public_host}/files/list",
headers={"Authorization": f"Bearer {auth_token}"},
params={"path": "/workspace"}
)
files = response.json()["files"]
Copy
const response = await fetch(
`${sandboxPublicHost}/files/list?path=${encodeURIComponent('/workspace')}`,
{
headers: {
'Authorization': `Bearer ${authToken}`
}
}
);
const data = await response.json();
const files = data.files;
Upload File
Copy
POST /files/upload
Content-Type: multipart/form-data
Copy
curl -X POST https://1761048129dsaqav4n.hopx.dev/files/upload \
-H "Authorization: Bearer {auth_token}" \
-F "file=@local_file.txt" \
-F "path=/workspace/remote_file.txt"
Copy
with open('local_file.txt', 'rb') as f:
files = {'file': f}
data = {'path': '/workspace/remote_file.txt'}
response = requests.post(
f"{sandbox_public_host}/files/upload",
headers={"Authorization": f"Bearer {auth_token}"},
files=files,
data=data
)
Download File
Copy
GET /files/download?path=/workspace/file.txt
Copy
curl -H "Authorization: Bearer {auth_token}" \
"https://1761048129dsaqav4n.hopx.dev/files/download?path=/workspace/file.txt" \
-o downloaded_file.txt
Copy
response = requests.get(
f"{sandbox_public_host}/files/download",
headers={"Authorization": f"Bearer {auth_token}"},
params={"path": "/workspace/file.txt"}
)
with open('downloaded_file.txt', 'wb') as f:
f.write(response.content)
Copy
const response = await fetch(
`${sandboxPublicHost}/files/download?path=${encodeURIComponent('/workspace/file.txt')}`,
{
headers: {
'Authorization': `Bearer ${authToken}`
}
}
);
const blob = await response.blob();
// Save blob to file
Related
- Code Execution - Execute code
- Commands - Run shell commands

