Skip to main content
POST
/
sandboxes
/
{id}
/
code
Run a code snippet
curl --request POST \
  --url https://sandbox.brimble.io/sandboxes/{id}/code \
  --header 'Content-Type: application/json' \
  --header 'x-brimble-key: <api-key>' \
  --data '
{
  "code": "<string>",
  "timeout_seconds": 150,
  "cwd": "<string>",
  "env": {
    "OPENAI_API_KEY": "sk-..."
  },
  "stream": true
}
'
{
  "message": "Exec completed",
  "data": {
    "stdout": "<string>",
    "stderr": "<string>",
    "exit_code": 123,
    "duration_ms": 123
  }
}

Authorizations

x-brimble-key
string
header
required

Your account-level Brimble API key. Find it in the dashboard under your profile drawer → API key (click the avatar in the sidebar). Available on paid plans only.

Path Parameters

id
string
required

24-char hex id of the sandbox.

Pattern: ^[a-f0-9]{24}$

Body

application/json
language
enum<string>
required
Available options:
python,
node
code
string
required

Snippet source. Multi-line via \n in the JSON string.

timeout_seconds
integer
Required range: 1 <= x <= 300
cwd
string
env
object

Extra environment variables for this snippet only. Same semantics as env on /exec, per-call override on top of the sandbox's default environment.

Example:
{ "OPENAI_API_KEY": "sk-..." }
stream
boolean

When true, the response is NDJSON streamed as the snippet runs, same behaviour as /exec with stream: true.

Response

Code completed.

When the request body has stream: true, the response is application/x-ndjson, one ExecStreamFrame per line.

message
string
required
Example:

"Exec completed"

data
object
required
Last modified on May 23, 2026