Skip to main content
POST
/
v1
/
agents
/
sandboxes
/
{sandbox_id}
/
code
/
run
Run Code
curl --request POST \
  --url https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/code/run \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "<string>",
  "timeout": 30
}
'
{
  "logs": {
    "stdout": "<string>",
    "stderr": "<string>"
  },
  "error": "<string>",
  "execution_time_ms": 123
}

Overview

Execute code inside an existing AgentBox sandbox.

Endpoint

POST /v1/agents/sandboxes/{sandbox_id}/code/run Headers:
  • Content-Type: application/json
  • Authorization: Bearer YOUR_API_KEY

Path Parameters

ParameterTypeRequiredDescription
sandbox_idstringYesID of the sandbox

Request Body

FieldTypeRequiredDescription
codestringYesCode to execute
languagestringYesLanguage: python, javascript, typescript, bash
timeoutintegerNoExecution timeout in seconds (default: 30)

Example Request

curl -X POST https://api.gravixlayer.com/v1/agents/sandboxes/sb-abc123/code/run \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "print(\"Hello from sandbox\")",
    "language": "python",
    "timeout": 30
  }'

Example Response

{
  "logs": {
    "stdout": "Hello from sandbox\n",
    "stderr": ""
  },
  "error": null,
  "execution_time_ms": 85
}

Authorizations

Authorization
string
header
required

API key authentication. Get your API key from the Gravix Layer Dashboard.

Path Parameters

sandbox_id
string
required

Sandbox ID

Body

application/json
code
string
required

Code to execute

Example: print('Hello, world!')

timeout
integer
default:30

Execution timeout in seconds (default: 30s)

Response

200 - application/json

Execution result

logs
object
error
string | null
execution_time_ms
integer