Sandbox Operations
Run commands, read/write files, and clone repos inside a sandbox.
Execute Command
POSThttps://relay.an.dev/v1/sandboxes/:id/exec
Run a shell command inside the sandbox. Returns stdout, stderr, and exit code.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | Sandbox ID |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| command | string | Required | Shell command to execute |
| cwd | string | Optional | Working directory for the command |
| envs | object | Optional | Additional environment variables |
| timeoutMs | number | Optional | Timeout in milliseconds (default: 30000) |
Request Body
{
"command": "ls -la /home/user/workspace",
"cwd": "/home/user/workspace/repo",
"envs": { "NODE_ENV": "production" },
"timeoutMs": 30000
}Response
{
"stdout": "total 24\ndrwxr-xr-x 5 user user 4096 ...",
"stderr": "",
"exitCode": 0
}cURL
curl -X POST https://relay.an.dev/v1/sandboxes/sb_abc123/exec \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "command": "ls -la /home/user/workspace" }'Write Files
POSThttps://relay.an.dev/v1/sandboxes/:id/files
Write one or more files to the sandbox filesystem. Creates directories as needed.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | Sandbox ID |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| files | { path: string; content: string }[] | Required | Array of files to write |
Request Body
{
"files": [
{ "path": "/home/user/workspace/hello.txt", "content": "Hello world!" },
{ "path": "/home/user/workspace/config.json", "content": "{\"key\": \"value\"}" }
]
}Returns 200 OK on success.
Read File
GEThttps://relay.an.dev/v1/sandboxes/:id/files
Read the content of a single file from the sandbox.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | Sandbox ID |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| path | string | Required | Absolute path to the file |
Response
{
"path": "/home/user/workspace/hello.txt",
"content": "Hello world!"
}Clone Repository
POSThttps://relay.an.dev/v1/sandboxes/:id/git/clone
Clone a git repository into the sandbox. For private repos, pass a token (e.g. GitHub PAT). Use depth: 1 for faster shallow clones.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | Sandbox ID |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| url | string | Required | Git repository URL |
| path | string | Optional | Target directory path in the sandbox |
| token | string | Optional | Auth token for private repos (e.g. GitHub PAT) |
| depth | number | Optional | Clone depth (use 1 for shallow clone) |
Request Body
{
"url": "https://github.com/org/repo.git",
"path": "/home/user/workspace/repo",
"token": "ghp_...",
"depth": 1
}Response
{
"path": "/home/user/workspace/repo",
"branch": "default"
}