Everstack
API ReferenceSandboxCreate Code Context

Create Code Context

POST/v1/sandbox/{sandbox_id}/code/context
POST/v1/sandbox/{'{sandbox_id}'}/code/context

Your 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

ParameterTypeRequiredDescription
sandbox_idstringYesSandbox ID or name

Request Body

PropertyTypeRequiredDescription
languagestringYesProgramming language for the REPL context. Supported values: "python"

Responses

201 Created

PropertyTypeDescription
idstringUnique ID of the created code context
languagestringProgramming language of the REPL context
sandbox_idstringID of the sandbox this context belongs to
created_atstringISO 8601 timestamp when the context was created

default An unexpected error response.

PropertyTypeDescription
codeinteger
messagestring
detailsobject[]

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"
    }
  ]
}