API reference · Sandboxes
End a sandbox now: runs are cut off, its files are deleted, billing stops
/v1/sandboxes/{sandbox_id}/end- TypeScript
client.sandboxes.end()- Python
client.sandboxes.end()- CLI
hayonix sandboxes end
The sandbox cannot be restarted and nothing in it can be recovered; its run records stay readable for 7 days. Ending a sandbox that has already ended returns it unchanged.
Project API key (Authorization: Bearer sk_…), or a console session. Requires the sandbox:delete permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
curl -sS -X POST "$API_BASE_URL/sandboxes/sbx_01jc5zq4m8k3v6x9t2w7r0b1e4/end" \
-H "Authorization: Bearer $API_KEY"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
X-Project-Id | session only | The project to act in, for console sessions. Requests with an API key leave it out. |
Path parameters
sandbox_idstringrequiredID of the sandbox
ID with prefix sbx_
Response
200 Sandbox — The sandbox (ending)
objectstringrequiredAlways `sandbox`: the type of this object
One of
sandboxidstringrequiredUnique ID (`sbx_…`)
ID with prefix sbx_
org_idstringrequiredOrganization it belongs to
ID with prefix org_
project_idstringrequiredProject it belongs to
ID with prefix prj_
namestringrequiredIts name
ShowHide 4 fields of
statusstatestringrequiredstarting | ready (waiting for code) | busy (running code) | unreachable (its host stopped reporting) | ending | ended | failed
One of
startingreadybusyunreachableendingendedfailedreasonstringrequiredMachine-readable cause, lower_snake_case
messagestringrequiredOne sentence for people
sincestring (date-time)requiredWhen it entered this state (ISO 8601, UTC)
sizeobjectrequiredThe size it was created with
ShowHide 4 fields of
sizecodestringrequiredMachine-readable code
display_namestring | nullrequiredName to show people
vcpusinteger | nullrequiredVirtual CPUs (null if the size is no longer listed)
memory_gbinteger | nullrequiredMemory in GB (null if the size is no longer listed)
regionstringrequiredRegion code
priceobjectrequiredIts price, fixed when it was created
ShowHide 2 fields of
priceper_secondstringrequiredPrice per second of running, nano-USD (what is billed)
pattern ^-?[0-9]+$
per_hourstringrequiredThe same price per hour (per_second × 3600), nano-USD
pattern ^-?[0-9]+$
usageobjectrequiredWhat it has cost so far
ShowHide 2 fields of
usagebilled_secondsstringrequiredRunning time billed so far, in seconds (decimal string)
cost_so_farstringrequiredCost of that running time, nano-USD; can lag a few seconds behind
pattern ^-?[0-9]+$
lifetimeobjectrequiredWhen it ends, and what keeps it alive
ShowHide 5 fields of
lifetimeexpires_atstring (date-time)requiredWhen it ends by itself
idle_timeout_secondsintegerrequiredIt ends after this many seconds without a run or a file operation
idle_expires_atstring (date-time) | nullrequiredWhen the idle timeout ends it if nothing runs and no file is touched before then (null once ended)
last_activity_atstring (date-time)requiredTime last activity (ISO 8601, UTC)
max_expires_atstring (date-time)requiredThe latest an extension can reach
runsobjectrequiredRun counts
ShowHide 2 fields of
runsactiveintegerrequiredRuns queued or running now
totalintegerrequiredRuns sent to it over its life, in any state
metadataobjectrequiredYour own key/value labels, returned as given
created_atstring (date-time)requiredWhen it was created (ISO 8601, UTC)
started_atstring (date-time) | nullrequiredWhen it first started running
ended_atstring (date-time) | nullrequiredWhen it ended (null until then) (ISO 8601, UTC)
end_reasonstring | nullrequiredrequested | expired | idle | billing | suspended | host_maintenance | host_lost | failed
One of
requestedexpiredidlebillingsuspendedhost_maintenancehost_lostfailed
Example response
{
"object": "sandbox",
"id": "sbx_01jc5zq4m8k3v6x9t2w7r0b1e4",
"org_id": "org_01jc5zq4m8k3v6x9t2w7r0b1e4",
"project_id": "prj_01jc5zq4m8k3v6x9t2w7r0b1e4",
"name": "string",
"status": {
"state": "starting",
"reason": "string",
"message": "string",
"since": "2026-01-01T00:00:00.000Z"
},
"size": {
"code": "cpu-2c-4gb",
"display_name": "string",
"vcpus": 1,
"memory_gb": 1
},
"region": "string",
"price": {
"per_second": "1500000000",
"per_hour": "1500000000"
},
"usage": {
"billed_seconds": "string",
"cost_so_far": "1500000000"
},
"lifetime": {
"expires_at": "2026-01-01T00:00:00.000Z",
"idle_timeout_seconds": 1,
"idle_expires_at": "2026-01-01T00:00:00.000Z",
"last_activity_at": "2026-01-01T00:00:00.000Z",
"max_expires_at": "2026-01-01T00:00:00.000Z"
},
"runs": {
"active": 1,
"total": 1
},
"metadata": {},
"created_at": "2026-01-01T00:00:00.000Z",
"started_at": "2026-01-01T00:00:00.000Z",
"ended_at": "2026-01-01T00:00:00.000Z",
"end_reason": "requested"
}Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
404 | not_found_error | No such resource in this project (an ID from another project is answered the same way). |
409 | conflict_error | The resource's current state does not allow this. |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |