Transfer files between your local machine and sandboxes, or manage files directly inside the sandbox filesystem.
File operations use the sandbox proxy URL: https://<sandbox-id-or-name>.sandbox.tensorlake.ai Named sandboxes can use the sandbox name in place of the ID in the proxy hostname. Name-based proxy requests require an Authorization header.
Copy Files
# Copy a local file into the sandbox
tl sbx cp data.csv < sandbox-i d > :/workspace/data.csv
# Copy a file from the sandbox to local
tl sbx cp < sandbox-i d > :/workspace/data.csv ./data.csv
from tensorlake.sandbox import SandboxClient
client = SandboxClient()
sandbox = client.create_and_connect()
sandbox.write_file( "/workspace/data.csv" , b "name,score \n Alice,95 \n Bob,87" )
content = sandbox.read_file( "/workspace/data.csv" )
print ( bytes (content).decode( "utf-8" ))
curl -X PUT "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/data.csv" \
-H "Authorization: Bearer $TL_API_KEY " \
-H "Content-Type: application/octet-stream" \
--data-binary "name,score\nAlice,95\nBob,87"
curl "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/data.csv" \
-H "Authorization: Bearer $TL_API_KEY "
tl sbx cp is file-only today. Directory copy workflows should use the Python SDK or the raw file API.
Read Files
tl sbx cp < sandbox-i d > :/workspace/data.csv ./data.csv
tl sbx exec < sandbox-i d > cat /workspace/data.csv
content = sandbox.read_file( "/workspace/data.csv" )
print ( bytes (content).decode( "utf-8" ))
image_bytes = sandbox.read_file( "/workspace/chart.png" )
with open ( "chart.png" , "wb" ) as f:
f.write(image_bytes)
curl "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/data.csv" \
-H "Authorization: Bearer $TL_API_KEY "
curl "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/chart.png" \
-H "Authorization: Bearer $TL_API_KEY " \
-o chart.png
Write Files
tl sbx cp config.json < sandbox-i d > :/workspace/config.json
sandbox.write_file( "/workspace/config.json" , b '{"debug": true, "port": 8080}' )
with open ( "model.pkl" , "rb" ) as f:
sandbox.write_file( "/workspace/model.pkl" , f.read())
curl -X PUT "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/config.json" \
-H "Authorization: Bearer $TL_API_KEY " \
-H "Content-Type: application/octet-stream" \
--data-binary '{"debug": true, "port": 8080}'
curl -X PUT "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/model.pkl" \
-H "Authorization: Bearer $TL_API_KEY " \
-H "Content-Type: application/octet-stream" \
--data-binary @model.pkl
List Directory Contents
tl sbx exec < sandbox-i d > ls -la /workspace
entries = sandbox.list_directory( "/workspace" )
for entry in entries.entries:
print ( f " { entry.name } ( { entry.size } bytes)" )
curl "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files/list?path=/workspace" \
-H "Authorization: Bearer $TL_API_KEY "
Delete Files
tl sbx exec < sandbox-i d > rm -rf /workspace/temp
sandbox.delete_file( "/workspace/temp" )
curl -X DELETE "https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/files?path=/workspace/temp" \
-H "Authorization: Bearer $TL_API_KEY "
Organize Files
tl sbx exec < sandbox-i d > mkdir -p /workspace/src/components
tl sbx exec < sandbox-i d > mv /workspace/old.txt /workspace/new.txt
sandbox.run( "mkdir" , [ "-p" , "/workspace/src/components" ])
sandbox.run( "mv" , [ "/workspace/old.txt" , "/workspace/new.txt" ])
Not supported in the HTTP API.
Best Practices
Use /workspace as the default directory for application files.
Use absolute paths to avoid ambiguity.
Use write_file / read_file for programmatic access.
Use tl sbx cp for single-file transfers.
Use the Python SDK or raw file API for directory-oriented workflows.
Learn More
Commands Execute commands in sandboxes.
Snapshots Save and restore sandbox filesystem and memory state.
Lifecycle Sandbox states, resources, and timeouts.