Skip to content

HTTP API reference

Base URL: https://api.slicevm.com. All bodies are JSON with camelCase keys. Durations are microseconds (...Us), memory is kilobytes (...Kb).

Authorization: Bearer slice_live_xxxxxxxxxxxxxxxx

Create and manage keys in the console. Each key has scopes that decide what it may call:

Scope Allows
* Everything
sandbox:eval POST /v1/sandbox/eval, MCP slice_eval_ts
cas:upload POST /v1/cas/upload
functions:invoke Every function, over HTTP or MCP
functions:invoke:<name> One function, over HTTP or MCP
artifacts:read List and download kept artifacts
artifacts:delete Delete kept artifacts
runs:read Read functions’ run logs

A request outside the key’s scopes returns 403 forbidden and is not charged. Keys created before the console have full access. Treat keys like passwords.

Endpoint Scope Costs a run
POST /v1/sandbox/eval sandbox:eval Yes
POST /v1/cas/upload cas:upload No
POST /v1/functions/{name}/invoke functions:invoke or functions:invoke:<name> Yes
GET /v1/functions/{name}/runs runs:read No
POST /mcp Per tool One per tool call
GET /v1/artifacts and GET /v1/runs/{runId}/artifacts artifacts:read No
GET /v1/artifacts/{id} artifacts:read No
DELETE /v1/artifacts/{id} and DELETE /v1/runs/{runId}/artifacts artifacts:delete No
GET /v1/account Any key No
GET /healthz None No

Runs TypeScript or JavaScript in a fresh isolate.

Terminal window
curl https://api.slicevm.com/v1/sandbox/eval \
-H "Authorization: Bearer $SLICE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"const x: number = 21 * 2; x","options":{"fuel":1000000}}'
Field Type Notes
code string Required. Max 64 KB.
casDigest string Optional. 64 hex characters from /v1/cas/upload. Pro and Scale.
options.fuel number Default and maximum: your plan’s (Free 25,000,000).
options.memoryKb number Default and maximum: your plan’s (Free 8,192). Minimum 256.
options.timeoutMs number Wall-clock limit. Default and maximum: your plan’s (Free 10,000).
options.allowNet string[] Default [] (deny all). host or host:port entries. Loopback, private, link-local and localhost hosts are refused (400); a granted name that resolves to such an address is refused when it connects (ERR_SLICE_NET_DENIED, catchable, listed in deniedCapabilities).
options.auditEgress string[] Secrets blocked in raw, Base64 and Base64URL form.
options.deterministicSeed number Seeds the PRNG and virtual clock.
options.checkpoints boolean Default true. false makes Slice.checkpoint() and Slice.restore() trap with CheckpointDenied. A run may take at most 1,024 checkpoints.
options.artifacts boolean or string Default true: files the code writes under /artifacts come back in artifacts, and a copy is kept for your plan’s retention (console keys). "inline" never keeps, "store" must keep (403 otherwise), false (or "none") leaves /artifacts unavailable. See Artifacts.
{
"ok": true,
"stdout": [],
"result": 42,
"violation": null,
"telemetry": {
"coldBootUs": 0.99,
"casMmapUs": 0,
"vmExecUs": 18.4,
"rollbackUs": 0,
"totalUs": 31.2,
"fuelConsumed": 412,
"peakMemoryKb": 96,
"mpkDomain": "pkey_02",
"checkpoints": 0,
"rollbacks": 0
},
"limits": { "fuel": 25000000, "memoryKb": 8192, "timeoutMs": 10000 },
"deniedCapabilities": []
}

limits is what the run got after defaults and plan caps. When you asked for more than your plan allows, limitsCapped lists the requested values that were reduced, for example "limitsCapped": { "memoryKb": 131072 } on Free; it is absent otherwise. deniedCapabilities lists capability attempts the sandbox refused, including ones your code caught, for example lacks outbound network authority for host 'example.com:443'. The values above illustrate the shape; real numbers vary by workload. A sandbox violation is still 200, with ok: false and violation set.

How a run can end:

Outcome ok violation result
Completed true null Last expression value
Uncaught exception or unhandled rejection false null Uncaught Error: ... or Uncaught (in promise) ...
process.exit(n) with n not 0 false null Value at exit; exitCode is n
Sandbox trap (fuel, memory, time, checkpoint cap, egress DLP, SSRF) false e.g. CpuFuelExhausted: ..., WallClockExceeded: ... null
Refused capability the code did not catch false e.g. NetAccessDenied: ... null

