> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute code inline — creates a sandbox, runs the code, returns output.

> This is the simplest way to run untrusted code. The sandbox is ephemeral and destroyed after execution. **Required scope:** sandbox:execute

This is the simplest way to run untrusted code. The sandbox is ephemeral
and destroyed after execution.

**Required scope:** `sandbox:execute`

### Request body

`RunCodeRequest`

<ParamField body="code" type="string" required>
  Source code to execute.
</ParamField>

<ParamField body="env" type="object">
  Environment variables.
</ParamField>

<ParamField body="language" type="string" required>
  Programming language ('python', 'node', 'bash', 'rust').
</ParamField>

<ParamField body="timeout_seconds" type="integer (int32)">
  Execution timeout in seconds (default: 30).
</ParamField>

### Response

No response body. Code executed.

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Code executed                                      |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |
| `503` | Sandbox infrastructure unavailable                 |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/sandbox/run' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "code": "string",
    "env": {},
    "language": "string",
    "timeout_seconds": 1
  }'
  ```
</RequestExample>
