# x402engine Code Execution Sandbox

> x402engine Code Execution Sandbox is a paid API for AI agents from x402engine.app, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-30).

Runs arbitrary code in an isolated sandbox supporting Python, JavaScript, Bash, and R, returning stdout/stderr and results

## Facts

- Endpoint: POST https://x402engine.app/api/code/run?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-30
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402engine-code-execution-sandbox-c874cb4a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_R8l-p_VZ6u5dvgml_u26D

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability x402engine-code-execution-sandbox-c874cb4a -d '<json body>'
```

Example prompt: Can you run this Python snippet for me in a sandbox and give me the output: `import math; print(math.factorial(20))`? Set a 30-second timeout.

## When to prefer this

Choose this endpoint when you need to execute arbitrary code in a safe, isolated environment without provisioning your own compute, especially for short-lived tasks up to 5 minutes. It supports Python, JavaScript, Bash, and R, making it versatile for data analysis, scripting, and logic evaluation. Prefer it over local execution when security isolation is required or when operating as an AI agent without a native code interpreter.

## Known failure modes

- Timeout exceeded if code runs longer than the specified timeout (max 300s)
- Syntax errors in code cause a non-zero exit code with error message in stderr
- Unsupported language value returns a validation error
- Code attempting to access restricted system resources may be blocked by sandbox
- Payment failure (HTTP 402) if USDC balance is insufficient

## How this service works

Run code in isolated sandbox — Python, JavaScript, Bash, R (up to 5 min)

## Output

Returns the captured stdout and stderr from the code execution, along with execution status (success or error), exit code, and elapsed time. If the code produces a return value or raised an exception, those details are also included.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "bodyType",
    "body",
    "method"
   ],
   "properties": {
    "body": {
     "type": "object",
     "required": [
      "code"
     ],
     "properties": {
      "code": {
       "type": "string",
       "example": "print(\"hello\")",
       "description": "Code to execute"
      },
      "timeout": {
       "type": "number",
       "default": 60,
       "example": 60,
       "description": "Execution timeout in seconds (1-300)"
      },
      "language": {
       "type": "string",
       "default": "python",
       "example": "python",
       "description": "Programming language (python, javascript, bash, r)"
      }
     },
     "additionalProperties": false
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402engine-code-execution-sandbox-c874cb4a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402engine.app](https://www.zero.xyz/host/x402engine.app/llms.txt)
