Create Code Context
POST
/v1/sandbox/{sandbox_id}/code/contextPOST
/v1/sandbox/{'{sandbox_id}'}/code/contextYour instance endpoint, shown on the instance page in the dashboard. Each instance has its own host; there is no shared API host.
Description
Creates a persistent REPL (Read-Eval-Print Loop) code context within the specified sandbox. A code context maintains interpreter state — variables, imports, and definitions — across multiple code execution requests, enabling interactive and stateful code evaluation sessions.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sandbox_id | string | Yes | Sandbox ID or name |
Request Body
| Property | Type | Required | Description |
|---|---|---|---|
language | string | Yes | Programming language for the REPL context. Supported values: "python" |
Responses
201 Created
| Property | Type | Description |
|---|---|---|
id | string | Unique ID of the created code context |
language | string | Programming language of the REPL context |
sandbox_id | string | ID of the sandbox this context belongs to |
created_at | string | ISO 8601 timestamp when the context was created |
default An unexpected error response.
| Property | Type | Description |
|---|---|---|
code | integer | |
message | string | |
details | object[] |
Request
curl -X POST "https://{instance}.{region}.everstack.ai/v1/sandbox/{sandbox_id}/code/context" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"language":"python"}'const sandboxId = "your-sandbox-id";
const response = await fetch(`https://{instance}.{region}.everstack.ai/v1/sandbox/${sandboxId}/code/context`, {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"language": "python",
}),
});
const data = await response.json();import requests
sandbox_id = "your-sandbox-id"
response = requests.post(
f"https://{instance}.{region}.everstack.ai/v1/sandbox/{sandbox_id}/code/context",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"language": "python",
},
)
data = response.json()Response
{
"id": "string",
"language": "python",
"sandbox_id": "string",
"created_at": "string"
}{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
