Skip to content

Guides

Key policies

Give each API key only what it needs: how much it spends, how many sandboxes it runs, for how long, where and when.

How policies work

A policy is a set of optional rules on one key, edited in Settings › Keys. A key without rules behaves as before. Rules apply on every call (who and when), at create (which sandbox, and how long it may live) or while running, where the meter stops sandboxes that break them within a minute. Counters are race-safe: ten parallel creates on a key with max_running: 3 start exactly three.

policy
{
  "daily_cap_usd": 50,
  "max_running": 20,
  "max_idle_s": 900,
  "allowed_regions": ["eu"],
  "allowed_operations": ["create", "exec", "files", "kill"],
  "ip_allowlist": ["203.0.113.0/24"],
  "sandbox_network": { "allow": ["pypi.org", "registry.npmjs.org", "*.github.com"] },
  "alert_thresholds": [50, 80, 100],
  "alert_webhook_url": "https://hooks.example.com/sandboxplease"
}

Routing respects the policy: providers it rules out are skipped and listed in the error's details.skipped, and a timeout longer than the key allows is shortened rather than refused.

Presets

CI runner

Short-lived sandboxes, a few at a time, stopped when idle.

{"max_running":10,"max_creates_per_minute":30,"max_lifetime_s":1800,"max_idle_s":600,"max_sandbox_cost_usd":1}

Agent in production

A daily cap with alerts, idle sandboxes stopped, cost per sandbox bounded.

{"daily_cap_usd":50,"max_running":20,"max_idle_s":900,"max_sandbox_cost_usd":5,"alert_thresholds":[50,80,100]}

EU only

Sandboxes run only in the EU.

{"allowed_regions":["eu"]}

Hackathon / demo

$5 to spend, expires in 24 hours, sandboxes stop with it.

{"kill_at_expiry":true,"max_running":3,"max_lifetime_s":3600,"alert_thresholds":[80,100]}

Read-only analytics

Lists and reads sandboxes; cannot create, run or kill anything.

{"read_only":true}

Every rule

Spend

daily_cap_usdnumber (USD)at create · while running

Hard cap on what the key spends per UTC day. New sandboxes are refused and running ones stopped once it is reached.

max_sandbox_cost_usdnumber (USD)at create · while running

A sandbox stops once it has cost this much; its lifetime is shortened at create to fit.

max_price_per_hour_usdnumber (USD)at create

Only providers whose list price for the size is at or under this hourly price are used.

Concurrency and rate

max_runningintegerat create

Running and paused sandboxes the key can hold at once.

max_creates_per_minuteintegerat create

Sandboxes the key can create in any rolling minute.

max_creates_per_hourintegerat create

Sandboxes the key can create in any rolling hour.

max_creates_per_dayintegerat create

Sandboxes the key can create in any rolling 24 hours.

max_execs_per_minuteintegerevery call

Commands the key can run per minute, across all its sandboxes.

Lifetime

max_lifetime_sinteger (seconds)at create

A longer timeout at create is shortened to this.

max_idle_sinteger (seconds, ≥ 60)at create · while running

A sandbox no API call touched for this long is stopped; a longer idle_timeout at create is shortened.

kill_at_expirybooleanat create · while running

Sandboxes never outlive the key's expires_at: their lifetime is shortened at create and the meter stops them.

Scope

allowed_providersprovider idsat create

Only these providers are used.

blocked_providersprovider idsat create

These providers are never used.

allowed_regions"eu" | "us"at create

Sandboxes run only in these regions; ["eu"] makes an EU-only key.

allowed_sizes"small" | "standard" | "large" | "custom"at create

Sizes the key can create.

allowed_templatestemplate namesat create

Templates the key can start; a create without a template uses the provider's default and is allowed.

billing"credits" | "byok"at create

"byok" runs only on your own provider keys, "credits" only on SandboxPlease credits.

read_onlybooleanevery call

The key can list and read sandboxes, nothing else.

allowed_operations"create" | "exec" | "files" | "ports" | "pause" | "snapshot" | "kill"every call

Calls the key can make besides reading; list and get are always allowed.

Network

ip_allowlistIPs or CIDR rangesevery call

API calls are accepted only from these addresses.

sandbox_network"deny-all" | { allow: string[] }at create

What the key's sandboxes may reach. Creates get this rule; a request may only ask for less. Only providers that enforce it are used.

allowed_originsoriginsevery call

Calls must carry an Origin or Referer from this list, for keys used from a browser.

Time

active_window{ days, start, end, timezone }every call

The key works only on these days (0 = Sunday) between start and end (HH:MM) in the time zone.

not_beforeISO 8601 date-timeevery call

The key works only from this moment.

max_sandboxesintegerat create

The key stops creating after this many sandboxes in its life; good for one-time keys.

Safety

alert_thresholdspercentageswhile running

Alerts when the key crosses these shares of its credit limit, daily cap or burst limit, e.g. [50, 80, 100].

alert_emailbooleanwhile running

Alerts are emailed unless this is false.

alert_webhook_urlhttps URLwhile running

Alerts are also POSTed here as JSON: { "type": "key.alert", ... }.

dry_runbooleanevery call · at create · while running

Logs what the policy would block without blocking, to roll a policy out safely. The kill switch still applies.

Dry run

With dry_run: true nothing is refused, shortened or stopped: each rule that would have acted is counted instead. Watch the counts in the key's Usage and limits panel and under Policy blocks in Activity, then turn dry run off.

Kill switch

Disable key in the key's menu refuses its next call with key_disabled and stops every sandbox it runs right away. Unlike revoking, it can be undone, and dry run does not soften it.

Keys in a workspace

In a team workspace, a member's key reaches only the sandboxes created by that member's keys: get, list, exec, files, ports, pause, resume and kill, through the API, MCP and the playground. Another member's sandbox answers not_found, like a sandbox of another account. Keys of the owner and of admins reach every sandbox in the workspace, and so do they in Logs.

Members can tighten their own keys but not undo what an owner or admin decided: a key an owner or admin disabled stays off, a policy they set can only get stricter (lower caps, shorter lists, no dry run), and only they change limit_reset, raise or remove credit_limit_usd, push back or remove expires_at or leave BYOK out of the limit. Each refusal is a forbidden error; for a policy, details.rules names the rules that would loosen.

Alerts

alert_thresholds are percentages of the key's credit limit, daily cap and max_sandboxes. Each threshold alerts once per window (per day for the daily cap), by email unless alert_email is false, and as a POST to alert_webhook_url when set:

POST alert_webhook_url
{
  "type": "key.alert",
  "key": { "id": "4b0c…", "name": "Coding agent" },
  "limit": "daily_cap_usd",
  "threshold_pct": 80,
  "used": 40.12,
  "max": 50,
  "unit": "usd",
  "at": "2026-11-23T14:02:11.000Z"
}

Errors

403policy_violation

The key's policy does not allow this call; details.rule names the rule.

429policy_limit_reached

The key reached a concurrency or rate cap of its policy; details.rule names the cap.

402key_limit_reached

This key used up its credit limit for the period, or its daily cap.

403key_disabled

The key's kill switch is on: its calls are refused and its sandboxes were stopped.

details.rule names the rule that refused the call, so a client can tell a daily cap from a rate limit.