A refused fetch, file, subprocess, environment or host extension call throws an error with err.code (ERR_SLICE_NET_DENIED, ERR_SLICE_FS_DENIED, ERR_SLICE_EXEC_DENIED, ERR_SLICE_ENV_DENIED, ERR_SLICE_EXT_DENIED); code that catches it keeps running.

artifacts is present when the run wrote files under /artifacts: one entry per file with name, size, contentType, sha256 and the bytes in data (Base64). Kept files also have id, url, urlExpiresAt and expiresAt; artifactsNotKept says why files were not kept (quota). skippedArtifacts lists files that were not returned, with a reason. Both are absent when empty. Caps and rules are on Sandbox.

exitCode is only present when the program called process.exit() or set process.exitCode. Lines printed before a trap are kept in stdout; the gateway may add [host] ... lines that describe the trap.

result is the return value parsed as JSON when possible, otherwise the raw string.

Header Example
X-Slice-Request-Id req_01J...
Server-Timing boot;dur=0.0001;desc="Cold Boot", cas;dur=0;desc="CAS mmap", compile;dur=3.055;desc="Compile", vm;dur=0.1403;desc="VM Exec", total;dur=3.2493
X-RateLimit-Remaining 999812

Responses also send Timing-Allow-Origin: *, and Server-Timing adds rollback;dur= when the run restored checkpoints. Server-Timing durations are milliseconds per the W3C specification, so browser DevTools and APM tools display the breakdown directly. The example above is a real response: most of a call is compiling your source (compile); booting the isolate and running it take microseconds. Move heavy dependencies into a precompiled .cas bundle (casDigest) so that only your short entry code is compiled per call.

  • fuel, memoryKb and timeoutMs above your plan cap are clamped to the cap, not rejected.
  • An uncaught exception in your code returns ok: false with the error text in result and violation: null. violation is set only when the sandbox traps (fuel, memory, time, egress DLP, SSRF) or a refused capability goes uncaught.
  • A run is stopped when your client disconnects, so an abandoned request frees its slot.
  • With casDigest, the bundle entrypoint runs first and then your code. Share values from the bundle by assigning them to globalThis.

Uploads a bundle produced by slice pack. Pro and Scale only.

Terminal window
slice pack ./app ./bundle.cas
curl https://api.slicevm.com/v1/cas/upload \
-H "Authorization: Bearer $SLICE_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary @bundle.cas

Returns 201 with { "casDigest": "<64 hex>", "bytes": 482113, "modules": 512 }. Uploading the same bundle again returns 200.

Your plan and usage, authenticated by the key itself. It costs no run.

Terminal window
curl https://api.slicevm.com/v1/account -H "Authorization: Bearer $SLICE_API_KEY"
{
"plan": "pro",
"enabled": true,
"key": { "start": "slice_live_3qCH", "createdAt": "2026-11-21T10:00:00.000Z" },
"runs": { "monthly": 2500000, "remaining": 2499000, "used": 1000, "nextRefill": "2026-12-20T00:00:00.000Z" },
"limits": { "memoryMb": 32, "runsInFlight": 4, "casBundles": true },
"subscription": { "status": "active", "cancelAtPeriodEnd": false, "currentPeriodEnd": "2026-12-20T10:00:00Z" },
"portalUrl": "https://polar.sh/slicevm/portal"
}

Usage updates about once a minute. Limited to 30 lookups per minute. For console keys the plan and runs are your account’s, shared by all of its keys. The same data, broken down by key and function, is in the console.

Runs the live version of a function you deployed in the console. Console keys only. Body {"input": <any JSON>} (at most 256 KB; omitted means null), optionally with "artifacts": false. The response is the eval result plus function: { name, version }, with the same headers as eval. Limits come from the function’s settings, clamped to your plan. See Functions.

Terminal window
curl https://api.slicevm.com/v1/functions/hello/invoke \
-H "Authorization: Bearer $SLICE_API_KEY" \
-H "content-type: application/json" \
-d '{"input": {"name": "Ada"}}'

A request for a function that does not exist returns 404 not_found and counts as one run. A deploy or rollback is live within 10 seconds.

The function’s run log: the same rows as the console’s Runs tab, kept 30 days, newest first. Console keys with runs:read (the Read run logs and artifacts access option) or full access. Invoking a function does not grant reading its log, because the log can hold other callers’ inputs. Not a run: not charged, and it works after the month’s runs are used up.

Query Values
limit 1 to 100 (default 50)
before The next value of the previous page
status all (default), ok, failed, stopped
via all (default), http, console, mcp, script
Terminal window
curl "https://api.slicevm.com/v1/functions/hello/runs?status=failed&limit=20" \
-H "Authorization: Bearer $SLICE_API_KEY"

