# x402 Code Execution Sandbox

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

Executes Python, JavaScript, Bash, or R code in an isolated sandbox and returns stdout, stderr, exit code, and execution time

## Facts

- Endpoint: POST https://x402-gateway-production.up.railway.app/api/code/run
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 1
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-gateway-production-up-railway-app-a592818c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_-cFolCMm6bKG5nSAnKx9G

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 x402-gateway-production-up-railway-app-a592818c -d '<json body>'
```

Example prompt: Can you run this Python snippet for me and show me the output: `import statistics; data = [4, 8, 15, 16, 23, 42]; print(statistics.mean(data), statistics.stdev(data))`?

## When to prefer this

Use this endpoint when you need to execute arbitrary code in Python, JavaScript, Bash, or R without a local runtime environment. Ideal for dynamic computation, data transformation, math-heavy tasks, scripting, or testing small code snippets. Prefer this over LLM-only computation when you need exact numerical results, file processing logic, or reproducible scripted outputs. Supports up to 5 minutes of runtime, making it suitable for moderate data processing tasks.

## Known failure modes

- Code syntax error — success:false, non-zero exit_code, error message in stderr
- Execution timeout — code runs longer than 5 minutes, process killed
- Unsupported language specified — returns error for languages other than python/javascript/bash/r
- Runtime error — unhandled exceptions cause non-zero exit code and traceback in stderr
- Missing required fields — no code or language provided returns 400-level error

## How this service works

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

## Output

Returns a JSON object with: stdout (string output from the code), stderr (any error messages), success (boolean), exit_code (integer), execution_time_ms (how long it took), and outputs (array of any structured outputs). On success, stdout contains the printed results of the code run.

## Example request

```json
{
 "code": "print('Hello from sandbox'); result = sum([1, 2, 3, 4, 5]); print(f'Sum: {result}')",
 "language": "python"
}
```

## Request schema (JSON Schema)

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

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-gateway-production-up-railway-app-a592818c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-gateway-production.up.railway.app](https://www.zero.xyz/host/x402-gateway-production.up.railway.app/llms.txt)
