pols.so API
Control plane API for pols.so developer sandboxes: full Ubuntu 24.04 VMs with root, systemd and Docker.
This file is the source of truth. The Go server interface and client
(pkg/api), the TypeScript client (clients/typescript) and the Python
client’s types (clients/python/src/pols/_schema.py) are generated from
it with make generate.
Authentication: /v1 endpoints require an org-scoped API key as a
bearer token (Authorization: Bearer pols_...), except the public
/v1/openapi.yaml and /v1/agent-logins, with which an agent gets
its first key. The CDP WebSocket endpoint also accepts the connection
token described under GET /v1/sandboxes/{sandbox}/browser/cdp.
Agent logins: an agent without a key asks for one by the person’s email
address (POST /v1/agent-logins), like OAuth’s device flow (RFC 8628).
pols emails the person a link to https://my.pols.so/agent and the
short user_code the agent shows too; there they approve or deny, and
for an address without an account approving creates it (accepting the
terms, and the trial starts) and logs them in. Meanwhile the agent
polls POST /v1/agent-logins/token with its device_code every
interval seconds until it gets the key, named
created by agent on <date> and revocable on the account page like
any other. Nothing, account included, is created before the person
approves, and the answers never say whether an address has an account.
Agent handoffs: instead, a person logged in on
https://my.pols.so/account/agents makes a one-time link like
https://my.pols.so/agent/handoff#<token>, for the whole org or limited
to some of its sandboxes, and hands it to their agent, which redeems
the token after # with POST /v1/agent-logins/handoff (pols login --handoff <link>, or the MCP tool account_handoff). The link is shown
once, works once and for 15 minutes, and can be revoked until then.
Roles: an org has users, each an owner, admin or member (see the
Role schema), invited by email on the website
(https://my.pols.so/account/members). Every user makes their own API
keys there, and a key acts with the current role of its user: changing
the role changes what the key may do, and removing the user from the org
revokes their keys. Every role may use sandboxes, templates, SSH keys
and the vault’s names through the API; GET /v1/api-keys lists a
member’s own keys only. GET /v1/org says the role of the calling key.
Sandbox-scoped keys: a key made on the website’s API keys page
(https://my.pols.so/account/agents, or “Create key for this sandbox” on a
sandbox’s page) can be limited to some sandboxes of the org instead of
acting in the whole org, and polsd enforces that on every operation. Such
a key sees and acts on its sandboxes of the org only. GET /v1/sandboxes lists them
alone, and the /v1/sandboxes/{sandbox} operations it may use (get,
stats, events and their thumbnails, stop, resume, exec, files, users,
computer use, the desktop, CDP, ports and SSH access) answer 404
not_found for any other sandbox, exactly as for one that does not
exist. Every other operation answers it 403 forbidden: creating,
deleting, forking and renaming sandboxes, timeline settings, templates,
sites, GitHub, API keys, the vault, webhooks, billing, usage and the
org’s stats. GET /v1/org names its sandboxes (sandboxes) and counts
their usage only, GET /v1/orgs lists its own org only, and
/v1/ssh-keys shows the SSH keys it registered, which reach its
sandboxes only. Port login links, desktop links and CDP connections it
makes work only while it may still act on their sandbox. A deleted
sandbox leaves its scope; once all of them are deleted the key stops
working (401), never widening to the org.
User-limited keys: a key limited to exactly one sandbox can also be
limited to one Linux user of it (added under .../users), so that each
agent acts as its own user. Such a key runs commands, reads and writes
files and logs in over SSH as that user only: omitting user means its
user, and asking for root or another user answers 403 forbidden.
Files are read and written with that user’s permissions. Its desktop
link, computer use, desktop control and CDP are its user’s own desktop
and Chrome, likewise: omitting user means its user, and the default
user’s desktop or another user’s answers 403 forbidden. Of the
sandbox’s operations it may use only get, stats, resume, exec, files,
SSH access and those of its user’s desktop; the others answer 403
forbidden, because they act on the sandbox’s other users too:
stopping, users, ports and their links, checkpoints and rollback, and
its events and their thumbnails (unless its limits allow checkpoint
or port; see Key limits below). GET /v1/org names its
user (sandbox_user). Once that user is removed from the sandbox the
key stops working (401), even if a user of that name is added again.
A user with sudo can still become root inside the sandbox.
Key limits: an org owner or admin can give a sandbox-scoped key limits
on https://my.pols.so/account/agents, so that an agent adapts its own
sandboxes within a budget. Limits name the self-service actions
(KeyAction) the key may take, any other being refused, and caps: the
largest size it may resize or fork to, what its sandboxes may cost in
CPU and RAM per calendar month, and how many sandboxes it may have. A
key with limits that allow resize may resize its sandboxes (PATCH /v1/sandboxes/{sandbox} with size only), and one that allows fork
may fork them; a fork joins the key’s sandboxes. Limits that leave out
checkpoint or port take those away from the key. Past its monthly
spend, the key may not resume, resize or fork; its sandboxes that run
keep running. A key limited to a sandbox user may be allowed
checkpoint, to create and list checkpoints only, and port, never
resize or fork. A call beyond the key’s limits answers 403
key_limit, with key_limit saying which limit, the key’s value and
its maximum. Keys without limits, every key until an owner or admin
sets some, are unchanged. The limits only narrow what the org may do:
its quotas, credit and trial limits apply too.
Lifecycle calls are asynchronous. They record the desired state and return
at once; a reconciler drives the runtime to it. Poll GET /v1/sandboxes/{sandbox} until status equals desired_state, or until a
standby sandbox is stably stopped with status=stopped and
desired_state=standby (or is error unless deletion is pending).
Conflicting stop/resume requests return 409 until the current transition
finishes.
Wherever a path takes {sandbox} or {template}, either the ID
(sbx_..., tpl_...) or the org-unique name is accepted.
Computer use: every sandbox has a 1920x1080 X11 desktop and Google
Chrome. /computer/* takes screenshots of the whole desktop and drives
its mouse and keyboard; coordinates are pixels in that 1920x1080 space,
with (0, 0) at the top left. /browser/cdp connects Playwright or
Puppeteer to the sandbox’s Chrome over the Chrome DevTools Protocol,
proxied by the control plane; Chrome’s debugging port itself only
listens inside the sandbox. That desktop is the default sandbox
user’s; every user added under .../users has a desktop of its own,
with its own Chrome and profile, which these operations and the
desktop link reach with user=<name>. A user’s desktop starts on
demand and stops after 10 minutes without use.
Edge: the edge serves sandbox content on its own domain (the sandbox
domain, on.pols.so in production), never on the API’s or the site’s
domain. A published port is at
https://<sandbox>-<port>.<sandbox domain>, where <sandbox> is the
sandbox’s host_label (a generated name with a random suffix, like
braveotterk3f9) or the sandbox ID with _ replaced by -; the
desktop is at <sandbox>-desktop and the CDP endpoint at
<sandbox>-cdp. Both forms reach the same sandbox with the same login
links and tokens. A name given to a sandbox is never part of an
address, and the host label never changes, a rename included; no host
label is ever given to another sandbox. The VM’s own hostname stays the
ID form (sbx-...). An unknown sandbox, a port that is not published
and a private port without a valid login link or session all get the
same 404 page. Ports are
private unless published as public: open them with a login link from
POST /v1/sandboxes/{sandbox}/ports/{port}/link, whose token the edge
exchanges for a cookie scoped to that one host. The desktop takes no
cookie: its link from POST /v1/sandboxes/{sandbox}/desktop carries a
token in the URL fragment, which the edge’s desktop page presents when
it connects. ssh <sandbox ID>@<gateway>
reaches a running sandbox with any key registered under /v1/ssh-keys
by a user who is still an active user of the org; a key registered
with a sandbox-scoped API key reaches that key’s sandboxes only.
Sites: a site is a static directory published from a sandbox (a
build’s dist/, say) and served by pols itself at
https://<name>.<sandbox domain>, so it stays up while the sandbox is
in standby, stopped or deleted. POST /v1/sites/{site}/versions copies
the directory out of the sandbox into a new version and makes it live;
versions never change, and .../restore makes an older one live again.
POST /v1/sites/{site}/upload publishes the files of a tar or zip
archive instead, without a sandbox.
A site keeps its newest keep_versions versions besides the live one.
Access is private (the org’s users, logged in on the website), link
(anyone with the site’s share_url, and the org’s users) or public.
Site names share the sandbox domain with sandbox addresses and never
collide with them; a name stays the org’s after its site is deleted.
The site’s files are billed as disk, with the sandboxes’ and templates’.
A site built from a GitHub repository (PUT /v1/sites/{site}/source)
is deployed with POST /v1/sites/{site}/deploys: pols builds the
commit in a build sandbox of the org and publishes the output as the
site’s new live version. A public or link site can have custom domains
of the org’s own (/v1/sites/{site}/domains): once the DNS records
point to the site, pols verifies the domain and serves the site there
too.
Standby: a running sandbox that nothing uses for the deployment’s
standby period (15 minutes by default) while its CPU and outbound
traffic stay low goes
to status standby, using no CPU, unless it was created or updated
with keep_awake. On Cloud Hypervisor, the default
engine for new sandboxes, its memory is written to disk and it is
billed only for that stored memory snapshot, as disk, with no RAM
charge (GET /v1/usage); on Incus, the fallback engine and where older
sandboxes run, its VM is frozen with its memory kept and billed for the
full RAM its size reserves. Its disk keeps being billed. Use means a call on
its contents (exec, files, computer use, CDP, a desktop link) or SSH and HTTP through the
edge. Any of those wakes it, and so do resuming, forking and saving it
as a template: the call waits until the sandbox runs again, usually
within a second, and answers 503 waking if that takes longer than the
deployment allows. On Cloud Hypervisor a standby whose memory went to
disk also gives back the host memory its size reserves, which waking
takes again: while its host has no room for it, the wake waits and
polsd retries it for up to 10 minutes (waiting_for_capacity_since is
set, and calls that wake it answer 503 server_busy with Retry-After);
after that it stays in standby with a last_error that says the server
was busy. Reading it (GET) does not wake it. A sandbox in
standby keeps its place among the org’s running sandboxes, so waking it
never fails on the org’s running limit. Once billing is on and the
org’s credit is used up, it cannot wake (402 insufficient_credit) and
is stopped with the running ones; so too once the org needs a
subscription and has none (402 subscription_required). If its VM stopped meanwhile (a host reboot), it
shows status stopped with desired state standby, gives up its place
and is billed for nothing; the next use boots it like a resume, with
the running quota checked, except a fork or template save, which copies
its disk without booting it.
Vault: each org has a vault of passwords and environment variables,
encrypted at rest. Its owners and admins add, replace and delete entries
on the website (https://my.pols.so/account); API keys can only list their names
(GET /v1/vault) and name them in secrets when creating or forking a
sandbox, which gets each one as an environment variable of that name.
No endpoint returns a value. An entry with hosts never enters the
sandbox: its variable holds a placeholder, which pols swaps for the
value only on the sandbox’s HTTPS requests to those hosts.
Webhooks: the org’s owners and admins register HTTPS endpoints on the website
(https://my.pols.so/account) and pick the events each one gets:
sandbox.ready, sandbox.stopped, sandbox.error and
sandbox.expired. API keys can only list endpoints and their delivery
log (GET /v1/webhooks and
GET /v1/webhooks/{webhook}/deliveries). Each delivery is a POST of a
WebhookEvent JSON body with a
Pols-Signature: t=<unix seconds>,v1=<hex> header:
the HMAC-SHA256, keyed with the endpoint’s secret (whsec_..., shown
once when it is created), of the timestamp, a . and the raw body.
Check it in constant time against the raw body before parsing it,
refuse timestamps more than 5 minutes from your clock, and process
each event id once: a delivery is retried until an endpoint answers
2xx within 10 seconds, with backoff for about a day, so the same event
can arrive more than once and out of order.
Billing: GET /v1/billing and PUT /v1/billing read and set who the
org’s invoices are made out to, as do the billing page on the website
(https://my.pols.so/billing); only owners’ and admins’ keys may (403
forbidden otherwise). A business’s EU or Northern Ireland VAT ID is
checked against VIES when it is saved. When VIES does not answer,
the details are saved anyway with the VAT ID unverified, and it is
checked again later. The details and VIES’s answer decide how VAT
applies to the org’s top-ups and subscription (TaxTreatment), and
each paid top-up and subscription month gets an invoice
(GET /v1/invoices), a PDF kept for 10 years. The subscription
(/v1/billing/subscription) costs EUR 10 a month and includes EUR 20
of usage each month, which expires when it renews; an org that needs
one (subscription.required on /v1/balance) runs sandboxes only
while it has one or its trial credit lasts. Usage beyond the included
usage is paid from prepaid credit, and auto top-up
(/v1/billing/auto-topup) tops that up by card when it runs low.
Limits: /v1 calls are rate limited per client address and per org,
sandbox and template lifecycle calls more tightly, and an org may have
only so many exec, file, computer and CDP calls in progress at once.
Over a limit the API answers 429 rate_limited with a Retry-After
header. A request body that stalls is answered with 408 timeout.
Errors and headers: a failure of the sandbox host is answered with 502
runtime_error and a fixed message; the details are only in the
server’s log. A {sandbox} or {template} that is neither a well-formed
ID nor a name is 404 not_found. Names and descriptions must be UTF-8
text without control characters other than tab, and exec arguments
and paths must not contain NUL. Every response carries
X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer,
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'
and Cache-Control: no-store, except that /v1/openapi.yaml may be
cached.
https://api.pols.soagent-logins
- POSTAsk the person at an email address for an API key (no API key needed)
/v1/agent-logins - POSTGet the API key of an approved agent login (no API key needed)
/v1/agent-logins/token - POSTRedeem a one-time agent handoff link for an API key (no API key needed)
/v1/agent-logins/handoff
org
- GETThe org the API key belongs to, with its quotas, current consumption and the key's role
/v1/org - PUTSet the org's own limits
/v1/org/limits - GETThe orgs the API key's person belongs to
/v1/orgs - GETCPU, memory and disk use summed over the org's running sandboxes
/v1/org/stats
api-keys
sandboxes
- GETList sandboxes
/v1/sandboxes - POSTCreate a sandbox from a template and start it
/v1/sandboxes - GETGet a sandbox
/v1/sandboxes/{sandbox} - DELETEDelete a sandbox and its disk
/v1/sandboxes/{sandbox} - PATCHRename, resize, change the egress policy of or keep awake a sandbox
/v1/sandboxes/{sandbox} - GETA sandbox's current CPU, memory and disk use and its recent history
/v1/sandboxes/{sandbox}/stats - POSTStop a sandbox (snapshot, then free; stopped time is not metered)
/v1/sandboxes/{sandbox}/stop - POSTResume a stopped sandbox, or wake one in standby
/v1/sandboxes/{sandbox}/resume - POSTFork a sandbox into a new running sandbox with a copy of its disk
/v1/sandboxes/{sandbox}/fork
timeline
- GETThe sandbox's timeline, newest first
/v1/sandboxes/{sandbox}/events - PUTSet the sandbox's timeline content-capture setting
/v1/sandboxes/{sandbox}/timeline - GETThe thumbnail of a screenshot event
/v1/sandboxes/{sandbox}/events/{event}/thumbnail
exec
- POSTRun a command in a running sandbox
/v1/sandboxes/{sandbox}/exec - GETList a running sandbox's detached processes
/v1/sandboxes/{sandbox}/processes - GETRead a detached process's output
/v1/sandboxes/{sandbox}/processes/{process}/output - POSTSend a signal to a detached process
/v1/sandboxes/{sandbox}/processes/{process}/signal
files
- GETRead a file from a running sandbox
/v1/sandboxes/{sandbox}/files - PUTCreate or overwrite a file in a running sandbox
/v1/sandboxes/{sandbox}/files - GETList a directory in a running sandbox
/v1/sandboxes/{sandbox}/files/list - GETStream the changes to files under a path
/v1/sandboxes/{sandbox}/files/watch - GETList what changed under a tracked directory
/v1/sandboxes/{sandbox}/files/changes - POSTStart tracking the changes under a directory
/v1/sandboxes/{sandbox}/files/changes - DELETEStop tracking the changes under a directory
/v1/sandboxes/{sandbox}/files/changes
users
- GETList the sandbox's Linux users
/v1/sandboxes/{sandbox}/users - POSTAdd a Linux user to a running sandbox
/v1/sandboxes/{sandbox}/users - DELETERemove a Linux user from a running sandbox
/v1/sandboxes/{sandbox}/users/{user}
checkpoints
- GETList the sandbox's checkpoints, oldest first
/v1/sandboxes/{sandbox}/checkpoints - POSTTake a named checkpoint of the sandbox's disk
/v1/sandboxes/{sandbox}/checkpoints - DELETEDelete a checkpoint
/v1/sandboxes/{sandbox}/checkpoints/{checkpoint} - POSTRoll the sandbox's disk back to a checkpoint, discarding everything newer
/v1/sandboxes/{sandbox}/rollback
computer
- GETTake a PNG screenshot of the sandbox's whole 1920x1080 desktop
/v1/sandboxes/{sandbox}/computer/screenshot - POSTClick, double-click, drag, type, press keys or scroll on the sandbox's desktop
/v1/sandboxes/{sandbox}/computer/actions - GETWho has control of the sandbox's desktop
/v1/sandboxes/{sandbox}/desktop/control
browser
- GETConnect to the sandbox's Chrome DevTools Protocol endpoint (WebSocket)
/v1/sandboxes/{sandbox}/browser/cdp - POSTGet a short-lived WebSocket URL for the sandbox's Chrome DevTools Protocol endpoint
/v1/sandboxes/{sandbox}/browser/cdp
edge
- GETList the sandbox's published ports
/v1/sandboxes/{sandbox}/ports - PUTPublish a sandbox port over HTTPS, or change its visibility
/v1/sandboxes/{sandbox}/ports/{port} - DELETEStop publishing a port
/v1/sandboxes/{sandbox}/ports/{port} - POSTGet a short-lived login link for a published port
/v1/sandboxes/{sandbox}/ports/{port}/link - GETList a port's custom domains
/v1/sandboxes/{sandbox}/ports/{port}/domains - POSTServe a published port at a custom domain
/v1/sandboxes/{sandbox}/ports/{port}/domains - GETGet a custom domain of a port
/v1/sandboxes/{sandbox}/ports/{port}/domains/{domain} - DELETERemove a custom domain from a port
/v1/sandboxes/{sandbox}/ports/{port}/domains/{domain} - PATCHMake a custom domain the port's primary one, or not
/v1/sandboxes/{sandbox}/ports/{port}/domains/{domain} - POSTCheck a port's custom domain's DNS now
/v1/sandboxes/{sandbox}/ports/{port}/domains/{domain}/check - POSTGet a link to the sandbox's desktop in the browser
/v1/sandboxes/{sandbox}/desktop - GETHow to reach the sandbox over SSH through the gateway
/v1/sandboxes/{sandbox}/ssh
sites
- GETList the org's sites
/v1/sites - POSTCreate a site, without a version yet
/v1/sites - GETGet a site
/v1/sites/{site} - DELETEDelete a site and all its versions
/v1/sites/{site} - PATCHChange a site's access, how many versions it keeps or its redirect
/v1/sites/{site} - GETList a site's versions
/v1/sites/{site}/versions - POSTPublish a sandbox directory as the site's new live version
/v1/sites/{site}/versions - POSTPublish uploaded files as the site's new live version
/v1/sites/{site}/upload - POSTMake one of the site's versions live again
/v1/sites/{site}/versions/{version}/restore - GETGet the server app a site runs
/v1/sites/{site}/app - GETRead a server app's log
/v1/sites/{site}/app/logs - POSTRestart a server app
/v1/sites/{site}/app/restart - POSTGive a site a new share link
/v1/sites/{site}/link - GETGet a site's path redirects
/v1/sites/{site}/redirects - PUTReplace a site's path redirects
/v1/sites/{site}/redirects - GETList a site's custom domains
/v1/sites/{site}/domains - POSTAdd a custom domain to a site
/v1/sites/{site}/domains - GETGet a custom domain of a site
/v1/sites/{site}/domains/{domain} - DELETERemove a custom domain from a site
/v1/sites/{site}/domains/{domain} - PATCHMake a custom domain the site's primary one, or not
/v1/sites/{site}/domains/{domain} - POSTCheck a custom domain's DNS now
/v1/sites/{site}/domains/{domain}/check - GETGet the GitHub repository a site is built from
/v1/sites/{site}/source - PUTBuild a site from a GitHub repository
/v1/sites/{site}/source - DELETEStop building a site from its repository
/v1/sites/{site}/source - PUTLink a site to a database
/v1/sites/{site}/database - DELETEUnlink a site from its database
/v1/sites/{site}/database - GETList a site's deploys
/v1/sites/{site}/deploys - POSTBuild and publish a site from its repository
/v1/sites/{site}/deploys - GETGet a deploy
/v1/sites/{site}/deploys/{deploy} - GETRead a deploy's build log
/v1/sites/{site}/deploys/{deploy}/log - POSTCancel a deploy
/v1/sites/{site}/deploys/{deploy}/cancel - GETA screenshot of the deployed site's front page
/v1/sites/{site}/deploys/{deploy}/thumbnail
github
- GETList the GitHub App installations connected to the org
/v1/github/installations - GETList the repositories the org's GitHub installations let pols read
/v1/github/repositories
ssh-keys
- GETList the org's SSH public keys
/v1/ssh-keys - POSTRegister an SSH public key for the org's sandboxes
/v1/ssh-keys - DELETERemove an SSH public key
/v1/ssh-keys/{key}
vault
webhooks
- GETList the org's webhook endpoints (secrets are never returned)
/v1/webhooks - GETThe endpoint's recent deliveries and their outcome
/v1/webhooks/{webhook}/deliveries
billing
- GETThe org's billing details and what VIES said about its VAT ID
/v1/billing - PUTSet who the org's invoices are made out to
/v1/billing - GETThe org's credit balance and the credit it was granted
/v1/balance - GETThe org's latest top-ups of its prepaid credit
/v1/billing/topups - POSTStart a top-up of the org's prepaid credit, paid on Mollie's checkout
/v1/billing/topups - GETA top-up and where its payment stands
/v1/billing/topups/{topup} - GETThe org's subscription and its latest payments
/v1/billing/subscription - POSTStart the monthly subscription, its first payment on Mollie's checkout
/v1/billing/subscription - DELETECancel the subscription at the end of the period paid for
/v1/billing/subscription - POSTSet up a new payment method for the subscription, on Mollie's checkout
/v1/billing/subscription/payment-method - GETThe org's auto top-up
/v1/billing/auto-topup - PUTSwitch auto top-up on or off, or change its settings
/v1/billing/auto-topup - GETThe org's invoices
/v1/invoices - GETAn invoice
/v1/invoices/{invoice} - GETAn invoice's PDF, the document itself
/v1/invoices/{invoice}/pdf
templates
- GETList system templates and the org's own templates
/v1/templates - POSTSave a sandbox's disk, or build an OCI image or Dockerfile, as a named template
/v1/templates - GETGet a template
/v1/templates/{template} - DELETEDelete one of the org's templates
/v1/templates/{template}
databases
- GETList the org's databases
/v1/databases - POSTMake a PostgreSQL database
/v1/databases - GETGet a database
/v1/databases/{database} - DELETEDelete a database and its data
/v1/databases/{database} - GETList a database's backups
/v1/databases/{database}/backups - POSTMake a new database as a copy of a database now
/v1/databases/{database}/duplicate - POSTGive a database a new password
/v1/databases/{database}/password