The reply is { runs, next, retentionDays, logInputs }. Each run has at, runId (the X-Slice-Request-Id of the call), version, via (http, console, mcp:<server id> or script:<server id>), key (the key’s name), ok, stopped, ms, vmMs, fuel, memKb, error (first 1,000 characters), input (first 4 KB, only when the function’s Log inputs setting is on, else null) and artifacts (its kept files: id, name, contentType, size, expiresAt; download with GET /v1/artifacts/{id}). Results and stdout are never logged. next is null on the last page. An unknown function is 404, a bad filter 400.

The hosted Model Context Protocol server. AI agents and editors connect here to get the slice_eval_ts tool and one fn_<name> tool per function. Setup for each client is on MCP for AI agents.

Property Value
Transport MCP Streamable HTTP, stateless. Every request is one JSON-RPC message and gets a JSON response (no SSE). GET /mcp returns 405.
Auth Authorization: Bearer <api key>. Missing or invalid key: 401.
Protocol versions 2025-06-18, 2025-03-26, 2024-11-05
Tools slice_eval_ts (scope sandbox:eval), fn_<name> (scope functions:invoke or functions:invoke:<name>, console keys only). tools/list returns only what the key’s scopes allow.
Cost One run per tools/call. initialize and tools/list are free.
Terminal window
curl https://api.slicevm.com/mcp \
-H "Authorization: Bearer $SLICE_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"slice_eval_ts","arguments":{"code":"21 * 2"}}}'

slice_eval_ts takes { code, allowNet?, fuel?, memoryKb?, timeoutMs?, artifacts? } and runs with the same defaults and plan caps as /v1/sandbox/eval. An fn_<name> tool takes its function’s input schema as arguments, or { input? } when the function has none. A tool result carries the full sandbox result in structuredContent and sets isError when ok is false; files the code wrote under /artifacts follow the text as image blocks (PNG, JPEG, GIF, WebP up to 1 MB) and embedded text resource blocks (up to 256 KB). Quota, rate limit and input errors come back as tool results with isError: true, not as HTTP errors; only a bad key fails the request with 401. Batched JSON-RPC messages are not supported.

Files your runs kept: 24 hours on Free, 7 days on Pro, 30 days on Scale. Console keys only; none of these costs a run.

Endpoint Scope Returns
GET /v1/artifacts?runId=&before=&limit= artifacts:read { artifacts, nextBefore }, newest first. Page with before=<nextBefore>; limit 1 to 200 (default 50).
GET /v1/runs/{runId}/artifacts artifacts:read One run’s files. The run id is the X-Slice-Request-Id of the call that ran.
GET /v1/artifacts/{id} artifacts:read 302 to a fresh download link (valid 15 minutes).
DELETE /v1/artifacts/{id} artifacts:delete { "deleted": 1 }
DELETE /v1/runs/{runId}/artifacts artifacts:delete { "deleted": n }

Each entry has id, runId, source (eval, fn:<name> or mcp:<server id>), name, size, contentType, sha256, createdAt, expiresAt, url and urlExpiresAt.

Terminal window
curl -L -o chart.png https://api.slicevm.com/v1/artifacts/art_0f3c... \
-H "Authorization: Bearer $SLICE_API_KEY"

Returns { "ok": true, "version": "0.3.0", "engine": "0.14.0", "workers": 8, "queueDepth": 0, "uptimeS": 8812 }. No key needed.

Errors use one shape:

{ "error": { "code": "quota_exceeded", "message": "monthly sandbox runs exhausted" } }
Status Code Meaning
400 bad_request Malformed JSON, empty code, invalid digest.
401 unauthorized Missing or invalid key.
403 forbidden Outside the key’s scopes, feature not in your plan (such as casDigest on Free), key disabled, account without a plan, or subscription paused.
404 not_found Unknown casDigest or function.
413 payload_too_large Code over 64 KB, bundle over 32 MiB, or function input over 256 KB.
429 quota_exceeded Monthly runs used up.
429 rate_limited Burst limit hit, or the key already has its plan’s maximum runs in flight; retry shortly. The SDK does this for you.
500 internal Unexpected server error. Retry later and quote X-Slice-Request-Id if it persists.
503 overloaded All workers busy; retry with backoff. The SDK does this for you.

A 429 rate_limited caused by runs in flight comes with Retry-After: 1. Authorized requests that hit the burst or in-flight limit still count one run.