$ ssh nma.sh api the same commands over HTTPS

Control API

the control API: the same commands as ssh nma.sh, over HTTPS, signed with a key. made from CONTROL-API.md, which stays at /CONTROL-API.md as Markdown.

Status: v1 built, 2026-11-03 (branch wt/ctlapi): the dp-ctlapi server and the nanovm CLI, over the authorized root group (spec/ControlAuth.tla), specified first in spec/ControlApi.tla. Design note: spec/NOTES-ctlapi.md. Sections marked (v1, built) are implemented as written here; the rest is still a draft. The plain site is dp/web: sign up with an invite, create an app, upload a compiled image and deploy it.

Four doors, one implementation

SSH, HTTP (including the web panel), CLI and MCP share the same control routes. Doors only parse and print. The MCP door runs as nanovm mcp over stdio: newline-delimited JSON-RPC 2.0, protocol 2025-06-18. Client configuration:

{"command": "nanovm", "args": ["mcp"]}

Use the CLI's credentials and connection options (--creds, --url, --timeout before mcp, or NANOVM_CREDS and NANOVM_URL). Log in first. Initialize, notifications/initialized, ping, tools/list and tools/call are supported; unknown methods return -32601. The static tool catalog exposes deploy (optional app name), apps, deployments, rollback, promote, logs (recent only, optional version and limit), secret_set, secret_delete, delete, whoami, retry, usage, keys, keys_create, keys_revoke, rename (Pro's chosen name), and an app's data: db_list, db_get, db_delete and db_export ("An app's data, from outside"). Each call spawns the same binary with --json and the corresponding CLI command; whoami is tenant (GET /v1/tenant), promote uses the CLI's generation-aware rollback-to-version command. No API route is reimplemented. The child stdout is text content; every nonzero exit sets isError, preserving the CLI JSON, including a deploy whose first request answered 5xx (exit 3). Deploy source, secret values and db keys are piped on stdin, never argv or environment. Requests are bounded at 1 MiB, 4096 JSON tokens and depth 32; malformed and oversized lines return an error and the next line remains usable. See spec/NOTES-mcp.md for the parser and transport contract and srv/test_ctlapi_e2e.py under dp for the pipe and process-argv checks.

v1: what is built, and the decisions it rests on

Where the spec changed these decisions (spec/NOTES-ctlapi.md has each):

App URLs (built)

GET /v1/apps/{app}, each entry of GET /v1/apps, and a deploy's answer have "url", the app's own origin, its name of two words, and "numeric_url", the same app by number; both route:

https://squeezing-beagle.D/rest?query     https://APP-TENANT.D/rest?query
        \______________/ |                       \________/
            the app's name  --base-domain             the app by number

Chosen names (Pro, 2026-11-15; rename APP NAME, spec/AppHostNames.tla). A Pro account may also give an app a name it chooses, NAME.sites.diy, beside the two-word and numeric URLs (which keep answering). The chosen names have a domain of their own, --names-domain (SITE_NAMES_DOMAIN in site.sh, sites.diy on live; staging may point it elsewhere), and it must differ from --base-domain: the base domain is the free, open-signup one, so a NAME.nma.sh host never routes a chosen name. A name is five or more characters of a-z, 0-9 and inner hyphens, at most 30, starting with a letter and at least one letter; it is filtered by the server's built-in reserved words and --name-deny FILE, and may not be a generated two-word name or N-F. An entry in that file is refused as one whole hyphen-separated part, and as a prefix or a suffix of the name with hyphens removed (paypal-login, pay-pal, mypaypal), never merely in the middle; meta, apple, bank and visa are ordinary words too, so those entries match a whole part only. A refusal names the entry that matched. It is a root key of its own, NVROOT1:e:NAME, taken once by a CAS from empty and never rewritten or cleared: it is unique over every tenant and is never reused, even after a rename to another name or the app's deletion. The app's current choice is its record NVROOT1:t:T:F; its chosen_name and chosen_url fields (null without one) are in GET /v1/apps/{app} and the app list. dp-front reads a --names-file of NAME.sites.diy T F lines, one immutable line per claim, and matches it only under --names-domain: a claim that has just committed may lag by a second (404, never another tenant's app). A free account is refused pro_only with Pro's sentence. A name whose write is answered route: "pending" is claimed; run the same rename again to finish publishing it.

