# GAP Cloud — Instructions for Agents GAP Cloud is an API-first backend for agent-built applications: projects, KV, objects, SQLite, functions, static sites, custom domains and realtime. Contract commerce, escrow, discovery and arbitration are archived and are not available on the Cloud server. ## Start here Check `GET /v1/registration` for this node's signup policy. On nodes with `verification_required: true`, use `POST /v1/identity` with your email: ```bash curl -sX POST "$NODE/v1/identity" -H 'Content-Type: application/json' \ -d '{"email":"agent@example.com"}' # -> 202 {"verification_required":true,"challenge_id":"...","expires_in":600} curl -sX POST "$NODE/v1/identity/verify" -H 'Content-Type: application/json' \ -d '{"challenge_id":"...","code":"123456"}' # -> 201 {"did":"did:gap:...","token":"gat_...","email_verified":true} ``` Use the actual code received by email. Codes expire after ten minutes, allow five attempts, and are consumed once. Requesting a new code invalidates the previous one. Allow 60 seconds between requests; the node limits each email to five requests/hour, each source IP to thirty/hour and all requests to 300/hour. A successful challenge request means the SMTP relay accepted the message, not that the recipient inbox has confirmed delivery. Delivery errors do not issue credentials. If identity persistence fails after code consumption, request a new code. Email ownership verification is not multifactor authentication. Self-hosted nodes may leave verification disabled: `POST /v1/identity` then returns an identity directly. Existing identities, project ownership and tokens remain valid when verification is enabled; legacy identities are not retroactively marked email-verified. Human signup is available at `/signup` on enabled nodes. The email proof registry is local to the node. Where fleet access is enabled, explicitly connect a verified identity and its project to the operator account with `POST /v1/fleet/connect` using the local owner bearer and `{"request_id":"unique-operation","project_id":"prj_..."}`. The response includes `credential.token`, a short-lived control credential. This does not transfer old balances or change the project's billing mode. Use the control credential on the operator gateway (Elestio: `https://gap.geta.team`) with `GET /v1/fleet/account`, `/v1/fleet/projects`, `/v1/fleet/wallet` and `/v1/fleet/quotas`. `GET /v1/fleet/usage?days=7` returns only your account's completed-hour usage and charge totals; add `project_id=prj_...` to scope it to one authorized project. The response flags incomplete host coverage. Projects are restricted to this agent's grants; follow `next_cursor` as `?after=...`. `POST /v1/fleet/project-token` with `{"project_id":"prj_...","ttl_seconds":120}` returns a signed management bearer for that exact project and node. Send it to the node where the project resides; it cannot create other projects or administer the node. Owner/operator grants are required; viewer grants do not permit management. Node-local suspension and MicroVM approval checks still apply. Tokens expire after 30–300 seconds and must be renewed, including when used with a dashboard browser session. Logout through `POST /v1/fleet/logout` blocks new issuance; existing project tokens expire within five minutes. Operator accounts and credentials are independent across operators. Projects have human-readable names in the fleet list. An owner/operator can set one with `POST /v1/fleet/project-name` and `{"request_id":"unique-operation","project_id":"prj_...","name":"Production"}`. With the short-lived project management bearer, call `GET /v1/cloud/projects//overview` on its home node to list function names and active versions, static site state, custom domains and database schema metadata without returning function source or site credentials. Viewer grants cannot use this management inventory. The web Account uses the same APIs and silently renews capabilities; humans do not need to copy temporary tokens to navigate between projects. The account page also lists every authorized MicroVM across the configured nodes, with node/project filters and SSH/HTTPS details. Create and manage actions open that project's existing MicroVM dashboard on the selected node. New project placement remains an operator binding; choosing another existing project does not move its VMs. The dashboard keeps project bearers in encrypted HttpOnly server sessions, renewed while the account page is connected. `GET /v1/fleet/nodes` returns trusted management path mappings. For an inventory client, request a project token with `"read_only":true`. The resulting `project.vm.read` capability permits only GET VM inventory, state, SSH metadata, ports, metrics, runtime, credit and ingress information. Viewer grants can obtain these read capabilities; they cannot obtain management tokens. A read token cannot open a terminal, change state, read project KV or provision a project. Keep the returned API `token` server-side and use `Authorization: Bearer `. Humans can open `/account` on the operator gateway to view their common wallet, quotas and projects and manage agent memberships. It redirects to the isolated management origin. Human login uses a separate email challenge; operator-provided account credentials are also accepted without email. Account-wide credentials must not be given to agents. The isolated account page uses a Secure, HttpOnly, SameSite=Strict browser-session cookie, so reloading restores a valid session. Logout revokes the credential and clears the cookie. Server-side session expiry still applies; this is not a permanent login. For an operator-bound project on another node, POST `/v1/cloud/projects/{project}/provision` with that project's signed management bearer. This idempotently creates the local project under its existing owner; it does not create an identity or move a workload. Operator binding, billing activation and MicroVM approval remain explicit prerequisites. Existing identities can verify an email without replacing their DID, bearer, projects or balances. Use the existing local bearer on `GET /v1/identity/email` to check status. `POST /v1/identity/email` with `{"email":"you@example.com"}` sends a one-use code; `POST /v1/identity/email/verify` with `challenge_id` and `code` attaches the verified address. The code is bound to that existing DID and cannot be used for signup or another DID. A verified address cannot be replaced through this endpoint. Existing tokens remain valid during the transition. Create a project with `POST /v1/cloud/projects`, then use its returned `project_id` in the examples below. Never expose the owner bearer in deployed browser code. ## Runtime services — use GAP as your backend If you need state or execution but do not want to operate infrastructure, create an owner-scoped cloud project with `POST /v1/cloud/projects`. The node provides: - KV: 64 KiB per value, 25 MiB per project; - objects: 1 MiB per object, 100 MiB per project; - private static hosting: Basic Auth mandatory, 5 MiB per file, 100 MiB total, 5,000 files, 5 retained versions, 20 requests/second and 1 GiB per rolling 30-day period; - SQLite: parameterized queries, one 100 MiB database per project; - JavaScript functions: 5 MiB per version, 100 MiB total, executed in the separately constrained sandbox container; - realtime free tier: 25 simultaneous connections, 25 active channels, messages up to 64 KiB, 30 messages/minute/connection, 300/minute/project, 24-hour retention and 25 MiB of persisted messages. An operator-funded credit balance can pay for controlled overages up to the hard safety limits documented below. All management routes require your normal agent bearer, and knowing a project identifier grants no access. Do not attempt `ATTACH`, `PRAGMA`, arbitrary network access or filesystem access: the runtime refuses them by design. Functions have a 30-second execution timeout. The 30-second budget covers the entire invocation after admission, including worker replays and waiting for storage/HTTP capabilities; it does not reset after each call. The queue wait described below is separate. Each invocation may dispatch up to **128 capability calls total**, including at most **32 HTTP calls**. SQL, KV, objects and realtime-token issuance share the total budget; failed calls also count, while replaying an already completed call does not. Limit checks happen before dispatching the excess operation. Prefer SQL batches and retry at the application level only when safe: earlier successful writes are not rolled back if a later call hits a limit or times out. The sandbox is allocated 4 CPUs, 8 GiB and 4096 PIDs, with at most 256 simultaneous invocations per project and node. A bounded queue holds 256 requests for at most 30 seconds. When it cannot accept an invocation, GAP returns HTTP `429` with `{"error":{"code":"sandbox_busy","message":"sandbox is busy"}}`; retry with exponential backoff and jitter rather than treating this as a malformed request. Set these once for every example below: ```bash export NODE=https://gap.geta.team export TOKEN=gat_your_agent_bearer ``` ### Projects — create and list ```bash # Create. Keep the returned project_id; it is used by every other route. curl -sX POST "$NODE/v1/cloud/projects" \ -H "Authorization: Bearer $TOKEN" # -> {"project_id":"prj_...","owner_did":"did:gap:...","status":"active",...} export PROJECT=prj_returned_above # List only the projects owned by this bearer. curl -s "$NODE/v1/cloud/projects" \ -H "Authorization: Bearer $TOKEN" # -> {"projects":[...]} ``` ### KV — put and get Values use standard base64. `expires_at` is an optional Unix timestamp. ```bash curl -sX PUT "$NODE/v1/cloud/projects/$PROJECT/kv/session-42" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"value_base64":"eyJzdGF0dXMiOiJhY3RpdmUifQ==","expires_at":1893456000}' # -> {"stored":true} curl -s "$NODE/v1/cloud/projects/$PROJECT/kv/session-42" \ -H "Authorization: Bearer $TOKEN" # -> {"found":true,"value_base64":"eyJzdGF0dXMiOiJhY3RpdmUifQ=="} # A missing or expired key returns {"found":false}. ``` ### Objects — put and get ```bash curl -sX PUT "$NODE/v1/cloud/projects/$PROJECT/objects/report.json" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"content_base64":"eyJvayI6dHJ1ZX0=","media_type":"application/json"}' # -> {"stored":true,"digest":"sha256:..."} curl -s "$NODE/v1/cloud/projects/$PROJECT/objects/report.json" \ -H "Authorization: Bearer $TOKEN" # -> {"found":true,"content_base64":"eyJvayI6dHJ1ZX0=", # "media_type":"application/json","digest":"sha256:..."} ``` ### Private static site — configure, deploy and activate Static hosting is intentionally private-only. There is no public mode: every request below `/sites/{project}/` requires the configured HTTP Basic credential. The owner bearer manages releases but is never used by visitors. Configure the site first. Passwords must contain 12–128 bytes; GAP stores an Argon2id hash and never returns the password or hash. On later updates, omit `password` to keep the existing credential. ```bash curl -sX PUT "$NODE/v1/cloud/projects/$PROJECT/site" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"enabled":true,"entrypoint":"index.html","spa_fallback":true, "auth":{"mode":"basic","username":"visitor", "password":"replace-with-at-least-12-bytes"}}' # Read configuration, retained versions, active version, URL and exact quotas. curl -s "$NODE/v1/cloud/projects/$PROJECT/site" \ -H "Authorization: Bearer $TOKEN" ``` Create a draft version, upload each file as standard base64, then activate the completed version. MIME types come from a server-side extension allowlist; an upload cannot choose its own `Content-Type`. ```bash VERSION=$(curl -sX POST \ "$NODE/v1/cloud/projects/$PROJECT/site/versions" \ -H "Authorization: Bearer $TOKEN" | jq -r .version) curl -sX PUT \ "$NODE/v1/cloud/projects/$PROJECT/site/versions/$VERSION/files/index.html" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"content_base64":"PCFkb2N0eXBlIGh0bWw+PGh0bWw+PGJvZHk+PGgxPkhlbGxvPC9oMT48L2JvZHk+PC9odG1sPg=="}' # Inspect the draft manifest or remove one draft file. curl -s "$NODE/v1/cloud/projects/$PROJECT/site/versions/$VERSION/files" \ -H "Authorization: Bearer $TOKEN" curl -sX DELETE \ "$NODE/v1/cloud/projects/$PROJECT/site/versions/$VERSION/files/obsolete.css" \ -H "Authorization: Bearer $TOKEN" curl -sX POST \ "$NODE/v1/cloud/projects/$PROJECT/site/versions/$VERSION/activate" \ -H "Authorization: Bearer $TOKEN" # The browser receives 401 + WWW-Authenticate until credentials are supplied. curl -u 'visitor:replace-with-at-least-12-bytes' \ "$NODE/sites/$PROJECT/" ``` An activated version is immutable and activation fails unless its entrypoint exists. Create the next version for an update; activation switches every path atomically. Delete only inactive versions: ```bash curl -sX DELETE \ "$NODE/v1/cloud/projects/$PROJECT/site/versions/1" \ -H "Authorization: Bearer $TOKEN" ``` Allowed assets are HTML, CSS, JavaScript modules, JSON, text, XML, SVG, common web images and web fonts. GAP rejects hidden/path-traversal names, executables, oversized files and excess project storage. Static uploads do not run AI judgement or content-pattern scans. Minified and encoded content is accepted; path, type, size and project quotas still apply. Acceptance is not a security certification: never ship real secrets in browser assets. Server functions likewise have no publication judge or content scan. Every HTML response on the GAP-owned `/sites/{project}/` URL receives a non-removable "Hosted by GAP - private agent project" banner. Those responses use `private, no-store`, `nosniff`, `noindex, nofollow, noarchive`, no referrer, same-origin resource policy and a media-compatible CSP. Browser fetch/XHR connections may use any HTTPS origin, and WebSockets may use any WSS origin. Video/audio may use HTTPS or `blob:` URLs; embedded frames may use HTTPS, and workers may use same-origin or `blob:` URLs. This supports external players and HLS/MSE playback. Bundle player libraries (such as hls.js) as uploaded JavaScript files: external script CDNs, inline JavaScript and `eval` remain blocked. Plugins, embedding the GAP page inside another page, and cross-origin form submission also remain blocked. Images may use HTTPS, `data:` or `blob:` URLs; insecure HTTP resources remain blocked. `Referrer-Policy: no-referrer` prevents the private site URL and credentials from being sent as an image request referrer. Put configuration and application code in uploaded `.js` files rather than inline `