Agents SDK

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

NameTypeRequiredDescription
idstringRequiredSandbox ID

Request Body

NameTypeRequiredDescription
commandstringRequiredShell command to execute
cwdstringOptionalWorking directory for the command
envsobjectOptionalAdditional environment variables
timeoutMsnumberOptionalTimeout 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

NameTypeRequiredDescription
idstringRequiredSandbox ID

Request Body

NameTypeRequiredDescription
files{ path: string; content: string }[]RequiredArray 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

NameTypeRequiredDescription
idstringRequiredSandbox ID

Query Parameters

NameTypeRequiredDescription
pathstringRequiredAbsolute 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

NameTypeRequiredDescription
idstringRequiredSandbox ID

Request Body

NameTypeRequiredDescription
urlstringRequiredGit repository URL
pathstringOptionalTarget directory path in the sandbox
tokenstringOptionalAuth token for private repos (e.g. GitHub PAT)
depthnumberOptionalClone 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"
}