Execution
Execute commands and code in sandboxes.
Run Command
POST /v1/sandboxes/:id/exec
Execute a shell command in a sandbox.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The sandbox ID |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
command | string | Yes | The shell command to execute |
Example
curl -X POST https://api.conway.tech/v1/sandboxes/sbx_abc123/exec \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"command": "ls -l /home/ubuntu"
}'const response = await fetch(
"https://api.conway.tech/v1/sandboxes/sbx_abc123/exec",
{
method: "POST",
headers: {
Authorization: "Bearer your-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({
command: "ls -l /home/ubuntu",
}),
}
);Response
{
"stdout": "total 0\n",
"stderr": "",
"exitCode": 0
}Run Code
POST /v1/sandboxes/:id/code
Execute a block of code in a sandbox.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The sandbox ID |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The code to execute |
language | string | No | Language of the code (e.g., python, javascript). Defaults to the sandbox's runtime language. |
Example
curl -X POST https://api.conway.tech/v1/sandboxes/sbx_abc123/code \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "print(\"Hello from Conway!\")"
}'const response = await fetch(
"https://api.conway.tech/v1/sandboxes/sbx_abc123/code",
{
method: "POST",
headers: {
Authorization: "Bearer your-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({
code: 'print("Hello from Conway!")',
}),
}
);Response
{
"result": "Hello from Conway!\n",
"exitCode": 0
}