The stack behind it is dp/onbox/site.sh (start, stop, status, invite). Its dp-ctlapi has --compiler, so an app can be deployed as source (the site's form, nanovm deploy APP app.js), or as an image from uni/compile-js.sh OUT.elf APP.js (nanovm deploy APP VERSION image, then nanovm promote).

The path a request takes: client, one of two dp-fronts (srv/front_main.c: public HTTP to one line on the pool's tenant-T.sock), one of two dp-warmpoolds, Firecracker guest. The other router, dp-srv router, is on a different path: it takes a guest's db calls to the shard groups. site.sh runs those groups and their gateways too: see "An app's data".

The API's protocol did not change: its commands are untouched (url is computed from the tenant and slot in the request), and an API-uploaded image was already segments and a manifest (bundle_upload, as deploy.sh). dp-front speaks dp-warmpoold's request line with version 0, the path Deploy.tla's pools already serve, plus the START line below (spec/FrontRetry.tla).

A promote reaches the two pools separately. Each adopts it on its own next poll, so until both have, about a second, either version can answer. X-NV-Version says which.

An app's data (built)

kv, db and crdt work in a deployed app with no setup: nanovm deploy APP app.js and the handler calls them (uni/uni_js.c). site.sh runs the tiers crud.sh tests: two shard groups of three replicas, their ctl group and two routers (db), an origin and four edges (kv), three CRDT replicas (crdt), and one gateway (dp-srv dpl) per pool, under DIR/data with their own key and table. A data value is at most 64 KiB, and a request body through dp-front is at most 64 KiB.

Whose data it is. A VM's vsock port 5001 is a link the pool makes when it starts the VM, to DIR/data/gR/tT.sock for the VM's tenant (--tenant-port). The guest names a port and nothing else. The gateway takes the tenant from the listener it was reached on, and every key and name gets that tenant's prefix. So data is per tenant, and a tenant's apps share it. One tenant cannot read or write another's, whatever it asks for (DataIsolated, with a mutant for the link and one for the prefix).

What survives. What a call acknowledged is in the tier, not the VM or the gateway: killing every VM of an app, deploying a new version, kill -9 of any one process, or stopping the whole stack loses no acknowledged write (DataRecycled, DataKill, DataRestart; spec/SiteData.tla). App variables are the VM's, and go with it.

Reading your own writes. A client that keeps its cookies does, across requests, whichever pool and edge answers (DataRyw). A client that keeps none gets a value that may be behind, as kv with eventual does; db.get(key, {consistency: 'strong'}) needs no cookie.

What one read costs. On chi, on two cores shared with the whole stack and the Python client, with other work on the box; one client, a new connection per request, six rounds of 2,000 over two runs. The ranges are that wide: the high end of each data row is one round, 4.5 ms against 1.6 ms for the same work a minute later, and the cause was not found.

Handlerp50p99
no data call0.41-0.57 ms3.8-4.7 ms
one kv.get, session1.6-4.6 ms8.0-11.5 ms
one kv.get, eventual1.6-4.6 ms7.4-11.1 ms
one db.get, session1.6-4.7 ms7.5-10.4 ms
one db.get, strong1.8-4.5 ms7.2-11.5 ms

make onbox-site-bench measures it again. Compare only on one host under one load.

What is left. The gateway is one per pool: while a pool's gateway is restarting, about 0.1 s, that pool's guests' calls throw, and an app that does not catch that answers an error, which dp-front does not retry, since the guest answered. Nothing acknowledged is lost. One or two reads saw that per gateway kill, and now and then one per origin kill; the other tiers' kills cost a reader nothing in these runs, which is a sample of one client, not a bound. The gateways' --meter files are not read by dp-ctlapi --meter yet, and the tiers' checker journals under DIR/data grow with use: neither is ready for a long-lived site.

Apps nobody uses (built, off unless SITE_DELETE is set)

An app with no real request and no deploy for the window is deleted (spec/AppDelete.tla). The default the owner has yet to confirm is 30 days. All of it is below the doors: dp-ctlapi sweep, and state in an app's JSON, which is live, warned, deleting or deleted. SITE_DELETE=WINDOW:NOTICE:GRACE:TICK_MS turns it on, the first three in ticks: for 30 days, a week's notice, a day's grace and an hour's tick, 720:168:24:3600000. Unset, nothing is recorded and nothing goes.

Verified email (built; nma.sh sets SITE_VERIFY, SITE_VERIFIED_APPS and SITE_MAIL_KEY; staging the first two with SITE_VERIFY_SPOOL)

An account is anonymous until a human proves an email (spec/EmailVerify.tla, core/verify.h). SITE_VERIFY=N turns it on; --anon-apps N is an unverified account's apps at once and --verified-apps M (SITE_VERIFIED_APPS, default 5) is a verified one's. Idle deletion passes over a verified account. Both are live caps: they count the apps it may bring back without asking. An owner's delete stops counting at once, so a delete frees room; the sweeper's own tombstone still counts while a late use can restore it without asking, and a gone app does not. A deploy that brings a deleted app back needs room like a new app. The slot numbers (SITE_CAPS's APPS, at most 16) are every account's life: a number is never reused, and apps_full says so when all 16 are used. An account that already holds more than its cap keeps every app and can deploy new versions of them; it takes no new number. The tiers' live caps are 2 unverified, 5 verified and 10 with Pro on nma.sh; a test copy enforces its own first two (staging: the same 2 and 5, with no Pro to buy).

Pro (built; nma.sh sets SITE_PAY_KEY, SITE_PAY_PRICE and SITE_PRO_APPS)

Pro is $5 a month (--pro-price), flat, paid through Stripe Checkout (spec/ProPlan.tla, core/plan.h, NOTES-pro.md). What it gives: apps at once from the account's own cap (2 unverified, 5 verified) to SITE_PRO_APPS (10), within the same 16 slot numbers; apps kept however long they sit idle; with SITE_STORE set, SITE_PRO_STORE db keys a data group and kv keys (default 10 times free's; NOTES-pro.md on sizing). Any owner key may ask; no email is needed.

Custom domains (built, off unless SITE_DOMAINS=1; not on nma.sh)

A Pro account's app answers on a hostname of its own (spec/DomainClaim.tla, NOTES-domains.md). An owner or deployer key, every door: nanovm domain add APP HOST, domain ls, domain rm HOST; MCP's domain_add, domains, domain_remove.

When a process dies

Target: no client sees a failed request when any one process of the stack dies. Each line below is asserted exactly, per kill, by make onbox-site (site_test.py's KILLS), with clients running through the kill and requests held in guests at that moment. Times are ranges over 3 rounds on chi, on two cores shared with other jobs.

Killed (kill -9)What clients seeProcess backPath ready
dp-frontnothing0.05-0.27 sat once: its peer took over its connections
dp-warmpoolda POST in one of its guests: 502, outcome unknown. Nothing else0.19-0.32 s3.3-4.2 s (fetches each app again; a request sent there meanwhile waits, 2 s at most seen)
Firecracker (one guest)a POST in that guest: 502, outcome unknown. Nothing else0.12-0.24 s0.9-1.2 s
bundle-launcher (a pool's agent)nothing0.55-0.65 sat once
dp-srv replica (root group)nothing0.11-0.57 sat once
Garage (S3)nothing0.30-0.61 sat once
dp-ctlapia raw API client it was serving: its connection resets. nanovm retries it and sees nothing0.11-0.53 sat once: the other one serves
the site.sh supervisornothing, but nothing is restarted until site.sh stop and startneverserving goes on

What makes this true is in the kernel, not in any process's memory:

What is left, and why:

A hung process is not a dead one, and no test covers it: by the code, a stopped pool's GETs move on after 12 s and its POSTs get 504; a stopped front's connections wait until it resumes, while new ones go to its peer.

Each app has its own origin. Every app is at its own hostname, so the browser keeps one app's cookies and storage from every other's: dp-front forwards Cookie and Authorization as sent and passes an app's Set-Cookie, dropping one that names a Domain, which could reach a sibling app through the parent domain (HostCookieDomain). The runtime's read tokens nv_tok and nv_dbt are cookies like these, kept out of req.headers by the guest; a token names a time and no data, so a forged one affects only the freshness of the forger's own reads (DataScoped, spec/SiteData.tla). dp-ctlapi is on its own port, a different origin.

Limits today, each refused rather than truncated:

LimitValueFromBeyond it
request body64 KiBFRONT_BODY_MAX413
request headers8 KiB as sent; every header reaches the app but hop-by-hop ones and a visitor's X-Forwarded-*, Forwarded, X-Real-IP and X-NV-* (spec/NOTES-reqheaders.md)FRONT_HDR_MAX, FRONT_FWD_MAX431
path and query255 bytesdp-warmpoold conns[].path414
response, with its headers1 MiB; over 16,128 bytes it travels as a memfd and closes the connectionFRONT_RESP_MAX502 that says the response was too large; the instance is replaced
resident functions per pool8 cached, and a host runs two poolsDP_WP_KEYS503
VMs per pool16 (SITE_POOL_CAP), one for each function and the rest shared by demandDP_WP_VMSa request waits
VMs one function may scale to, per pool8. A busy function gives up what it holds over its share as each lease ends, so it cannot keep another from its first VM (spec/WarmPoolScale.tla)DP_WP_KEY_VMSa request waits
tenants per poolall tenants with deployed apps; optional SITE_TENANTS / --tenant operator pinroot catalog, loaded on demandcache capacity temporarily gives 503; absent apps give 404
connections4096 per dp-front; each has at most 32 requests at a pool at once, and the rest wait thereFRONT_CONNS, FRONT_POOL_WINDOWwait in the backlog

No TLS and no rate limit: dp-front is plain HTTP, and a flood of requests for undeployed apps can make a real first request wait or get 503 (the bounded catalog tracks at most 16 keys). No startup tenant list is required: the front sends a canonical tenant number on the private shared apps socket. Only a linearizable root read establishes absence, and NONE answers only requests waiting before that read was sent. Later waiters get another read; failed reads give 503 or failover, never 404. Tenant IDs are never reused. Status codes: 404 no such app or nothing deployed, never a pool that is down, 502 the instance failed or its response was malformed (the outcome is unknown), 503 not available yet or no room (Retry-After), 504 no answer in time (the outcome is unknown), including a handler stopped at its 2 s budget (DP_WP_LEASE_MS), which names that limit.

An app's data, from outside (built)

An owner reads and deletes the account's db from outside any app, through every door: the door's and CLI's db list APP [PREFIX] [--after K] [--limit N], db get APP KEY, db delete APP KEY and db export APP; MCP's db_list, db_get, db_delete and db_export; and the routes below. APP is any app of the account that still resolves, a deleted one too: the data is the tenant's, not the app's, and stays after a delete. A deployer or reader key is 403 forbidden.

The same path an app takes. For each request dp-ctlapi forks a reader. The reader writes WHO_DIR/PID (TENANT APP, mode 0600), then connects to a gateway's --guests listener named by --data SOCKET:WHO_DIR (two, one per gateway, tried in turn). The gateway names it as it names a pool's guest (spec/GuestIdentity.tla, srv/guestid.c): the kernel's peer pid, that file, a live peer. Every key it reads or deletes gets that tenant's prefix, so no request can name another tenant's keys; a ?tenant= of another is 404 as on every route. Each gateway has its own listener for this, gR/api.sock with gR/apiwho, so the API's files never share a directory with the pools'. Reads are strong, a delete is db.delete's unconditional one, a list db.list's (spec/KeyList.tla, spec/KeyDelete.tla): no new protocol path, so no new spec. The reader removes its files before it exits; one killed (15 s, 300 s for an export) has them removed by the parent. A new pid for each request means a reader never carries another request's tenant.

What it costs. Nothing is counted against the account's room. Calls are rate-limited per account on each server, --db-rate N a minute (120; an export costs 10), with 2 at once per account and 8 per server: 429 slow_down with retry_after_s and Retry-After, or 429 too_many_readers. The reader answers the client itself, so a large export does not hold the API's one request at a time.

Answers. list: {"app","keys":[...],"next":KEY|null}. get: {"app","v":N,"value":"..."} or 404 not_found. delete: {"app","deleted":true|false}, sent once (a 504 outcome_unknown means read the key). export: NDJSON, 200 keys a page, a strong read for each, lines {"key","v","value"} then {"end":true,"keys":N}; a failure partway writes an error line, and {"after": KEY} resumes (the CLI does it itself). Keys and values are UTF-8 in JSON strings, invalid bytes as U+FFFD; a key is at most 512 bytes with no NUL or tab. A data tier that does not answer is 503 data_unavailable or busy.

The e2e (make srv-test-ctlapi-e2e) runs it against a stand-in gateway that names peers the same way, with mutants 50 DbOwnTenant, 51 DbOwnerOnly, 52 DbRate, 53 DbExportWhole, 54 DbWhoCleared and 55 DbDeletedReadable; make onbox-site runs it against the real gateways.

Backups (Pro, built)

Pro keeps a daily copy of every app's db and kv and can put one back (NOTES-backups.md, spec/Backups.tla). Off unless the site sets SITE_BACKUPS=1: one dp-ctlapi backup process takes the copies, and the API servers get --backups for these routes. A server without it answers 404 not_found ("this server has no backups").

Method and pathWhoCommandAnswer
GET /v1/apps/{app}/backupsan owner keybackups APP, MCP backups {app}{"app","backups":[{"date","db_keys","kv_keys","bytes"}]}, newest first
POST /v1/apps/{app}/backups/{date}/restorean owner keyrestore APP DATE, MCP restore {app,date}{"app","date","db_written","kv_written","keys"}, after every record

date is YYYY-MM-DD, a UTC day. Only the last seven are visible; an older date, or one with no manifest, is 404 not_found ("backups APP lists the last 7 days"). A free account is 403 pro_only with Pro's sentence and nanovm upgrade; a deployer or reader is 403 forbidden.

What a backup is. For each of the app's db keys, a strong read gives the key's value and the version it had then; kv keys are read eventual (kv has no strong read). It is one committed version per key, not a cross-key snapshot: a key written after it was read is in the next day's. It is stored in the site's S3 origin as backups/TENANT/SLOT/YYYY-MM-DD (a small manifest, at most 512 parts) over the existing content-addressed chunks (at most 256 KiB each); seven days are kept per app, and deleting the app deletes its manifests. Chunks are content-addressed and shared, so they stay for a collector, as deploy segments do.

What a restore does. It reads every record and writes it back: db with db.cas at the version it reads just before (retrying if a writer moved the key), so every key gets exactly one new version; kv with kv.put, also a new version. It is not atomic across keys: a reader sees each key either before or after its write, never a torn value, and across keys any mix. Keys added after the backup are not deleted, and a restore interrupted partway leaves that mix; run it again to finish. The answer counts what it wrote; a tier failure is 503 data_unavailable with how far it got.

The e2e (make srv-test-ctlapi-e2e) takes a backup, changes keys, restores, lists, shows the 8th day dropping the oldest, refuses a free account, and shows a deleted app's backups gone; mutants 80 BackupFree, 81 BackupTake, 82 BackupRestore, 83 BackupKeep7 and 84 BackupDeleted are each caught by name.

v1 wire summary (built)

Method and pathWhoBody / headersCommand
POST /v1/signupan invite, no key{"tenant": T, "invite": hex, "key_hash": hex, "ref"?: TAG}read p:0, admin add on p:T*64+1, optional CAS from 0 on w:s:T
POST /v1/signupno key, --open-tenants{"key_hash": hex, "ref"?: TAG}read p:T*64+1 along the key's walk, then as above
GET /v1/tenantanyread p:ID and w:s:T (ref: TAG or null)
GET /v1/keysanyread p:T*64+1..63 (no hashes returned)
POST /v1/keysowner{"id": N, "role": ..., "key_hash": hex}, Idempotency-Keyadd on p:N, tenant = the caller's
DELETE /v1/keys/{id}ownerIdempotency-Keyrevoke on p:id
GET /v1/apps, GET /v1/apps/{app}anyread n:T:1..16, a:T:F, c:T:F:*, s:T:F
POST /v1/appsowner, deployer{"name": ...}, Idempotency-KeyCAS n:T:F from 0
GET /v1/apps/{app}/deploymentsanyread c:T:F:1..
POST /v1/apps/{app}/deployowner, deployerthe JS source; no key, version or If-Match: sending it again is safecompiles, creates the app if new, reuses the version holding these bytes or commits the next, moves the pointer (spec/ControlDeployOp.tla); 422 compile_error carries the diagnostic; needs --compiler. The answer's build is what the app printed while it loaded (50 lines at most) and first the status and time of a GET through the front once that version answers (--first-request; null when off or nothing answered in 10 s)
POST /v1/deployowner, deployerthe JS source and an Idempotency-Keyas the deploy above, to a new app named from (tenant, key) alone, quiet-river-7k2: a retry with the key is the same app; a new key whose name is taken is 409 name_taken, and the CLI retries once with another (spec/NOTES-ctlapi.md)
POST /v1/apps/{app}/deployments/{V}owner, deployerthe image, Idempotency-Key; V the next versionS3 upload, CAS on the ring's slot for V (see below)
POST /v1/apps/{app}/deployments/{V}/promoteowner, deployerIf-Match, Idempotency-KeyCAS a:T:F
POST /v1/apps/{app}/rollbackowner, deployerIf-Match, Idempotency-KeyCAS a:T:F; 409 app_deleted after an owner's delete (also promote)
POST /v1/apps/{app}/renameowner, deployer{"name": ...}, Idempotency-KeyPro only: CAS e:NAME from 0 (never rewritten), then the record t:T:F and dp-front's --names-file line, NAME.sites.diy; 409 name_taken
DELETE /v1/apps/{app}ownerIf-Match, Idempotency-KeyCAS on the record u:T:F: the owner's tombstone ("Apps nobody uses")
PUT /v1/apps/{app}/secrets/{NAME}owner, deployer{"value": ...}, Idempotency-Key; If-Match when the app existssealed set to S3, CAS s:T:F naming the request; before the app's first deploy, CAS q:T:F
DELETE /v1/apps/{app}/secrets/{NAME}owner, deployerIdempotency-Key; If-Match when the app existsCAS s:T:F, or q:T:F before the first deploy, naming the request
GET /v1/apps/{app}/secrets[/{NAME}]none: 405, write-only
POST /v1/dashany key (not a dash session)none; no Idempotency-Key: nothing is written{"url": "PUBLIC_URL/dash#t=TOKEN", "role", "expires_in_s": 300, "session_s": 28800}: the token is the account, key, role and mint time under an HMAC of the root key; 404 with no --public-url; a session is 403
POST /v1/dash/redeemno key: the token{"token": hex}read p:ID, then CAS u:dash:T (the newest mint redeemed, the sign-out epoch) from the generation read; {"tenant","key","role","session","secret","expires"}, or 400 link_invalid, 410 link_expired or link_used, 401 for a revoked key
POST /v1/dash/signoutownernoneCAS u:dash:T: the epoch + 1, ending every session of the account
GET /v1/usageanythe server's --meter files
GET /v1/admin/usageany key of the --admin-tenant?days=N (1..366, 30), ?after=Tlinearizable reads of p:, v:, w:T, w:T:F, w:a:T and the plan per tenant, and w:d:S per day ("Usage of the site"); another account's key gets 404 not_found
GET /v1/admin/emailsany key of the --admin-tenant?after=Tverified accounts (NVROOT1:v:T) with sealed S3 addresses (emails/<eid>) unsealed and hash-verified; another account's key gets 404 not_found
GET /v1/apps/{app}/logsany?follow=1, ?after=E-S, ?limit=N (1..1000), ?version=Vnone: the socket goes to dp-logd, which answers NDJSON (below); needs --logs
POST /v1/apps/{app}/db/listowner{"prefix"?, "after"?, "limit"?} (1..1000, 100)a forked reader's DBLIST through the gateway ("An app's data, from outside"); needs --data
POST /v1/apps/{app}/db/getowner{"key"}the reader's strong GET
POST /v1/apps/{app}/db/deleteowner{"key"}, no Idempotency-Keythe reader's DBDEL, unconditional
POST /v1/apps/{app}/db/exportowner{} or {"after": KEY}DBLIST pages and strong GETs, NDJSON

A HEAD request is answered as the GET of the same path would be, with the same status and headers and no body; on a /v1 route, where every read is signed for its method, it is 405.

Keys are NVROOT1: root-group keys (dp/core/root.h). Roles are enforced at apply; readers can read and nothing else.

The control API is how a tenant manages apps: deploy code, set configuration and secrets, see instances and usage. It is not on the request path: function traffic goes through the routers, gateways and warm pools, never through this API, so a control-plane outage stops changes, not serving.

Versions kept, deploys per hour, and what a tenant can hold (built)

An app keeps its last 10 versions, the current one always among them. A deploy past that frees the oldest that is not current, in the one command that commits the new version, so a retry frees nothing more. Promoting or rolling back to a freed version is 410 version_gone; a number that never existed is 404. A retry that starts while its first attempt is still in flight can commit twice under two numbers: two versions freed, the key count unchanged (spec/VersionLimit.tla, RetryFreesOne).

A tenant has at most 60 deploys an hour (--deploy-rate, 0 for none), on the one route all four doors use, charged before the compile; past it, 429 slow_down with Retry-After. The count is one root key per tenant, so every server shares it and a restart keeps it. A retry is charged too.

The bound, keys in the root group a tenant can hold: 63 principals + 16 apps x 14 (name, pointer, secrets record, usage record, 10 versions) + 1 for the rate + 1 for the dash record (u:dash:T, made by the account's first sign-in link) + up to --max-apps sets for names not deployed yet = 305. Measured end to end (a real replica's store, counted): an app with 10 versions holds 12 keys, after 12 deploys still 12, with 3 secrets 13: all secrets are one sealed record. Open sign-up's tenant cap N must keep N x X + reserve <= capacity, X being the keys one tenant can hold under the site's caps, plus a reserve (the operator's keys and apps still in the old layout of up to 64 versions). With live's 16 slot numbers and 3 key ids, X = 3 + 16 x 14 + 1 + 1 + 16 = 245, so the root's 65,536 slots (49,152 keys) hold 200 tenants that fill every slot. SITE_OPEN=340 is a cap, not a reservation, as it was at 10 slots (154 keys a tenant); the root's room is watched in NOTES-status.md. The tiers' live caps change no key count: a number is never reused. An app's hostname (squeezing-beagle, "App URLs") adds nothing: it is computed from the slot, not stored. A chosen name is stored: one NVROOT1:e:NAME key per name ever taken (never reused, not even after a rename), and one NVROOT1:t:T:F record for the app that has one now. Neither is part of the caps below. The caps are built: --max-apps N (1..16) and --max-keys N (1..63) on every server of a site (site.sh SITE_CAPS=APPS:KEYS), off by default. --max-apps caps the slot numbers creation may use, for every tier, and not a count, so two servers creating at once cannot pass it; since a number is never reused it holds for good: a deleted app keeps its number, a revoked key its id. --anon-apps N, --verified-apps N and --pro-apps N cap the apps at once by tier. Past them, 413 apps_full (an app create, or a deploy that would create one; a deploy to an app the tenant has still works) or keys_full. They apply to every tenant, invited ones too; an app or key made before them stays. Growing the root is not free: test-rootfill on the laptop, three runs each, at 3,072 keys a write averages 17 to 22 us, worst 30 to 46 ms, recovery about 30 ms; at 12,288 keys 186 to 203 us, worst 515 to 696 ms, recovery about 340 ms. At 49,152 keys it did not finish filling in 200 s. Four times the keys, about 18 times the worst stall: compaction's insertion sort is the first suspect, not yet measured on its own. Fix that before growing the root.

The SSH door (built)

ssh nma.sh deploy hello < app.js is the deploy above. OpenSSH authenticates, and srv/nanovm-ssh-keys, its AuthorizedKeysCommand, lets every key in with a forced command carrying that key's hash, restricted to no port, agent or X11 forwarding and no user rc. A PTY is left to a person: with no command and a terminal the door prints a short welcome (the key's account or the signup command, one deploy example, help and llms.txt), and ssh nma.sh -- cmd has no terminal and reads the agent list, byte for byte as before. The welcome's own address and site come from the door's sshd config — SetEnv NV_DOOR and SetEnv NV_WEB — so one binary serves live and staging (dp/onbox/live/sshd_door.conf and dp/onbox/staging/sshd_door_stg.conf); with either unset it prints the nma.sh text. Both configs say PermitTTY yes. Set dp-ctlapi's --door to the command readers should copy from verify and Pro answers. Use ssh nma.sh for the public door, or specify the site's non-22 port with ssh -p PORT HOST. nanovm door holds one directory of credentials per key and sends the same request as the CLI and the site. signup [INVITE] [--ref TAG] gives a new key its account: nothing to save, and the door keeps the API key. TAG is 1-24 chars of [a-z0-9-], stored once at sign-up and shown in tenant --json as ref. The client controls the command words and stdin; the words never reach a shell.

login ID < secret attaches a key made elsewhere (the HTTP sign-up, keys create, another CLI) to this SSH key: the secret is stdin's first line, one line of hex, and the door checks it with one signed GET /v1/tenant before writing anything. It then stores the key as signup does: the same private directory, the same lock, the same atomic write, the hash of the secret and never the secret. A wrong id or secret stores nothing and answers the API's error; a key that already has an account is refused with door_has_account (naming keys and tenant), because a door's credentials are never replaced. The secret is never printed.

dash prints one line, a link to the web dashboard (POST /v1/dash; DASHLOGIN.md). The browser that opens it is signed in to this key's account with this key's role, once, within 5 minutes of the link, for 8 hours, and no key id is taken. A second open answers 410 link_used, naming dash again and dash signout, which (owner key) signs every browser of the account out. A dashboard session cannot make keys or links. Free accounts have it.

mcp is MCP over this connection, each tool a child of the door under the key's own account (spec/NOTES-mcp.md): {"command":"ssh","args":["nma.sh","mcp"]}.

rollback APP goes to the newest older version that differs from the live one, through POST /v1/apps/{app}/rollback; rollback APP V is a promote of V. The site's button and the CLI's nanovm rollback APP are the same request, at the generation the door just read. Sent again after a lost answer it reports the first outcome and moves nothing; with nothing older it is 409 nothing_older. secret set APP NAME takes the value on stdin, dropping one final newline, and secret delete APP NAME removes it; both work before APP's first deploy, which then starts with the set. When either returns, the app's next secrets.get sees the change. retry finishes a change whose answer was lost. logs APP prints the app's recent lines, and logs APP -f follows them until the SSH client goes.

Match User nv
    AuthorizedKeysFile none
    AuthorizedKeysCommand /path/nanovm-ssh-keys /path/nanovm /var/lib/nanovm/door IP:PORT %t %k
    AuthorizedKeysCommandUser nobody
    PasswordAuthentication no
    PermitTTY yes
    SetEnv NV_DOOR="ssh nma.sh" NV_WEB=https://nma.sh

Principles

Authentication and principals

Resources

All paths are under /v1. Names are [a-z0-9-]{1,31} (they become tier key prefixes and NVS1 identity fields, which allow 1..31 bytes).

Tenants and members (owner; v1 built: tenant read, keys create/list/revoke)

Apps (v1 built: create, list, get, delete; PATCH is draft)

An app is a named function with its configuration; it has a current deployment.

Deployments (v1 built: upload, list, promote, rollback)

A deployment is an immutable version: a compiled bundle whose manifest digest is committed in the deployment root (the launcher of NOTES-origin.md).

Instances (read-only; draft, not in v1)

Configuration and secrets (v1 built: secrets PUT and DELETE with If-Match; env is draft)

Logs (built: NOTES-logs.md, spec/LogFollow.tla)

Usage (v1 built: summed from the server's --meter files until a collector exists)

Usage of the site (built; admin only; NOTES-usage.md, spec/UsageFacts.tla, spec/FunnelFacts.tla)

The site's own funnel, for its operator. Not a door command and not in llms.txt: the CLI has nanovm admin-usage [DAYS], and examples/admin-usage shows it as a page.

Errors

Every refusal is JSON {"error":{"code","message"}}; code is a stable snake_case token an agent may branch on, and message names the condition and the next step. A resource of another tenant is 404, never 403: the API never says that a name exists elsewhere.

Error codes (built)

CodeStatusWhenWhat to do next
unauthenticated401no signature, an unknown or revoked key, a bad signature, or X-NV-Date outside +-5 minsign with a live key and the clock in the window
forbidden403the key's role cannot do this (a reader deploy, a non-owner's data read)use a key with the role the route needs
pro_only403the feature (a custom domain, a chosen name, backups) is part of Prorun nanovm upgrade for a checkout link
invalid_invite403the invite's tag does not match the keyuse the invite dp-ctlapi invite printed
invite_required403open sign-up is off and no invite was sentsign up with an invite
not_found404no such app, version, key, secret, data key, or a name of another tenant; also a server that does not build apps, has tree deploy off, keeps no logs, has no paid plan, offers no chosen names, or reaches no app datacheck the name in this account; for those seven ask the operator
not_available404email verification is off on this server (no SITE_MAIL_KEY/SITE_VERIFY_SPOOL): nothing was senttell your human this site has no mail; a retry will not send it
no_billing404this account has never paidrun nanovm upgrade to start Pro
method_not_allowed405a known path with the wrong method, or a site that does not delete appsuse the method the wire table documents
write_only405a read of secretswrite the secret; secrets are never read back
already_verified409this account already verified another email, and keeps itrun nanovm tenant to see the address; nothing was sent
email_taken409that email verified another nma.sh accountask your human for another address and run nanovm verify OTHER@EMAIL; one email verifies one account
conflict409If-Match is not the current generation, the Idempotency-Key is older than this key's latest, the app name or version is taken, or the app was deployed while its secret was writtenread the generation for If-Match; for a name or slot take a new name or a new Idempotency-Key; for the secret race run the command again
idempotency_key_reused409the same Idempotency-Key named a different requesttake a new Idempotency-Key
invite_used409the invite was already redeemedobtain a new invite
name_taken409a nameless deploy's generated name, or a chosen name, already belongs to another appretry with a new Idempotency-Key (a generated name), or choose another chosen name
domain_taken409another account has that hostname and it is served for themrun nanovm domain rm HOST in that account first, or use another hostname
nothing_older409a rollback with no older version to go todeploy a new version
app_deleted409a promote or rollback of an owner-deleted appdeploy it again to bring it back
version_gone409, 410409: the version went with its app; 410: it is older than the last CTL_KEEP versionsdeploy the source again
apps_full413the account has its tier's apps at once: 2 unverified, 5 with a verified email, 10 with Pro; or all 16 app numbers are used (they are never reused, so a deleted app keeps its number)delete one and its room is freed at once, or deploy a new version of one it has; bringing a deleted app back needs room like a new app; run nanovm verify THEIR@EMAIL for 5 instead of 2, or nanovm upgrade for 10 with Pro
domains_full413the account has named all 10 custom domains it may ever have; a place is never given back, even after its domain is removeduse a hostname it already holds; a domain removed before can be added again
keys_full413every key id of the account is used (3 on the free tier), and an id is never reusedrun nanovm keys revoke ID, or keep using a key it has
full413the root group's fixed key table is full, a name's pending and app secret sets hold 17 entries (16 allowed), or a store every account shares is out of roomfor a secret set delete one with nanovm secret delete APP NAME; for a shared store delete keys; for the root the operator must grow it, then retry
too_large413the body is over 32 MiB, a static tree over 27 MiB, or the compiled image is too largemake it smaller; about 6 MB of source deploys
compile_error422the compiler rejected the source; the message is its diagnosticfix the code and deploy again
if_match_required428a mutation that needs If-Match sent noneread the generation and send If-Match
slow_down429the sign-up, deploy or data-call rate limit was reached; retry_after_s and Retry-After say how longwait that many seconds, then retry
rate_limited4295 verify links an account and 3 an address a day were asked foruse the link already sent, or wait the minutes the message names
too_many_readers4294 log followers or 2 data readers are already open for the accountclose one, then retry
internal_error500the server could not generate a name for a nameless deployretry; report it if it repeats
error500, 503, 504the generic fallback: an unexpected answer, a verification or plan record that does not decode, or an over-long answerretry once; if it repeats, tell the operator
checkout_failed502Stripe did not make a checkout; the message is Stripe'sretry nanovm upgrade later, or tell your human
portal_failed502Stripe did not make a billing link; the message is Stripe'sretry nanovm billing later, or tell your human
unavailable503a dependency is down: the message names root, S3, compiler, payment, mail or meterretry where it says so (a mutation: the same Idempotency-Key); otherwise tell the operator
no_room503every open sign-up tenant is takencontact the operator, or try again later
logs_unavailable503dp-logd did not answerretry
data_unavailable200, 503the data plane did not answer or its answer was malformed; a db export that fails mid-stream answers 200 with a data_unavailable lineretry; for an export continue with after=<last key>, do not restart from the first key
busy503the data tier is busy (a table or the account's share)retry when it has room
warming503a source retry found its version committed but the pool not readyretry the same source
outcome_unknown504the root group did not answer in time; the command may have appliedretry with the same Idempotency-Key (a deploy: the same source)
invalid400a malformed body, path, name or number; version too large (over 64); a non-Stripe body to /v1/stripe; or a signature that does not checksend the body and names the route documents; for version 64 delete the app and deploy again
idempotency_key_required400a mutation with no Idempotency-Keysend an integer key that increases per key
version_limit400an app on the old key layout holds its last version (64)run nanovm delete APP, then deploy again

A server that is a test copy of this one (--test-copy NAME:HOST, staging's SITE_TEST_COPY) says where those features run instead, when it builds none of them: not_available for a mailed verification, and the no-paid-plan and no-custom-domains not_found, answer "email verification runs on nma.sh itself: this is staging, a test copy of nma.sh, and nothing was sent" (and the same sentence for Pro (upgrade) and custom domains). A copy that builds verify never says it: its verify is 202, its mail spooled, its link on the copy's own --public-url, and its own words name the copy (--base-domain), never the site it copies. Live sets no --test-copy, so its answers are the rows above.

The test for every row is dp/srv/test_ctlapi_errors.py, which runs the real server and prints the answer each produced (ANSWER <code> <status>). dp/tools/verify-errs.sh extracts this table and requires each code to be produced or listed with a reason in CONTROL-API-ERRS.md.

The CLI's side of the same promise is dp/srv/test_cli_errors.py: it runs the real nanovm binary against the real server, and for every code a command can meet checks a non-zero exit, the code's meaning and next step in the words above, and --json carrying the server's code and message unchanged. dp/tools/verify-clierrs.sh extracts this table and requires 80% of the codes to be checked on the CLI or listed with a reason in CONTROL-API-CLI-ERRS.md.

Data plane errors (in-band)

An app's db, kv and crdt calls answer no HTTP status: a refusal is prose on the ERR frame, prefixed by the operation and a word, and the app sees db.put: <word>: <text>. quota: is the account's share of a db group or kv; full: is a store every account shares (the root group's table; a name's pending and app secret sets, 17 entries with 16 allowed; or the db/kv store); busy: means a table or slot was busy and the write was not applied; unavailable: means the gateway, router or replica did not answer (a write may have applied only if it says unknown:); unknown: means the outcome is unknown and the write applied at most once, so read the key before rewriting it. crdt:, db:, db LIST:, db PUT:, db list:, kvs:, kvs LIST:, kvs PUT: and stale: are protocol diagnostics: the message names the bad op, cursor, prefix, limit or write id, and the fix is in the words. The exact text of each is in NOTES-erraudit.md.

What the model checks (spec/ControlAuth.tla)

Authorization is checked AT APPLY in the Raft group that holds both the tenant's roots and its principals. Every root command carries {principal, idempotency key, op}. The state machine refuses it unless the principal exists, is not revoked, belongs to the root key's tenant and has the role the op needs. The API servers and the future host-side broker are not trusted for isolation; the model treats the submitter as an adversary (spec/NOTES-ctlauth.md has the trust model). Checked, each with known-bad designs that fail:

Idempotency-Key, as modelled and as the core's dedup allows: an integer that increases per API key. An equal key returns the first result, and a lower one is refused (409: read before retrying). The operator's deploy.sh keeps working for tenants that have no principal yet ("unclaimed"). Adding a tenant's first owner claims it for good.

Not covered: authenticity of the principal name. A component holding the cluster key can act as any live principal, within that principal's tenant and role. Signed commands verified at apply would close this (spec/NOTES-ctlauth.md, "Trust model").

What the API model checks (spec/ControlApi.tla)

Stateless servers, sequential clients that retry unknown outcomes with the same key, lost and duplicated requests and responses, server timeouts, the group applying a command more than once, If-Match races and revocation racing in-flight requests. Checked: ControlAuth's invariants, NoLostUpdate, RetryIsSafe, TenantFromPrincipal, SecretsNeverRead, RevokedReadsDead, SecretBeforeDeploy and the liveness property Learns. Nine known-bad designs fail their properties, and four reach configs show a 504 then a retry returning the original result, a 409 loser, a rollback through the API and a revoke landing on an in-flight request.

Open questions

Settled by v1 (above): API keys and request signing, integer Idempotency-Keys, If-Match on promotes and secret sets (a set for a name not deployed yet needs none), write-only secrets, tenant from the key.

Experimental tree deployment and static files (off by default)

The compiler API accepts POST /v1/apps/{app}/deploy-tree only with --static-trees 1. Its signed body is an opaque, uncompressed ustar archive, bounded at 27 MiB. The existing deploy operation, authentication, retry handling, version commit and pointer CAS are shared with the source endpoint. The host never extracts the archive or parses application source. The compile guest validates paths, file kinds, checksums, duplicates and limits, loads app.js and its relative modules, and generates the static table and compressed bodies. The limits and format are in NOTES-static.md.

A directory must contain app.js; assets belong under public/. public/index.html also answers the app root. A successful tree deploy returns static_base and, when that index exists, page_url: open page_url for the version-qualified page.

Use nanovm deploy APP DIR, the site's optional directory picker, or nanovm pack DIR | ssh HOST deploy APP. The native CLI and browser WASM use the same C ustar writer. SSH recognizes the writer's ustar transport marker; it does not validate or unpack its files. The explicit SSH command deploy-tree APP also forwards opaque tree bytes. These doors call the same control endpoint. The MCP deploy tool accepts {"app":"APP","directory":"/absolute/path/to/DIR"}. The directory is local to the MCP server; it requires an app name and an absolute path, and cannot be combined with source. It runs the same CLI packer. For HTTP, sign POST /v1/apps/APP/deploy-tree with the bytes from nanovm pack DIR. In the web panel, choose the app name and directory picker, then Deploy. Credential filenames and links are refused; no package manager runs on the host. The directory picker is offered only when the API serves its WASM packer.

Enable the pool and front with --static 1; the site harness exposes all three options as SITE_STATIC=1. Upgrade both paired fronts and their pools before enabling it. Each pool publishes an immutable version descriptor only after verified installation and adoption. Each front learns complete descriptors outside request dispatch and pins a version for its answer. Static GET/HEAD hits use the front's own file descriptor and sendfile, without a pool request or VM. An unknown app can use the existing pool path for discovery; its held answer is inspected against that actual lease's descriptor before a public-file hit is answered. A pool may evict the key and reuse its view before the front reads it; the front then reads that one version's descriptor from the answering pool's catalog, and serves it only after a pool answers for that version. Missing admission returns an error rather than another version's file.

Dynamic handlers receive req.staticBase, also available as the internal X-NV-Static-Base request header. The pool derives it from that VM lease's version and verified manifest, including for a draining old VM. It is a version-qualified base within the app's route; append a public file's path. Such URLs resolve a retained immutable descriptor or return 410. They never fall back to a newer version. Unqualified names follow independent front/pool adoption as before. Full verified SHA256 filenames and qualified URLs get immutable caching; mutable names require revalidation. ETag, conditional GET, HEAD, single byte ranges, Accept-Encoding and representation-specific hashes are covered in NOTES-static.md.

The option includes bounded admission, per-front static quota with --quota, and static use reporting through the existing inactivity mechanism. The local catalog's static bytes have separate per-pool bounds. Shared object-segment GC remains open: app deletion removes manifests and retires views, and does not unlink a shared child merely because one app stopped referencing it.

nma.sh Control API reference