# CapVM: full documentation > All CapVM docs in one file, for agents. Real machine provisioning is still being rolled out, so the API may return simulated machines and command output for now. --- # CapVM docs > **Status.** Real machine provisioning is still being rolled out, so the API may return simulated machines and command output for now. CapVM lets AI agents rent their own Linux machines: ARM (`arm-small`) or an NVIDIA L4 GPU (`gpu-l4`). They run in AWS Zurich (`eu-central-2`), Switzerland, and are paid for from prepaid credits (for now, CapVM adds them to your account). Every agent gets its own API key, and each key has a spend cap, a concurrent-machine limit and a list of allowed SKUs. Agents use the machines through a REST API or an MCP server. ## Pricing | SKU | Machine | Region | Price | |---|---|---|---| | `arm-small` | 2 vCPU, 4 GiB memory, ARM64 Linux | `eu-central-2` (Zurich) | $0.20/h | | `gpu-l4` | 1x NVIDIA L4 (24 GB) | `eu-central-2` (Zurich) | $2.00/h | `arm-small` is $0.20/h and `gpu-l4` is $2.00/h. Billing is per second with a 60 s minimum, and the clock starts when the machine is created. Prices are in USD, excluding VAT where applicable. Prices may change. See [Billing and caps](billing-and-caps.md). ## Pages - [Quickstart](quickstart.md): from key to first machine with curl - [Signup and Terms acceptance](signup.md): `POST /v1/signup`, the human confirmation, `403 terms_not_accepted` - [API reference](api-reference.md): every route, field and error code - [Billing and caps](billing-and-caps.md): credits, holds, charges, spend caps and card top-ups - [Limits](limits.md): limits (time, egress, mail ports, concurrency, rate limits) - [MCP](mcp.md): tools for Cursor, Codex, Claude Code and other streamable HTTP clients - [Dashboard](dashboard.md): sign-in, API keys and security for people in your organization (Coming soon) - [FAQ](faq.md) - [Pricing](https://capvm.com/pricing/): ARM64 VM $0.20/h and NVIDIA L4 24 GB GPU $2.00/h, billed per second with a 60-second minimum, prepaid credits that never expire - [Compare](https://capvm.com/compare/): CapVM vs RunPod, Vast.ai, Scaleway, Lambda, Modal and Northflank, with published prices checked Oct 29, 2026 - [MCP server](https://capvm.com/mcp/): an MCP server that lets AI agents rent L4 GPU and ARM machines in Zurich, with a hard spend cap per key For agents: [llms.txt](llms.txt), [llms-full.txt](llms-full.txt), and an OpenAPI 3.1 document at `/openapi.json`. ## Status of features | Feature | Status | |---|---| | REST API: create, list, get and stop machines; usage; balance | Available | | Running commands on a machine (`POST /v1/machines/{id}/exec`) | Available | | MCP server at `https://api.capvm.com/mcp` with an `ak_` key (`create_machine`, `get_machine`, `list_machines`, `stop_machine`, `exec`, `get_usage`, `get_balance`; `create_checkout_session` is Coming soon) | Available | | Buying credits by card (Stripe Checkout), $10 to $1000 per top-up | Coming soon. For now, CapVM adds credits to your account | | API signup (`POST /v1/signup`) with human Terms acceptance by email | Available | | API keys: the CapVM team issues them after signup and Terms acceptance; they aren't self-serve | Available | | Dashboard sign-in (email link or code), self-serve API keys, sign out everywhere, security alerts, "This wasn't me" lockdown | Coming soon | | Signing in to MCP clients such as Codex with OAuth instead of an API key | Coming soon | | Machine and balance views in MCP clients that support MCP Apps | Coming soon | | Web signup, self-serve re-acceptance of updated Terms | Coming soon. For now, CapVM sends acceptance links | | SSH access to your machine | Not offered | CapVM is a product of MAKERSCLUB Molina, Thunstrasse 124, 3074 Muri bei Bern, Switzerland. Contact: hello@capvm.com. --- # Quickstart Get from an API key to your first CapVM machine with curl: check your balance, create a machine, run a command, then stop it. [Sign up](signup.md) to get a key. ## 1. Get an agent key The CapVM team issues API keys after your organization signs up and a human accepts the Terms. Keys aren't self-serve; self-serve keys in the [dashboard](dashboard.md) are Coming soon. Every key has: - a **spend cap** (the most it can ever spend, in micro-USD) - a **max concurrent machines** count - an **allow-list of SKUs** (`arm-small`, `gpu-l4`) > **Terms first.** Before CapVM can issue a key, add credits or start a machine for your organization, a human authorised to bind your business must accept the current Terms of Service and Acceptable Use Policy (Terms §3.1). An agent can start the signup with `POST /v1/signup`, but can't accept. See [Signup and Terms acceptance](signup.md). Without a current acceptance, those calls return `403 terms_not_accepted`. Keys look like `ak_test_…` or `ak_live_…`. Use `ak_test_` while you build and `ak_live_` in production. The secret is shown **once**, and CapVM stores only its SHA-256 hash. ```bash export CAPVM_KEY=ak_test_... export CAPVM=https://api.capvm.com/v1 ``` ## 2. Check your balance ```bash curl $CAPVM/balance -H "Authorization: Bearer $CAPVM_KEY" # {"available_micro":10000000,"held_micro":0,"currency":"USD","unit":"micro_usd"} ``` Money is always an integer number of micro-USD (1 USD = 1,000,000). Not enough credits? For now, CapVM adds credits to your account. Card top-ups are Coming soon: your agent will be able to start one with `POST /v1/checkout/sessions` (an `Idempotency-Key` header and a body like `{"amount_usd":"10.00"}`, $10 to $1000), and hand the returned Stripe `url` to a human to pay. The amount format may change. See [Billing → Topping up by card](billing-and-caps.md#topping-up-by-card). ## 3. Create a machine `ttl_seconds` is required (60 to 7200). `Idempotency-Key` is also required: if you retry with the same key and body, you get the same machine back, never a second one. ```bash curl $CAPVM/machines \ -H "Authorization: Bearer $CAPVM_KEY" \ -H "Idempotency-Key: job-42" \ -H "Content-Type: application/json" \ -d '{"sku":"arm-small","ttl_seconds":900}' ``` `201 Created`. The full TTL is held up front: 900 s × $0.20/h = 50,000 micro-USD ($0.05). ```json { "id": "m_9b1c0e6f2d8a4c3b9e7f1a2b3c4d5e6f", "sku": "arm-small", "state": "provisioning", "instance_id": "i-0abc…", "public_ip": null, "region": "eu-central-2", "ttl_seconds": 900, "price_per_hour_micro": 200000, "hold_micro": 50000, "charge_micro": null, "created_at": "2026-10-25T11:00:00Z", "expires_at": "2026-10-25T11:15:00Z", "ready_at": null, "stop_requested_at": null, "terminated_at": null } ``` If the credits or the key's cap can't cover the hold, you get `402` (`insufficient_credits` or `spend_cap_exceeded`) and nothing launches. ## 4. Wait for `ready` ```bash curl $CAPVM/machines/$ID -H "Authorization: Bearer $CAPVM_KEY" ``` States: `requested` → `provisioning` → `ready` → `stopping` → `terminated`. ## 5. Run a command Wait until the machine is `ready`. The command agent on the machine can take about a minute longer than the machine itself; if it isn't accepting commands yet, you get `409 machine_not_ready` ("Machine is running but is not accepting commands yet."). Retry. ```bash curl $CAPVM/machines/$ID/exec \ -H "Authorization: Bearer $CAPVM_KEY" -H "Content-Type: application/json" \ -d '{"command":"uname -a","timeout_seconds":30,"working_directory":"/tmp"}' # {"stdout":"…","stderr":"","exit_code":0,"truncated":false} ``` - `command` is required (1 to 8192 characters, no NUL). `timeout_seconds` is optional (1 to 300, default 30). `working_directory` is optional: an absolute path; leave it out for the machine's default. - A non-zero exit is a normal `200` result: `{"command":"exit 7"}` returns `exit_code` 7. - `stdout` and `stderr` are each capped at 256 KiB. `truncated` is `true` if either was cut. - A command that runs past `timeout_seconds` returns `408 command_timeout`. All fields and errors: [API reference → exec](api-reference.md#post-v1machinesidexec-run-a-command). ## 6. Check spend, then stop ```bash curl $CAPVM/usage -H "Authorization: Bearer $CAPVM_KEY" curl -X DELETE $CAPVM/machines/$ID -H "Authorization: Bearer $CAPVM_KEY" ``` `DELETE` stops the machine, charges the billed seconds (at least 60) and releases the rest of the hold. If you forget, CapVM stops the machine at `expires_at` anyway. --- # Signup and Terms acceptance How an agent signs your business up for CapVM with `POST /v1/signup`, and how a human accepts the Terms. **Available.** CapVM is for businesses only. Before your organization can get an API key, add credits or start a machine, a **human** authorised to bind the business must accept the current Terms of Service and Acceptable Use Policy (Terms of Service §3.1). An AI agent can start a signup, but it **can't accept** the Terms: acceptance takes effect only when that human confirms it (Terms §3.2). ## How it works 1. Your agent (or you) calls `POST /v1/signup` with the business details and the name of the human who accepts. 2. CapVM creates the organization in status `pending_acceptance` and emails that person a single-use link. The link expires after **72 hours**. 3. The person opens the link. The page shows the account email and the organization's name, country and VAT ID as they are when the page loads (read-only; after a signup retry, the newest values), the Terms of Service and AUP versions with links to `/terms` and `/aup`, the Data Processing Agreement, Billing and Refund Policy and Privacy Policy versions in effect with links to `/dpa`, `/billing` and `/privacy` (a document with no version in effect isn't listed), and the acceptance checkbox (it also covers the Data Processing Agreement), which is **not pre-ticked**. The **I accept on behalf of my business** button stays disabled until the box is ticked. The page says: "Only a person authorised to bind the business may confirm. An AI agent must not." 4. When they tick it and click the button, CapVM records the acceptance and the organization becomes active. Signup doesn't create an API key. Keys aren't self-serve: the CapVM team issues API keys after signup and once the acceptance is recorded. Self-serve keys in the [dashboard](dashboard.md) are Coming soon. ## `POST /v1/signup` Public: no API key needed. ```bash curl https://api.capvm.com/v1/signup \ -H "Content-Type: application/json" \ -d '{ "company_name": "Acme GmbH", "country": "CH", "vat_id": "CHE-123.456.789", "terms_acceptance": { "tos_version": "tos-0.2", "aup_version": "aup-0.2", "accepted_by_email": "person@acme.example" } }' ``` | Field | Type | Required | Notes | |---|---|---|---| | `company_name` | string | yes | 1 to 120 characters after trimming, no control characters | | `country` | string | yes | 2 to 56 characters after trimming, no control characters. Free text, not checked against a country list. | | `vat_id` | string | no | Up to 64 characters. Empty is treated as missing. | | `terms_acceptance` | object | yes | Must be an object. Missing, `null` or `false` is rejected. | | `terms_acceptance.tos_version` | string | yes | Must be the **current** Terms of Service version | | `terms_acceptance.aup_version` | string | yes | Must be the **current** Acceptable Use Policy version | | `terms_acceptance.accepted_by_email` | string | yes | The human who will accept. Up to 320 characters; stored lowercase. The link goes here (sent by email from hello@capvm.com). | The current versions are `tos-0.2` and `aup-0.2`. If you send an old version, the error tells you the current ones in `required_versions`. `201 Created`: ```json { "org_id": "…", "user_id": "…", "status": "pending_acceptance", "request_id": "…", "expires_at": "…" } ``` `expires_at` is when the emailed link stops working (72 hours after signup). The response never contains the link itself. ### Errors Checked in this order: the per-IP rate limit, the JSON body, the per-email rate limit, then `terms_acceptance`, `company_name`, `country`, `vat_id`, and finally `accepted_by_email`. | Status | Code | Message | |---|---|---| | 429 | `rate_limited` | `Signup rate limit exceeded.` (see Rate limits below) | | 400 | `invalid_json` | `Request body must be valid JSON.` (also for an empty or `null` body; `Request body must be a JSON object.` for another non-object body) | | 400 | `terms_acceptance_required` | `terms_acceptance with the current tos_version, aup_version, and accepted_by_email is required.` (missing, `null`, `false` or not an object) | | 400 | `terms_acceptance_required` | `terms_acceptance must include tos_version, aup_version, and accepted_by_email.` | | 400 | `terms_acceptance_required` | `No Terms of Service version is effective yet.` | | 400 | `terms_acceptance_required` | `terms_acceptance must name the current tos_version and aup_version.` | | 400 | `validation_error` | `company_name must be 1 to 120 characters.` / `country must be 2 to 56 characters.` / `vat_id must be a string.` / `vat_id must be at most 64 characters.` | | 400 | `invalid_email` | `accepted_by_email must be a valid address.` | | 503 | `email_send_failed` | `The acceptance email could not be sent. This request can be retried.` with `Retry-After: 30`. Checked last, after the signup is saved (see below). | `terms_acceptance_required` adds the current versions (or `null` when none is effective yet): ```json { "error": { "code": "terms_acceptance_required", "message": "terms_acceptance must name the current tos_version and aup_version.", "required_versions": {"tos_version": "tos-0.2", "aup_version": "aup-0.2"} } } ``` A rejected signup (any `400` or `429`) creates nothing. ### Retrying a signup If you call `POST /v1/signup` again with the same `accepted_by_email` while that person's organization is still `pending_acceptance`, CapVM doesn't create a second organization. The newest submission wins: it replaces the pending organization's company name, country and VAT ID with the values in the new call, makes every unused link for it stop working (opening or submitting an old link then returns `410 link_superseded`, an HTML page unless `Accept` prefers JSON: `A newer confirmation link was sent; please use the latest email.`), and emails a new 72-hour link. The response has the same `org_id` and a new `request_id` and `expires_at`. A retry counts toward the rate limits like any other call. If the email can't be sent, the signup is still saved (the organization exists in `pending_acceptance`), the link created by that call is voided (opening it returns `410 link_expired`, `This confirmation link has expired.`), and the call returns `503 email_send_failed` with `Retry-After: 30`. On a retry, older links were already voided too, so there is no working link until a send succeeds. Retry the same call after that: it's handled as a retry above and sends a fresh link. ### Rate limits `POST /v1/signup` allows **5 requests per hour per client IP** and **5 per hour per `accepted_by_email`** (rolling one-hour window: each call counts for one hour after it's made; CapVM can change these defaults). Over either limit you get `429 rate_limited` `Signup rate limit exceeded.` with a `Retry-After` header: the seconds until the oldest counted call leaves the window, rounded up, at least 1. Every call counts against the IP limit, including ones later rejected as invalid. A call counts against the email limit only when its `accepted_by_email` is a valid address. ## The confirmation link The email links to `https://api.capvm.com/signup/confirm/{token}`. The link works once and for 72 hours. Only the person it was sent to should open it: an agent must not confirm on a human's behalf. Each time the page is opened it issues a new single-use **form token**, valid for 15 minutes, tied to that link and to a hash of exactly what the page showed: the account email, organization name, country, VAT ID, the Terms and AUP versions (with the SHA-256 of their text), the DPA, Billing and Privacy versions, and the checkbox text version. The accept button submits an HTML form with that form token and the ticked checkbox. A JSON request to the link is refused: only the page's form records an acceptance. Opening the page: | Case | Result | |---|---| | Link unknown | Status page, `404` (`not_found`): `This confirmation link is not valid.` | | Link replaced by a newer one (a signup retry or a new link from CapVM) | Status page, `410` (`link_superseded`): `A newer confirmation link was sent; please use the latest email.` | | Link already accepted | Status page, `400` (`link_used`): `This confirmation link was already used.` | | Link expired (after 72 hours), or its email failed to send | Status page, `410` (`link_expired`): `This confirmation link has expired.` | The link checks run in that order, so a replaced link always shows the "use the latest email" page, even after 72 hours. All four follow the rule in [HTML or JSON](#html-or-json) below; for the unknown link that's a status page `

404. This confirmation link is not valid.

`, or `404 not_found` JSON if `Accept` prefers JSON. ### HTML or JSON Link errors (`not_found` for an unknown link, `link_superseded`, `link_used`, `link_expired`) on opening or submitting, and form-token errors on submitting (`400 validation_error`, below), come back as an HTML **status page** by default, with the same HTTP status. The page is one line, the status code then the message, marked with `data-error` (the code) and `data-status`, for example: ```html

410. A newer confirmation link was sent; please use the latest email.

``` They come back as the usual JSON error body (`{"error":{"code","message"}}`) **only when the `Accept` header prefers `application/json` over `text/html`**. Exactly how CapVM reads `Accept`: - It takes the highest `q` given for `application/json` and the highest for `text/html` (no `q` means 1). JSON is used only when `application/json` is listed with a `q` above 0 **and** above `text/html`'s (`text/html` counts as 0 when it isn't listed). - No `Accept` header, an empty one, or one that can't be parsed: HTML. - `*/*`, `application/*` and `text/*` count for neither type. So `Accept: */*` alone gets HTML, but `Accept: application/json, */*` gets JSON. - A tie gets HTML: `application/json, text/html` is HTML. So is `text/html, application/json;q=0.8`, and `application/json;q=0`. - `application/json` on its own, or `application/json, text/html;q=0.2`, gets JSON. The same rule picks between the form again and JSON when the box isn't ticked and for `409 details_changed` (below). Other errors don't depend on `Accept`. ### Submitting the form Checked in this order: first the request, then the link, then the form token, then the checkbox and Terms, then the details. What comes back as HTML or JSON: - Always JSON: not sent as a form, and the Terms having changed. - HTML status page unless `Accept` prefers JSON: the link errors (link unknown included) and the form-token errors. - The form again unless `Accept` prefers JSON: box not ticked (with an inline error), and `409 details_changed`. | Case | Result | |---|---| | Not sent as the page's form (for example JSON) | `400 validation_error`: `Acceptance is only recorded from the confirmation page form.` | | Link unknown | `404 not_found`: `This confirmation link is not valid.` (status page, or JSON if `Accept` prefers it) | | Link replaced by a newer one | `410 link_superseded`: `A newer confirmation link was sent; please use the latest email.` (status page, or JSON if `Accept` prefers it) | | Link already accepted | `400 link_used`: `This confirmation link was already used.` (status page, or JSON if `Accept` prefers it) | | Link expired (after 72 hours), or its email failed to send | `410 link_expired`: `This confirmation link has expired.` (status page, or JSON if `Accept` prefers it) | | No form token | `400 validation_error`: `A form token from the acceptance page is required.` | | Form token unknown | `400 validation_error`: `This form token is not valid.` | | Form token from another link | `400 validation_error`: `This form token does not match this link.` | | Form token already used | `400 validation_error`: `This form token was already used.` (A form token is only used up by a successful acceptance, which also uses the link, so in practice the link check answers first with `400 link_used`.) | | Form token expired (after 15 minutes) | `400 validation_error`: `This form token has expired.` Reload the page to get a new one. | | (all four form-token rows above) | Status page with `data-error="validation_error"`, or JSON if `Accept` prefers it | | Box not ticked | `400`, the acceptance page again (HTML) with the inline error `Please tick the box to accept.` (marked `data-error="terms_acceptance_required"`), the box still unticked, the current details and a new form token. If `Accept` prefers JSON: `400 terms_acceptance_required` `The Terms and Acceptable Use Policy checkbox must be ticked.` with `required_versions`. Either way nothing is recorded, and the form token you sent isn't used up. | | The Terms changed since the link was sent | `400 terms_acceptance_required`: `This link was issued for terms that are no longer the current versions.` (always JSON) | | Anything the page showed has changed since it was loaded (for example the organization's details, or a new DPA, Billing or Privacy version) | `409 details_changed`. Unless `Accept` prefers JSON (then it's the JSON error `409 details_changed` with the same message), it's an **HTML page**: the acceptance page again with the current details, a new form token, and the message `These details changed. Review them and accept again.` Nothing is recorded and the organization stays pending. Review the page and accept again from that page, which uses its new form token. | | Accepted | `200`, page "Acceptance recorded": "The Terms of Service and Acceptable Use Policy are accepted for this business. You can close this page." The organization is active. | When a signup link has expired or is out of date and the organization is still pending, repeat `POST /v1/signup` with the same `accepted_by_email` to get a new one (see [Retrying a signup](#retrying-a-signup)). Otherwise CapVM can send one (see "How to resolve it"). After a `409 details_changed`, the old form token isn't used up: it stays unused until it expires 15 minutes after it was issued, and it can only succeed if the details change back to what its page showed. Use the new form token from the page shown with the 409 (the page does this when you accept from it). Because the link is checked before the form token and the details, a page for a link that was replaced by a signup retry or a new link from CapVM gets `410 link_superseded` on submit, even if its form token has expired, and never `409 details_changed`. Use the link in the latest email. ### What is recorded Each acceptance is stored in an append-only record (never changed or deleted) tied to the human and the organization, never to an API key: exactly what the page showed the person (the form token's snapshot): company name, country and VAT ID, Terms and AUP versions with the SHA-256 of their published text, the DPA, Billing and Privacy versions, the exact checkbox text version stored on the link (`signup-checkbox-0.2` for a first acceptance, `reaccept-checkbox-0.2` when the organization already accepted an earlier version), the time in UTC, the IP address and user agent of **both** the API call that sent the link and the human's confirmation, channel `email_confirm_page`, and the `request_id` of the call that sent the link. If the organization had no country or VAT ID yet, the confirmed values are saved on it. The IP address is your connecting client address. Terms §3.3 describes this record. ## 403 `terms_not_accepted` Until your organization has accepted the **current** Terms and AUP, these return `403 terms_not_accepted`: - `POST /v1/machines` (and the MCP `create_machine` tool) - issuing an API key - adding credits - starting a card top-up, `POST /v1/checkout/sessions` (and the MCP `create_checkout_session` tool), see [Billing → Topping up by card](billing-and-caps.md#topping-up-by-card). It's checked before Stripe is called, so no Checkout Session is created and nothing is recorded when it's refused. Unlike the other actions, it's also refused on a non-production server before any Terms version is in effect, but with a different error: `400 terms_acceptance_required` `No Terms of Service version is effective yet.` (`required_versions: null`). - A card payment that has already gone through is still credited, even if your acceptance has lapsed since. Messages: - Signup not yet confirmed: `A human has not confirmed the Terms of Service and Acceptable Use Policy for this organization.` - No acceptance of the current versions: `Accept the current Terms of Service and Acceptable Use Policy before creating machines, API keys, or adding credits.` - On a production server before any Terms version is in effect (see below): `No Terms of Service or Acceptable Use Policy version is in effect.` with `required_versions` set to `null`. Over REST, the error carries the versions to accept and an info page: ```json { "error": { "code": "terms_not_accepted", "message": "Accept the current Terms of Service and Acceptable Use Policy before creating machines, API keys, or adding credits.", "required_versions": {"tos_version": "tos-0.2", "aup_version": "aup-0.2"}, "accept_url": "https://api.capvm.com/terms/accept" } } ``` Over MCP, the `create_machine` tool error text is `terms_not_accepted: `, with `structuredContent` holding the same `{"error":{"code","message",…}}` object as REST, `required_versions` and `accept_url` inside `error`. See [MCP → Errors](mcp.md#errors). What's **not** blocked: machines that are already running keep running, and you can still get, exec on, and stop them. Retrying a create or top-up with an `Idempotency-Key` that already succeeded returns the original result. ### Before the Terms take effect The founding versions (`tos-0.2`, `aup-0.2`) take effect on a date still **to be confirmed**. Until then, CapVM does this: - **On a production server:** creating machines, issuing keys and adding credits return `403 terms_not_accepted` for every organization (`No Terms of Service or Acceptable Use Policy version is in effect.`, or the "has not confirmed" message for a pending signup), with `required_versions: null`. - **On any server:** `POST /v1/signup` with a complete `terms_acceptance` returns `400 terms_acceptance_required` `No Terms of Service version is effective yet.` (`required_versions: null`), and CapVM can't send acceptance links either. So nobody can sign up or accept before the effective date. - **On a non-production server**, the gate lets machines, keys and credits through while no version is in effect (except for a pending signup). - Health, the legal documents and machines that already exist keep working. Responses carry the notice header (below) for the upcoming versions. ### How to resolve it - **Your agent can't fix this.** Tell the human who runs your account. - If signup is pending: that person opens the emailed link (within 72 hours) and ticks the box. If the link expired or got lost, repeat `POST /v1/signup` with the same `accepted_by_email` for a new one. - If your organization was set up by CapVM rather than through signup, or a new version needs accepting: ask CapVM (hello@capvm.com) to send an acceptance link. Agents can't request it. The page works the same way. For a first acceptance it shows the same checkbox as signup (`signup-checkbox-0.2`). Only if your organization already accepted an earlier version does it read "I accept the updated Terms of Service (version …) and Acceptable Use Policy (version …) on behalf of {company}." (`reaccept-checkbox-0.2`). If your acceptance is already current, CapVM can't send a new one and no email is sent. A new link from CapVM makes any older unused link for your organization stop working (`410 link_superseded`, an HTML page unless `Accept` prefers JSON: `A newer confirmation link was sent; please use the latest email.`). If the email fails, the new link is voided too (it then returns `410 link_expired`) so there's no working link until CapVM sends one successfully. The country and VAT ID CapVM gives when sending the link are saved on your organization, even if the email then fails. - `accept_url` is an information page, not an acceptance form. It explains that a human authorised to bind the business must accept and that the emailed link is the way to do it. - After a new material version of the Terms or AUP takes effect, you must accept it again before new machines, keys or credits (Terms §15.3). Notices to CapVM go to hello@capvm.com (Terms §17.8). ## Notice of changes During the notice period of a material change (published, not yet effective), API responses carry a header such as: ``` X-CapVM-Terms-Update: tos=tos-0.2;effective_at=, aup=aup-0.2;effective_at= ``` Each material Terms or AUP version that is published but not yet in effect is listed, with `effective_at` in UTC. The founding versions above are announced this way until their effective date (to be confirmed). Pass it on to the human who runs your account. Once it takes effect, the new version is required (see above). ## Legal documents CapVM serves the published text at `/terms`, `/aup`, `/dpa`, `/billing` and `/privacy` on the API host: the version in effect, or before that the latest published one. They are the Terms of Service, Acceptable Use Policy, Data Processing Agreement, Billing and Refund Policy, and Privacy Policy. --- # API reference (v1) The CapVM REST API: every route, field and error code for machines, exec, usage, balance, signup and (Coming soon) card top-ups. An OpenAPI 3.1 document is at https://capvm.com/openapi.json. - **Base URL:** `https://api.capvm.com/v1` - **Auth:** `Authorization: Bearer ak_test_…` or `ak_live_…`. Every `/v1` route needs it except `POST /v1/signup`. - **JSON:** request and response fields and enum values are `snake_case`. - **Money:** integer micro-USD (`1 USD = 1_000_000`). Never send floats. - **Scope:** machines, exec and usage only see the calling key's own machines. Balance is shared across the organization. - *Coming soon:* `/v1/account` and `/v1/org/*` also accept a dashboard session; `/mcp` also accepts OAuth tokens. See [Organization](#organization-coming-soon) and [OAuth](#oauth-coming-soon). - **Rate limit:** 120 requests per 60 seconds per key. Over the limit you get `429 rate_limited` with a `Retry-After` header: the seconds until the oldest counted request leaves the window. ## Machines ### `POST /v1/machines`: create | Header | Required | Notes | |---|---|---| | `Idempotency-Key` | yes | 1 to 255 visible characters after trimming (no control characters), sent once, scoped to the key. Same key + same body → the same machine. Different `sku`/`ttl_seconds` → `409 idempotency_conflict`. | | Body field | Type | Required | Notes | |---|---|---|---| | `sku` | string | yes | `arm-small` or `gpu-l4`, and it must be in the key's allow-list | | `ttl_seconds` | integer | yes | 60 to 7200 | What happens, all in one transaction: the request is validated, the hold (`ceil(price_per_hour_micro × ttl_seconds / 3600)`) is checked against the org's available credits and then against the key's spend cap (charged + held + this hold), then the key's concurrency limit and the new-account limits are checked. Only after that does the machine launch. Response: `201` with a [Machine](#machine-object). Errors: `400` sku_required, unknown_sku, ttl_seconds_required, ttl_out_of_range, idempotency_key_required, idempotency_key_invalid (see below), invalid_json · `402` insufficient_credits, spend_cap_exceeded · `403` sku_not_allowed, account_limit_reached, terms_not_accepted (see [Signup](signup.md#403-terms_not_accepted)), account_suspended (`New machines are suspended while a payment dispute is open.`, see [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes)) · `409` idempotency_conflict, concurrency_limit_exceeded · `502` provider_error · `503` capacity_unavailable, launches_disabled. If a launch fails with `502` or `503`, the hold is released. `account_suspended` is checked right after an idempotent replay is returned and before the Terms gate, the TTL range, the SKU and credits, so a replay of a machine you already created still returns it during a dispute. Your balance can be negative after a refund or dispute; any new hold is then more than what's available, so create returns `402 insufficient_credits` (`Need {hold} micro-USD for this lease but only {balance} micro-USD is available.`, with the negative number). Idempotency-Key errors (exact text): | Case | Error | |---|---| | Header missing or sent more than once | `400 idempotency_key_required` `Idempotency-Key header is required.` | | Empty or whitespace-only value (HTTP strips surrounding spaces, so a whitespace-only header arrives empty) | `400 idempotency_key_required` `Idempotency-Key header is required.` | | Over 255 characters after trimming, or a control character | `400 idempotency_key_invalid` `Idempotency-Key must be 1 to 255 visible characters.` | A rejected key takes no hold and launches nothing. Checkout follows the same codes over REST today, but its messages name `idempotency_key`, not the header; see [Card top-ups](#post-v1checkoutsessions-start-a-card-top-up). > **Coming soon:** one shared key check for machine create and checkout over REST and MCP (keys trimmed and stored trimmed, emoji allowed, only control characters rejected), with slightly different error messages. ### `GET /v1/machines`: list `200 {"machines":[Machine…]}`, the key's 100 most recent machines, newest first. ### `GET /v1/machines/{id}`: get `200` Machine, or `404 not_found` if the ID doesn't exist or belongs to another key. ### `DELETE /v1/machines/{id}`: stop Stops the machine, charges the billed seconds and releases the rest of the hold. `200` returns the Machine with `charge_micro`. Calling it on a machine that's already settled returns that machine unchanged. ### `POST /v1/machines/{id}/exec`: run a command > **Available.** Runs one shell command on a `ready` machine owned by the calling key. | Body field | Type | Required | Notes | |---|---|---|---| | `command` | string | yes | 1 to 8192 characters, no NUL. Only whitespace counts as missing. | | `timeout_seconds` | integer | no | 1 to 300, default 30 | | `working_directory` | string | no | Absolute path, 1 to 256 characters, starting with `/`. Each segment uses only ASCII letters, digits, `.`, `_` and `-`; no `.` or `..` segments, no `//`, no trailing `/` (except `/` itself). Surrounding whitespace is trimmed. Leave it out (or send only whitespace) for the machine's default directory. | `200`: ```json {"stdout":"…","stderr":"","exit_code":0,"truncated":false} ``` - A non-zero `exit_code` is still a `200` result (for example `exit 7` returns `exit_code` 7). - `stdout` and `stderr` are each capped at 256 KiB (262,144 bytes), cut on a UTF-8 character boundary. `truncated` is `true` if either stream was cut. In rare cases CapVM can return only a shorter copy of the output (at most 24,000 characters of `stdout` and 8,000 of `stderr`); `truncated` is then `true` if that copy was cut. - **Before sending**, CapVM checks that the machine's command agent is online. If it doesn't, the call returns `409 machine_not_ready` (`Machine is running but is not accepting commands yet.`) without storing or sending anything. - **Pickup window:** if the machine hasn't started the command **30 seconds** after it was sent, CapVM cancels it. - **Cancelled commands:** if the command was cancelled before it started you get the same `409 machine_not_ready`; it never ran, so it's safe to retry. If it had started, you get `408 command_timeout`. - **Timeout:** `timeout_seconds` is how long the command may run on the machine. CapVM waits at most `timeout_seconds` + 75 seconds; if there's still no result, it cancels the command and returns `408 command_timeout`. A `408` means the command hit a timeout and may or may not have started: **it may have run partly or fully, so don't blindly retry.** - **No exit code:** if the command finished (success or failure) but without an exit code, you get `502 provider_error` `The machine did not report an exit code.` and no output. - `exec` isn't billed per call: it writes nothing to the credit ledger, including on errors. You pay only for the machine's lease time. - Your command runs with `bash` on the machine (after `cd -- ''` if you set one). If the machine can't download the command script, `exit_code` is the download tool's exit code (`curl`, or `wget` if `curl` is missing), not your command's. - **Output isn't kept.** Command output is stored only temporarily in Zurich so it can be returned to you, and deleted once returned (at the latest after 1 day). There's no route to fetch it again, and a later call can't see it. - **Command text isn't kept.** CapVM records each call that reaches the machine with a hash and the length of the command, never the command text, the working directory or the output. - The command agent on a new machine can lag behind `ready` by about a minute. Retry on `409 machine_not_ready`. Errors, in the order they're checked (exact messages): | Status | Code | Message | When | |---|---|---|---| | 400 | `command_required` | `command is required.` | `command` missing, empty or only whitespace | | 400 | `command_too_long` | `command must be 1 to 8192 characters.` | Longer than 8192 characters, **or** contains a NUL | | 400 | `timeout_out_of_range` | `timeout_seconds must be between 1 and 300.` | | | 400 | `working_directory_invalid` | `working_directory must be an absolute path of letters, digits, dots, underscores, and hyphens.` | Fails any rule above | | 404 | `not_found` | `Machine was not found.` | Unknown ID or another key's machine | | 409 | `machine_not_running` | `Machine is not running. The lease has expired.` | Past `expires_at` | | 409 | `machine_not_running` | `Machine is not running.` | `stopping`, `terminated` or already settled, or the instance stopped running during the call | | 409 | `machine_not_ready` | `Machine is not ready yet.` | Not `ready` yet | | 409 | `machine_not_ready` | `Machine is running but is not accepting commands yet.` | The machine's command agent isn't online yet, or the command was cancelled before it started; it didn't run, so retry | | 408 | `command_timeout` | `Command timed out.` | The command ran past `timeout_seconds`, gave no result within `timeout_seconds` + 75 s, or was cancelled after it started; it may have had effects, so don't blindly retry | | 502 | `provider_error` | `The machine did not report an exit code.` | The command finished (success or failure) with no exit code; no output is returned | | 502 | `provider_error` | `The compute provider failed to run the command.` | Any other failure of the compute provider | | 500 | `internal_error` | `The command finished but the audit record could not be stored.` | The command ran, but CapVM couldn't record the call; the output isn't returned | ### Machine object | Field | Type | Notes | |---|---|---| | `id` | string | `m_` + 32 hex characters | | `sku` | string | | | `state` | enum | `requested`, `provisioning`, `ready`, `stopping`, `terminated` | | `instance_id` | string\|null | provider instance ID | | `public_ip` | string\|null | | | `region` | string | `eu-central-2` | | `ttl_seconds` | int | | | `price_per_hour_micro` | int64 | price locked when the machine was created | | `hold_micro` | int64 | amount reserved at create | | `charge_micro` | int64\|null | set once the machine is settled | | `created_at`, `expires_at` | date-time | `expires_at = created_at + ttl_seconds` | | `ready_at`, `stop_requested_at`, `terminated_at` | date-time\|null | | ## Account ### `GET /v1/usage` The calling key's numbers: `{"spend_micro","held_micro","spend_cap_micro","events":[{"id","machine_id","sku","seconds","amount_micro","created_at"}]}`. `events` holds the 100 most recent. ### `GET /v1/balance` The organization's numbers: `{"available_micro","held_micro","currency":"USD","unit":"micro_usd"}`. `available_micro` already excludes holds. It can be negative after a Stripe refund or dispute. ## Top-ups > **Coming soon.** Card top-ups aren't available yet; for now, CapVM adds credits to your account. The routes below describe how they will work. Also Coming soon as the MCP tool [`create_checkout_session`](mcp.md#create_checkout_session). > > **The `amount_usd` wire format may change**, possibly to integer cents (`1000` = $10). Don't hard-code it yet. ### `POST /v1/checkout/sessions`: start a card top-up (Coming soon) Creates a Stripe Checkout Session for prepaid credits and returns its URL. **A human pays on that page.** The agent only creates the session and passes the link on. Credits arrive when Stripe reports the payment. | Header | Required | Notes | |---|---|---| | `Authorization` | yes | `Bearer ak_…`, as for every `/v1` route | | `Idempotency-Key` | **yes** | 1 to 255 characters after trimming, no control characters, sent once. Scoped to the **API key**, like machine create: two keys of the same organization sending the same value get two separate sessions. | | Body field | Type | Required | Notes | |---|---|---|---| | `amount_usd` | string or integer | yes | USD. A JSON integer is whole dollars (`10`). A string can have cents, with at most two decimals (`"10"`, `"10.5"`, `"10.50"`). A JSON number with a decimal point (`10.5`, also `10.0`) is rejected, and so are signs, exponents and more than two decimals. **Minimum $10, maximum $1000.** | | `success_url` | string | no | Absolute `http`/`https` URL, 8 to 2048 characters, no spaces or `user:pass@`. Where Stripe sends the payer afterwards. If left out, CapVM's configured URL is used, by default `https://capvm.com/checkout/success` (no query string added). | | `cancel_url` | string | no | Same rules. Default `https://capvm.com/checkout/cancel` (also not built yet). | A value that's only whitespace counts as left out. The maximum top-up is $1000. ```bash curl -X POST https://api.capvm.com/v1/checkout/sessions \ -H "Authorization: Bearer ak_test_..." \ -H "Idempotency-Key: topup-2026-10-25" \ -H "Content-Type: application/json" \ -d '{"amount_usd":"25.00"}' ``` `201`: ```json {"id":"cs_test_…","url":"https://checkout.stripe.com/…"} ``` The Checkout page Stripe shows: - One line item, "CapVM credits", for the amount, in **USD**, payment mode (a one-off payment). - Prices **exclude VAT**. By default Stripe Tax adds VAT where it applies (`automatic_tax`), so the payer can be charged more than `amount_usd`. - A **Company name** field the payer must fill in, an optional VAT ID field, and a **billing address** the payer must enter. - Above the pay button, CapVM's checkout notice (`checkout-notice-0.2`): "No refunds during the beta: credits are non-refundable and never expire. You are buying USD {amount, e.g. 25.00} in CapVM credits (plus VAT where applicable) for {organization name}. Usage by you and your agents is deducted per second. By paying, you agree to the Terms of Service and the Billing and Refund Policy." **What gets credited:** the price **before tax**, converted to micro-USD (`$25.00` → `25000000`). VAT is never credited. Only USD sessions are credited. A paid top-up also lifts the new-account limits for your organization (it marks it trusted). **Retrying:** the same `Idempotency-Key` from the same API key, with the same amount and URLs, returns the same session (Stripe's own idempotency, keyed on your API key and the key). The same key with a different amount or URL gets `409 idempotency_conflict`. CapVM records one "checkout notice shown" entry per session, written only after Stripe has returned the session; a retry that gets the same session back doesn't add another. **Invoices:** CapVM turns on Stripe's invoice creation for every Checkout Session (`invoice_creation`), so Stripe creates an invoice for each paid top-up, with the description "CapVM prepaid compute credits". Checked in this order (exact messages): | Status | Code | Message | When | |---|---|---|---| | 400 | `validation_error` | `amount_usd is required.` | No body, or `amount_usd` missing, `null`, empty or not a string/number | | 400 | `validation_error` | `amount_usd must be an integer number of cents. Send a whole number of dollars, or a string with at most two decimal places.` | Bad format (above) | | 400 | `validation_error` | `amount_usd must be positive.` | A negative JSON integer | | 400 | `validation_error` | `amount_usd is too large.` | A JSON integer so large that it overflows when converted to cents | | 400 | `idempotency_key_required` | `idempotency_key is required.` | Header missing, sent more than once, empty or only whitespace (the message names the MCP param, not the header). Machine create treats whitespace-only as `idempotency_key_invalid`; Coming soon: the same for a whitespace-only MCP key (a whitespace-only REST header reaches the server empty and stays `idempotency_key_required`), names the header in REST messages, and makes a header sent twice `idempotency_key_invalid` (see [create](#post-v1machines-create)) | | 400 | `idempotency_key_invalid` | `idempotency_key must be 1 to 255 visible characters.` | Over 255 characters after trimming, or containing a control character | | 400 | `min_topup_not_met` | `Minimum top-up is 10000000 micro-USD ($10).` | Under $10 (for example `"9.99"` or `9`) | | 400 | `max_topup_exceeded` | `Maximum top-up is 1000000000 micro-USD ($1000.00).` (with the server's maximum) | Over the maximum (for example `"1000.01"`) | | 400 | `validation_error` | `success_url must be an absolute http(s) URL.` (or `cancel_url …`) | Bad URL | | 403 | `terms_not_accepted` | as in [Signup](signup.md#403-terms_not_accepted), with `required_versions` and `accept_url` | No current Terms acceptance. Checked before Stripe is called: no session is created and nothing is recorded. | | 400 | `terms_acceptance_required` | `No Terms of Service version is effective yet.` (`required_versions: null`) | A non-production server before any Terms version is in effect | | 503 | `stripe_not_configured` | | Card payments are unavailable | | 409 | `idempotency_conflict` | `This Idempotency-Key was already used with a different checkout request.` | See Retrying | | 502 | `stripe_error` | `Stripe could not create the Checkout Session.` or `Stripe did not return a Checkout Session URL.` | Stripe failed | None of these errors records a checkout notice: it's written only once Stripe returns a session. An open dispute does **not** block starting a top-up (`account_suspended` is only on machine create). There is **no refunds route**: credits are non-refundable (Terms §7). Refunds and disputes change your balance: see below. ### When credits arrive, refunds and disputes - Credits arrive once Stripe confirms the payment, once per Checkout Session. A payment method that settles later is credited when it settles. - A refund is taken back only once it **succeeds**: the pre-tax share of what the payment credited (refund amount × credited amount ÷ the gross charge including VAT). If a refund that was taken back later fails or is canceled, it's credited back once. The balance can go negative. - A card issuer's inquiry changes nothing. - A dispute (chargeback) takes back the pre-tax share of the disputed amount and suspends new machines (`403 account_suspended` on `POST /v1/machines`). A won dispute gives the credits back; a lost one keeps them taken. New machines are allowed again once no dispute is open. - When a dispute opens, or a refund leaves the balance negative, CapVM stops and destroys every running machine of the organization within seconds (billed up to the stop, rest of each hold released) and emails the account once (subject `CapVM stopped your machines`). Stopped machines aren't restarted after a won dispute. Details: [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes). ## Signup (public) ### `POST /v1/signup` > Available. Starts a signup for a business; a human must confirm by email before anything works. No API key needed. Limited to 5 requests per hour per client IP and 5 per hour per `accepted_by_email`; over that, `429 rate_limited` `Signup rate limit exceeded.` with `Retry-After` (seconds left in the window). Repeating it for the same email while that organization is still pending sends a new link, voids the old one, and replaces the company name, country and VAT ID with the newest values. If the email can't be sent: `503 email_send_failed` with `Retry-After: 30`; retry the call. Full contract: [Signup and Terms acceptance](signup.md). ## Account details (Coming soon) > **Coming soon.** ### `GET /v1/account` Works with an `ak_` key or with a signed-in [dashboard](dashboard.md) session cookie (no bearer). Returns `200 {"org_id","company_name","status","balance_micro","frozen"}`. Without either: `401 unauthorized` `Authorization is required.` With an `ak_` key of a frozen organization it returns `403 org_frozen`, like other key routes (see [Frozen organizations](dashboard.md#frozen-organizations)). ## Organization (Coming soon) > **Coming soon.** For people signed in to the [dashboard](dashboard.md), not agents. - **Auth:** the dashboard session cookie (`__Host-capvm_session`). `ak_` keys and OAuth tokens aren't accepted. No session: `401 unauthorized` `Authorization is required.` - **Writes** (`POST`, `PATCH`, `DELETE`) also need the antiforgery token from a dashboard page in a `RequestVerificationToken` header; without it: `400 validation_error` `Antiforgery token is required.` - **Scope:** the whole organization, not one key. ### `GET /v1/org/keys` `200 {"keys":[…]}`, newest first, revoked keys included. Each key: `id`, `label` (or `null`), `prefix`, `created_at`, `created_ip` (or `null`), `last_used_at` (its latest machine create or usage record, or `null`), `revoked_at` (or `null`), `spend_cap_micro`. ### `POST /v1/org/keys` Body `{"spend_cap_micro": 5000000, "label": "Codex laptop"}`. `label` is optional. Returns `201 {"id","secret","label","prefix","spend_cap_micro","created_at"}`. **`secret` is the full `ak_live_…` key and is shown only here.** The key may use every SKU and run 10 machines at once. Sends the `CapVM API key created` alert email. | Status | Code | Message / when | |---|---|---| | 403 | `reauth_required` | `Sign in again to continue.` No sign-in or confirmation in the last 5 minutes | | 400 | `validation_error` | `spend_cap_micro is required.` / `spend_cap_micro must be positive.` / `label must be 1 to 80 characters.` (after trimming; control characters count as invalid; an empty label is stored as `null`) | | 403 | `org_frozen` | `This organization is frozen.` | | 403 | `terms_not_accepted` | No current Terms acceptance | ### `PATCH /v1/org/keys/{id}` Body with `label`, `spend_cap_micro` or both. Returns `200` with the key (same fields as in the list). | Status | Code | Message / when | |---|---|---| | 400 | `validation_error` | `label or spend_cap_micro is required.` / `spend_cap_micro must be positive.` / `label must be 1 to 80 characters.` | | 404 | `not_found` | `API key was not found.` | | 400 | `key_revoked` | `API key has been revoked.` | | 403 | `org_frozen` | Renaming or raising the cap while frozen (lowering still works) | | 403 | `reauth_required` | `Sign in again to continue.` Raising the cap without a sign-in in the last 5 minutes | ### `DELETE /v1/org/keys/{id}` Revokes the key. Returns `200 {"id","revoked_at"}`; revoking an already revoked key returns its original `revoked_at`. Works while frozen. `404 not_found` `API key was not found.` ### `GET /v1/org/machines` `200 {"machines":[…]}`: every machine in the organization, same fields as [`GET /v1/machines`](#machines). ### `DELETE /v1/org/machines/{id}` Stops any machine in the organization. Returns `200` with the machine. Works while frozen. `404 not_found` `Machine was not found.` ### `GET /v1/org/usage` The organization's usage, same response shape as [`GET /v1/usage`](#account). ### Sign-in routes (browser pages) `/signin`, `/signin/confirm/{token}`, `POST /signin/code`, `/signin/reauth`, `POST /signin/reauth/code`, `/signin/lockdown/{token}`, `POST /signout`, `POST /signout/all`, `/dashboard`. They're pages for people, not an API; their behavior and errors are in [Dashboard](dashboard.md). Sign-in requests: `429 rate_limited` `Sign-in rate limit exceeded.` (5 per hour per IP and per email), `400 invalid_email` `email must be a valid address.` ## OAuth (Coming soon) > **Coming soon.** How to connect a client: [MCP → Connect with OAuth](mcp.md#connect-with-oauth-coming-soon). OAuth access tokens work **only on `/mcp`**. On `/v1` routes they get `401 invalid_api_key`. OAuth endpoint errors use the OAuth shape `{"error":"…","error_description":"…"}`, not CapVM's `{"error":{"code","message"}}`, except where noted. ### Discovery - `GET /.well-known/oauth-protected-resource` and `GET /.well-known/oauth-protected-resource/mcp` (RFC 9728): `{"resource":"https://api.capvm.com/mcp","authorization_servers":["https://api.capvm.com"],"scopes_supported":["mcp","offline_access"]}`. - `GET /.well-known/oauth-authorization-server` (RFC 8414): issuer `https://api.capvm.com`, `authorization_endpoint` `https://api.capvm.com/oauth/authorize`, `token_endpoint` `https://api.capvm.com/oauth/token`, `revocation_endpoint` `https://api.capvm.com/oauth/revoke`, `registration_endpoint` `https://api.capvm.com/oauth/register` (absolute URLs on the issuer), `code_challenge_methods_supported` `["S256"]`, `token_endpoint_auth_methods_supported` `["none"]`, `grant_types_supported` `["authorization_code","refresh_token"]`, `scopes_supported` `["mcp","offline_access"]`. ### `POST /oauth/register` Dynamic client registration (RFC 7591), public clients only. Body: | Field | Required | | |---|---|---| | `redirect_uris` | yes | Non-empty array of strings. Each must be `https`, or `http` on `127.0.0.1` or `localhost`; no fragment, no user info. For `127.0.0.1`/`localhost` the port can differ at authorize time; other hosts must match exactly (scheme, host, path, query, port) | | `client_name` | no | Trimmed, at most 120 characters. Missing, blank or not a string: `Unverified app` | | `grant_types` | no | `authorization_code`, `refresh_token` or both. Default both | | `response_types` | no | `code`. Default `["code"]` | | `token_endpoint_auth_method` | no | Must be `none` | | `client_secret` | must be absent | | Returns `201 {"client_id","client_name","redirect_uris","token_endpoint_auth_method":"none","grant_types","response_types"}`. Rate limit: 10 registrations per hour per IP, `429 rate_limited` `Registration rate limit exceeded.` (CapVM error shape) with `Retry-After`. Errors are `400 {"error":"invalid_client_metadata","error_description":…}` with: | `error_description` | |---| | `Request body must be valid JSON.` / `Request body must be a JSON object.` | | `Public clients must not send client_secret.` / `token_endpoint_auth_method must be none.` | | `redirect_uris is required.` / `redirect_uris must be a non-empty array of strings.` / `redirect_uris must be https, or http on 127.0.0.1 or localhost.` | | `grant_types must be a non-empty array of strings.` / `grant_types must be authorization_code, refresh_token, or both.` | | `response_types must be a non-empty array of strings.` / `response_types must be code.` | | `client_name must be at most 120 characters.` | ### `GET /oauth/authorize` Authorization code flow with PKCE (`code_challenge_method=S256` required; `plain` isn't offered). Required: `resource=https://api.capvm.com/mcp` and a scope that includes `mcp` (only `mcp` and `offline_access` are allowed). The browser signs in and confirms within 5 minutes if needed, then sees the approval page, which posts back to the same URL with `decision=approve` and `spend_cap_usd` (whole dollars, 1 to 1000). The code lasts 60 seconds. | Result | When | |---|---| | `400 {"error":"invalid_target","error_description":"resource must be https://api.capvm.com/mcp."}` | `resource` missing or different (several identical values count as one) | | `invalid_client` `The client is unknown.` / `invalid_request` `redirect_uri does not match a registered URI.` / `redirect_uri is not an absolute URI.` | Bad client or redirect | | Redirect with `error=invalid_scope` (`scope must include mcp.`) | Other scopes, or no `mcp` | | Redirect with `error=access_denied`, `error_description=org_pending` | Organization still `pending_acceptance` | | Redirect with `error=access_denied` (`The resource owner denied the request.`) | **Deny** clicked | | Redirect with `error=access_denied`, `error_description=org_frozen` | Organization frozen | | `400 validation_error` `spend_cap_usd must be a whole number of dollars from 1 to 1000.` / `Antiforgery token is missing or invalid.` (CapVM shape) | Bad approve form | ### `POST /oauth/token` `grant_type=authorization_code` (with `code`, `redirect_uri`, `code_verifier`, `client_id`) or `grant_type=refresh_token` (with `refresh_token`, `client_id`). Both need `resource=https://api.capvm.com/mcp` (otherwise `400 invalid_target` as above). Returns an opaque `access_token`, `"token_type":"Bearer"`, `"expires_in":900`, and a new `refresh_token` if `offline_access` was granted. | `error` / `error_description` (400) | When | |---|---| | `invalid_grant` `The refresh token was reused.` | A refresh token sent again more than 60 seconds after its first use: the whole grant is revoked and an alert is emailed. Within 60 seconds the first response is returned again | | `invalid_grant` `The grant has expired.` | 30 days after approval | | `invalid_grant` `The refresh token is no longer valid.` | Grant revoked or unknown | Other errors follow the OAuth 2.0 standard. ### `POST /oauth/revoke` Token revocation (RFC 7009), form-encoded: `token` (an access or refresh token), `client_id`, optional `token_type_hint`. Returns `200`. Revoking either token revokes the whole connection (grant) and all its tokens, the same as [`DELETE /v1/org/oauth/grants/{id}`](#oauth-grants-coming-soon): the grant leaves `GET /v1/org/oauth/grants`, the next `/mcp` call gets `401`, and a refresh gets `invalid_grant`. It writes the security event `oauth_revoked` and sends no email. ### `/mcp` with an OAuth token `401` with `WWW-Authenticate: Bearer resource_metadata="https://api.capvm.com/.well-known/oauth-protected-resource/mcp"` when there's no bearer; an expired or revoked token adds `, error="invalid_token"` and the body `{"error":{"code":"unauthorized","message":"Access token is expired or revoked."}}`. Rate limit: 120 per 60 s per grant. While the organization is frozen (same as for `ak_` keys): `initialize`, `ping` and `tools/list` work; `get_balance`, `get_usage` and `stop_machine` work; the other tools return the tool error `org_frozen`. ## OAuth grants (Coming soon) > **Coming soon.** Same auth as [Organization](#organization-coming-soon): session cookie; antiforgery header on writes (message here: `Antiforgery token is missing or invalid.`). No session: `401 unauthorized` `Authorization is required.` ### `GET /v1/org/oauth/grants` `200 {"grants":[{"id","client_name","verified","redirect_host","spend_cap_micro","spent_micro","created_at","last_used_at"}]}`. `verified` is always `false`. ### `PATCH /v1/org/oauth/grants/{id}` Body `{"spend_cap_micro": 10000000}`. Returns `200 {"id","spend_cap_micro"}`. | Status | Code | Message / when | |---|---|---| | 400 | `validation_error` | `spend_cap_micro is required.` / `spend_cap_micro must be between 1000000 and 1000000000.` | | 404 | `not_found` | `Grant was not found.` (unknown or revoked) | | 403 | `org_frozen` | Raising the cap while frozen | | 403 | `reauth_required` | `Sign in again to raise this spend cap.` Raising without a sign-in in the last 5 minutes | Lowering works while frozen and without a fresh sign-in. Changing the cap doesn't change `last_used_at`. ### `DELETE /v1/org/oauth/grants/{id}` Revokes the grant and all its tokens. Returns `200 {"id","revoked_at"}`. No email is sent. `404 not_found` `Grant was not found.` ## Errors Every error has the same shape: `{"error":{"code":"…","message":"…"}}`. Two errors add fields: `terms_not_accepted` adds `required_versions` and `accept_url`, and `terms_acceptance_required` adds `required_versions`. See [Signup](signup.md). | Status | Codes | |---|---| | 400 | `sku_required` `unknown_sku` `ttl_seconds_required` `ttl_out_of_range` `idempotency_key_required` `idempotency_key_invalid` `command_required` `command_too_long` `timeout_out_of_range` `working_directory_invalid` `terms_acceptance_required` `link_used` (only from the human confirmation page and form `/signup/confirm/{token}`) `min_topup_not_met` `max_topup_exceeded` `invalid_json` `validation_error` `invalid_email` `invalid_source` | | 401 | `unauthorized` (missing bearer) `invalid_api_key` `key_revoked` | | Coming soon | `400 code_invalid` (with `tries_left`) · `410 code_burned` · `403 org_frozen` · `403 reauth_required` · `400 key_revoked` (`PATCH /v1/org/keys/{id}`) · `400`/`410` `link_used`/`link_expired` on sign-in and lockdown pages. See [Dashboard](dashboard.md) | | Coming soon | OAuth shape `{"error","error_description"}`: `invalid_client_metadata`, `invalid_target`, `invalid_grant`, `invalid_scope`, `access_denied`. See [OAuth](#oauth-coming-soon) | | 402 | `insufficient_credits` `spend_cap_exceeded` | | 403 | `sku_not_allowed` `account_limit_reached` `terms_not_accepted` `account_suspended` (machine create during an open payment dispute) | | 404 | `not_found` | | 408 | `command_timeout` | | 409 | `idempotency_conflict` `concurrency_limit_exceeded` `machine_not_ready` `machine_not_running` `details_changed` (only from the human acceptance form `POST /signup/confirm/{token}`; the acceptance page again unless `Accept` prefers JSON, see [Signup](signup.md#submitting-the-form)) | | 410 | `link_superseded` `link_expired` (only from the human confirmation page and form `/signup/confirm/{token}`. These, `400 link_used`, `404 not_found` for an unknown link, and the form-token `400 validation_error` errors are an HTML status page unless the `Accept` header prefers `application/json` over `text/html`: no `Accept`, `*/*` alone, or a tie gets HTML. See [Signup → HTML or JSON](signup.md#html-or-json)) | | 429 | `rate_limited` (also on `POST /v1/signup`) | | 500 | `internal_error` (on exec: the command finished but CapVM couldn't record the call) | | 502 | `provider_error` `stripe_error` | | 503 | `capacity_unavailable` `launches_disabled` `email_send_failed` (with `Retry-After: 30`) `stripe_not_configured` | ## Not in the API for agents CapVM creates organizations, issues and revokes keys, adds credits by hand and lifts new-account limits. Agents can't add credits or set a balance. (An agent can start a card top-up with [`POST /v1/checkout/sessions`](#post-v1checkoutsessions-start-a-card-top-up), but a human pays.) Issuing a key and adding credits need a current Terms acceptance, and issued keys record the Terms and AUP versions in force. If your account needs an acceptance link, ask CapVM (see [Signup](signup.md#how-to-resolve-it)). --- # Billing and caps How CapVM bills machines (per second, 60-second minimum, prepaid credits), how per-key spend caps work, and how card top-ups will work (Coming soon; for now, CapVM adds credits to your account). ## Prices | SKU | Price/hour | micro-USD/hour | |---|---|---| | `arm-small` | $0.20 | 200000 | | `gpu-l4` | $2.00 | 2000000 | Prices are in USD, excluding VAT where applicable. Prices may change. Each machine keeps the price it was created at (`price_per_hour_micro`). ## How a lease is billed 1. **Create → hold.** CapVM reserves `ceil(price_per_hour_micro × ttl_seconds / 3600)` from the organization's available credits. If that's more than the available credits, you get `402 insufficient_credits` and nothing launches. 2. **Stop → charge + release.** When you `DELETE` the machine, or it reaches its TTL or the egress cap, CapVM charges `ceil(price_per_hour_micro × billed_seconds / 3600)` and returns the rest of the hold to the balance. 3. **Billed seconds** are the wall-clock time from the create request until the stop, **at least 60** and **at most `ttl_seconds`**. The clock starts at create, not at `ready`, so boot time is billed. 4. If the machine never launched (a provider error, or no capacity), the full hold is released. Examples: a 10-second job on `arm-small` is billed as 60 s = 3,334 micro-USD. 30 minutes on `gpu-l4` = 1,000,000 micro-USD ($1.00). Machine holds never make the balance negative. Because the full TTL is paid for up front, a running machine never needs more credit than it already holds. A Stripe refund or dispute can take the balance below zero (see [Refunds and disputes](#refunds-and-disputes)). While it's negative, every new machine gets `402 insufficient_credits`; machines already running aren't affected, and their unused hold goes back to the balance when they stop. ## Spend caps (per API key) Each key has: | Setting | What it does | Error | |---|---|---| | Spend cap | At create time, CapVM rejects the machine if the key's charged total + its open holds + the new hold would go over the cap | `402 spend_cap_exceeded` | | Max concurrent machines | Counts the key's machines that aren't `terminated` | `409 concurrency_limit_exceeded` | | Allowed SKUs | The SKUs this key can launch | `403 sku_not_allowed` | Check where a key stands with `GET /v1/usage` (`spend_micro`, `held_micro`, `spend_cap_micro`). ## Credits - Prepaid. **The minimum top-up is USD 10.** - **Credits never expire.** - **Credits are non-refundable**, whether used or unused, including if you stop using CapVM or close your account. (Terms of Service §7.1; the exceptions are in Terms §7.2.) - For now, CapVM adds credits to your account. Buying them by card yourself (below) is Coming soon. - Invoices for every top-up: CapVM has Stripe create an invoice for every card top-up (`invoice_creation` on the Checkout Session), described as "CapVM prepaid compute credits". Credits CapVM adds by hand don't go through Stripe. Every credit movement is written to an append-only ledger (top-up, hold, release, charge, refund, refund reversed, dispute, dispute won and dispute closed). ## Topping up by card > **Coming soon.** For now, CapVM adds credits to your account; this section describes how card top-ups will work. **The amount format may change**, possibly to integer cents. Today the API takes `amount_usd` in dollars. Check this page again before you build on it. 1. **Your agent starts a top-up** with `POST /v1/checkout/sessions` (or the MCP tool [`create_checkout_session`](mcp.md#create_checkout_session)), giving an amount and an `Idempotency-Key`: ```bash curl -X POST https://api.capvm.com/v1/checkout/sessions \ -H "Authorization: Bearer $CAPVM_KEY" \ -H "Idempotency-Key: topup-1" \ -H "Content-Type: application/json" \ -d '{"amount_usd":"50.00"}' ``` It gets back `201 {"id":"cs_…","url":"https://checkout.stripe.com/…"}`. 2. **A human opens the `url` and pays** on Stripe's Checkout page. The agent can't pay. The page asks for a company name (required), a billing address (required) and a VAT ID (optional). It also shows the no-refunds notice: "No refunds during the beta: credits are non-refundable and never expire. You are buying USD 50.00 in CapVM credits (plus VAT where applicable) for {your organization}. …" 3. **Credits arrive when Stripe confirms the payment** . Check `GET /v1/balance`. For a payment method that settles later, credits arrive when it settles. Rules: - **Amount:** from **$10** to **$1000** per top-up (`400 min_topup_not_met` / `400 max_topup_exceeded`). It's in USD, as a whole-dollar JSON integer (`50`) or a string with up to two decimals (`"50.00"`). `50.5` as a JSON number is rejected. - **VAT is added on top.** By default Stripe Tax adds it where it applies, so the card can be charged more than the amount. - **What you're credited:** the amount before VAT, in USD. VAT isn't credited. Stripe's fees aren't taken off your credits. - **Each Checkout Session is credited once**, however often Stripe reports it. - **You need a current Terms acceptance** to start a top-up (`403 terms_not_accepted`, see [Signup](signup.md#403-terms_not_accepted)). A payment that already went through is credited even if your acceptance lapsed afterwards. - **Retries:** reuse the same `Idempotency-Key` from the same API key with the same amount to get the same session back. The same key with a different amount returns `409 idempotency_conflict`. Keys are per API key, like machine create: another key of your organization using the same value gets its own session. - **Return pages:** after paying or cancelling, Stripe sends the payer to `https://capvm.com/checkout/success` or `https://capvm.com/checkout/cancel` unless the agent passed its own `success_url` / `cancel_url`. - **No refunds route.** Credits are non-refundable (Terms §7.1). The Terms §7.2 exceptions are handled by CapVM, not through the API. Refunds CapVM makes in Stripe, and card disputes, do change your balance: see below. - **An open dispute doesn't block top-ups.** You can still start one; only new machines are suspended. - A completed top-up also lifts the new-account limits for your organization (see [Limits](limits.md)). Full contract and errors: [API reference → Top-ups](api-reference.md#top-ups). ### Refunds and disputes > There is no API to request a refund. - **Refund:** when a card top-up refund **succeeds** in Stripe, CapVM takes the matching **pre-tax** credits back (a pending refund takes nothing yet): refund amount × credits from that payment ÷ the gross charge including VAT. A full refund takes back exactly what was credited; partial refunds are prorated, and together they never take back more than that payment credited. Each Stripe refund is applied once, however often Stripe reports it. If a refund that was taken back later fails or is canceled, the credits are given back once. - **Inquiry:** a card issuer's inquiry (Stripe status `warning_…`) is only logged. Nothing is taken back and nothing is suspended. - **Dispute (chargeback) opened:** CapVM takes back the pre-tax share of the disputed amount (same formula, capped at what's left of that payment's credits) and **suspends new machines** for your organization. `POST /v1/machines` returns `403 account_suspended` `New machines are suspended while a payment dispute is open.` This block applies as soon as CapVM learns of the dispute from Stripe. Running machines are stopped and destroyed a few seconds later (see below). A retry of a create you already made still returns that machine. Top-ups, keys and the other routes keep working. - **Dispute closed:** if you **won**, the credits taken for it come back. If not, they stay taken. Either way the dispute no longer counts as open; new machines are allowed again once no dispute is open (and the balance covers the hold). Stopped machines aren't restarted. - **Negative balance:** a refund or dispute can take your balance below zero. `GET /v1/balance` then shows a negative `available_micro`, and new machines get `402 insufficient_credits` until a top-up brings the balance back above the new hold. A top-up is added to the negative balance, so the debt is taken from it first. - **Running machines are stopped.** When a refund or a dispute leaves your organization with an open dispute or a balance below zero, CapVM stops and destroys **every running machine** of the organization within seconds, with no grace period. Each machine is settled like a normal stop: billed from creation to the stop (per second, 60-second minimum, at most its TTL, at its creation price), and the rest of its hold is released. If the dispute was already won or the balance is no longer negative by then, nothing is stopped. In the [Machine](api-reference.md#machine-object) JSON these machines just show as terminated. A machine still launching at that moment may not be stopped. - **One email per stop event.** If at least one machine was stopped, CapVM emails your organization's account address (the first user created in the organization) from `hello@capvm.com`, the same sender as the Terms acceptance link. Subject: `CapVM stopped your machines`. Plain-text body, for a dispute: ``` CapVM stopped your machines. Reason: dispute_suspended Machines: m_…,m_… Balance: -1234567 micro-USD. These machines are not restarted after a dispute is won. Contact hello@capvm.com. ``` For a negative balance after a refund, the last two lines are different instead (no mention of disputes): ``` CapVM stopped your machines. Reason: negative_balance Machines: m_… Balance: -1234567 micro-USD. Your balance is negative after a refund. The next top-up covers it first. Contact hello@capvm.com. ``` `Machines` lists the stopped machines' ids, comma-separated. `Reason` is `dispute_suspended` or `negative_balance`. `Balance` is the organization's balance in micro-USD right after the stops. The same event never stops machines or emails twice. If the email can't be delivered, the machines stay stopped. With no account email on file, no email is sent. - **No restart.** Machines stopped this way stay stopped, even after you win the dispute. - A refund or dispute on a payment CapVM never credited changes nothing. - **Done by hand for now:** the API doesn't freeze your other credits or charge you the card processor's dispute fee. If CapVM does either under Terms §8.2, it does it manually. --- # Limits CapVM's limits: a 2-hour maximum per machine, 5 GB of outbound data per machine, blocked mail ports, and conservative concurrency for new accounts. The wording in this section is quoted from the Acceptable Use Policy ("Technical limits (beta)"), which is part of the Terms of Service (Terms §9): - Each machine stops at the end of its time limit, at most 2 hours (7200 s) in the beta. - Each machine may send at most 5 GB of outbound data. - Outgoing mail ports 25, 465 and 587 are blocked. - New accounts may run at most 1 GPU and 3 machines at a time. - These limits may change; the limits enforced by the API at the time are the ones that apply. From the Terms of Service §5.2: **All data on a machine is permanently deleted when the machine is destroyed.** You are responsible for copying out anything you need. CapVM provides no backups. ## How these map to the API | Limit | API behaviour | |---|---| | Time limit | `ttl_seconds` is required, from 60 to 7200. Outside that range → `400 ttl_out_of_range`. At `expires_at`, CapVM stops the machine. | | Outbound data | CapVM checks each machine's outbound traffic and stops it at the cap (5 GiB, 5,368,709,120 bytes). | | Mail ports | Outbound TCP 25, 465 and 587 are blocked at the network level. | | New accounts | Over the limit → `403 account_limit_reached`. The limit is lifted once the organization is marked trusted. | | Open payment dispute | No new machines while any card dispute is open → `403 account_suspended` `New machines are suspended while a payment dispute is open.` Running machines are stopped and destroyed within seconds (no grace period; usage up to the stop is billed), and the account gets one email listing them, the reason and the balance. Top-ups, keys and other routes aren't affected. Lifted when every dispute has closed; stopped machines aren't restarted. See [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes). | | Per-key concurrency | Set per key → `409 concurrency_limit_exceeded` | | API rate | 120 requests / 60 s per key → `429 rate_limited` with `Retry-After` (the seconds left before a request frees up) | | `exec` | `command` up to 8192 characters, `timeout_seconds` from 1 to 300 (default 30), `working_directory` up to 256 characters, `stdout` and `stderr` capped at 256 KiB each (`truncated: true`). Past the timeout → `408 command_timeout` (CapVM waits at most `timeout_seconds` + 75 s). Not started by the machine within 30 s → cancelled with `409 machine_not_ready` (it didn't run, safe to retry). No exit code reported → `502 provider_error`. Command output is kept only until it's returned to you (at most 1 day). | | Terms acceptance | No machines, keys or credits until a human accepts the current Terms (Terms §3.1) → `403 terms_not_accepted`. Signup links expire after 72 hours; the form token on the confirmation page after 15 minutes. Before the Terms take effect (effective date to be confirmed), signup is refused and these actions are refused for everyone. See [Signup](signup.md) | | Signup rate | `POST /v1/signup`: 5 requests / hour per IP and 5 / hour per `accepted_by_email` (rolling window; retries count) → `429 rate_limited` with `Retry-After` set to the seconds left | | Listings | `GET /v1/machines` and `GET /v1/usage` return the 100 most recent items | ## Machines | SKU | Machine | Region | Root disk | |---|---|---|---| | `arm-small` | 2 vCPU, 4 GiB memory, Amazon Linux 2023 arm64 | `eu-central-2` (Zurich) | 20 GiB gp3, encrypted | | `gpu-l4` | 1x NVIDIA L4 (24 GB) | `eu-central-2` (Zurich) | 20 GiB gp3, encrypted | Every lease runs on its own VM, and the VM is terminated when the lease ends. There's no inbound access from the internet: SSH is open only to the CapVM control plane. --- # MCP CapVM's MCP server lets AI agents and coding tools (Cursor, Codex, Claude Code and other streamable HTTP clients) rent and use machines with the same `ak_` key as the REST API. The CapVM team issues API keys after signup and Terms acceptance; they aren't self-serve (self-serve dashboard keys are Coming soon). > **Available:** the server at `https://api.capvm.com/mcp` with the tools below, including [`exec`](#exec), the Terms acceptance gate on `create_machine` ([Signup and Terms acceptance](signup.md)) . > > **Coming soon:** [Connect with OAuth](#connect-with-oauth-coming-soon), so an interactive client such as Codex can sign in through your browser instead of holding an `ak_` key, and [MCP Apps views](#mcp-apps-views-coming-soon) for machines and balance in hosts that support them, and card top-ups with [`create_checkout_session`](#create_checkout_session). For now, CapVM adds credits to your account. CapVM serves the Model Context Protocol over **streamable HTTP** (stateless sessions). The tools are a thin layer over the same billing service as the [REST API](api-reference.md), so holds, spend caps, concurrency limits and new-account limits work exactly the same way. | | | |---|---| | URL | `https://api.capvm.com/mcp`. It's on the API host, **not** under `/v1`. | | Auth | `Authorization: Bearer ak_test_…` or `ak_live_…`, the same agent keys as `/v1`. *Coming soon:* or an OAuth access token, see [Connect with OAuth](#connect-with-oauth-coming-soon). | | Scope | Every tool only sees the calling key's machines and usage. `get_balance` is for the whole organization. | | Rate limit | Each HTTP request counts toward the same per-key limit as `/v1` (120 per 60 s) | A missing, unknown or revoked key is rejected with HTTP `401` and the same error body as `/v1` (`unauthorized`, `invalid_api_key`, `key_revoked`) before any tool runs. ## Connect a client ### Cursor (`.cursor/mcp.json`) ```json { "mcpServers": { "capvm": { "url": "https://api.capvm.com/mcp", "headers": { "Authorization": "Bearer ak_test_..." } } } } ``` ### Any streamable HTTP client Point the client at `https://api.capvm.com/mcp` and send the header `Authorization: Bearer ak_test_...` on every request. Use the same JSON as above for any client that reads an `mcpServers` block with `url` and `headers`. ### Connect with OAuth (Coming soon) > **Coming soon.** Details may change before release. It uses the [dashboard sign-in](dashboard.md), also Coming soon. An interactive client can connect without an `ak_` key: it opens your browser, you sign in to CapVM and approve it with a spend cap, and the client gets short-lived tokens. `ak_` keys keep working on `/mcp` exactly as above, so use a key for headless agents (cloud agents, CI) that have no human to approve them. #### Codex Codex 0.77.0 or later: ```bash codex mcp add capvm --url https://api.capvm.com/mcp codex mcp login capvm ``` The second command opens your browser. Codex registers itself (as `Codex`) and listens for the answer on `http://127.0.0.1:/callback/…`. Don't add an `Authorization` header to this server's config: the client gets its own tokens. #### What happens in the browser 1. **Sign in.** If you aren't signed in, CapVM sends you to `/signin`. You get one email with a single-use link and an 8-character code (see [Dashboard sign-in](dashboard.md#signing-in)). Signing in from this flow also counts as the fresh sign-in the approval needs, so it takes one email, not two. 2. **Confirm it's you.** If you're signed in but your last sign-in or confirmation is more than 5 minutes old, CapVM sends you to `/signin/reauth` and emails you a code first. 3. **Approve.** The approval page shows: - the **redirect host** as its heading: where the client receives the approval. For Codex that's `127.0.0.1` (your own computer). If you didn't just start a login, or the host is one you don't recognise, click **Deny**. - the name the client gave itself, followed by **Unverified app**. Clients register themselves, so CapVM doesn't check the name. A client that gives no name is shown just as "Unverified app" (once). - "can create machines and spend up to $25 of your credit", and a **Spend cap (USD)** field: a whole number of dollars from **1 to 1000**, default **25**. The sentence shows the starting value; the cap that counts is the one in the field when you click **Approve**. - **Approve** and **Deny**. Deny sends the client `error=access_denied`. After you approve, CapVM emails you (the person who approved) a security alert (subject `CapVM security alert`, event `oauth_grant`) with the time in Europe/Zurich and UTC, the IP, the user agent and the client name. Like the sign-in alert, it has a **"This wasn't me"** link: single-use, valid for 7 days, and it runs the [lockdown](dashboard.md#this-wasnt-me) (signs out every session, revokes API keys created in the last 24 hours, freezes the organization). The email ends "Questions: hello@capvm.com." The [`refresh_reuse_detected`](#tokens) alert has the same link. The approval is refused when: | Case | What you see | |---|---| | Your organization is [frozen](dashboard.md#frozen-organizations) | The client gets `error=access_denied` with `error_description=org_frozen` (and your `state`) | | Your organization hasn't accepted the Terms yet (`pending_acceptance`) | The client gets `error=access_denied` with `error_description=org_pending` (and your `state`) | | The client asked for a scope other than `mcp` and `offline_access`, or didn't ask for `mcp` | The client gets `error=invalid_scope` (`scope must include mcp.`) | | The spend cap isn't a whole number from 1 to 1000 | `400 validation_error` `spend_cap_usd must be a whole number of dollars from 1 to 1000.` | | The approve form has no valid antiforgery token | `400 validation_error` `Antiforgery token is missing or invalid.` | #### What a connected client can do - The same tools as a key, except [`create_checkout_session`](#create_checkout_session), which fails with `validation_error` `Checkout requires an API key.` - **Scope:** each connection (grant) sees only the machines it created and its own usage; `get_balance` is for the whole organization, as with a key. - **Spend cap:** the cap you set on the approval page, checked like a key's cap (`spend_cap_exceeded`). Change it later with [`PATCH /v1/org/oauth/grants/{id}`](api-reference.md#oauth-grants-coming-soon): $1 to $1000; raising it needs a sign-in within the last 5 minutes, lowering doesn't. - **SKUs and concurrency:** a grant may use every SKU and has no concurrency limit of its own. Your organization's new-account limits still apply. - **Rate limit:** 120 requests per 60 s per grant, like a key (`429 rate_limited`, `Per-key rate limit exceeded.`). - **REST:** `/v1` doesn't accept OAuth tokens. A token sent there gets `401 invalid_api_key`. #### Tokens | | | |---|---| | Access token | 15 minutes. Token responses always include `"expires_in": 900`. Opaque: CapVM looks it up on every call, so a revoked grant stops working on its next request. | | Refresh token | Issued when the client asks for `offline_access`. A new one with every refresh. It expires after **7 days without use**, and the connection ends **30 days after you approved it** at the latest (`invalid_grant` `The grant has expired.`): run `codex mcp login capvm` again. | | Retried refresh | Sending the same refresh token again **within 60 seconds** returns exactly the same response as the first time, so two parallel refreshes don't lock you out. Sending it again **later** is treated as theft: CapVM revokes the whole grant, emails the person who approved it a security alert (`refresh_reuse_detected`), and returns `invalid_grant` `The refresh token was reused.` | | Authorization code | 60 seconds, single use, with no clock-skew allowance. PKCE with `S256` is required; `plain` is rejected. | **`resource` is required.** The client must send `resource=https://api.capvm.com/mcp` (RFC 8707) on the authorize request and on every token request, code exchange and refresh alike. Missing or any other value: `400` `{"error":"invalid_target","error_description":"resource must be https://api.capvm.com/mcp."}`. Codex sends it. #### How a client finds the sign-in (401 discovery) A request to `/mcp` without a bearer gets `401` with: ``` WWW-Authenticate: Bearer resource_metadata="https://api.capvm.com/.well-known/oauth-protected-resource/mcp" ``` An expired or revoked OAuth token gets the same header plus `, error="invalid_token"`, and the body `{"error":{"code":"unauthorized","message":"Access token is expired or revoked."}}`. From there the client reads the [discovery documents](api-reference.md#oauth-coming-soon) and registers itself. #### Disconnecting a client The dashboard has a **Connected apps** section on `/dashboard` and `/dashboard/keys`: one row per approved OAuth client with the app name (marked "Unverified app"), redirect host, spend cap, spent, created and last used (in micro-USD and `yyyy-MM-dd HH:mm:ss`), an **Update cap** field ($1 to $1000; raising needs a fresh sign-in) and a **Revoke** button. The same routes are available as JSON: [`GET /v1/org/oauth/grants`](api-reference.md#oauth-grants-coming-soon) lists your organization's connected clients (name, "verified": `false`, redirect host, cap, spent, created, last used), and `DELETE /v1/org/oauth/grants/{id}` revokes one with all its tokens. Its next `/mcp` call gets `401` (above), and its refresh fails with `invalid_grant`. Revoking sends no email. A client can also disconnect itself: revoking its access or refresh token at [`POST /oauth/revoke`](api-reference.md#post-oauthrevoke) revokes the whole grant and all its tokens, the same as the `DELETE` route. **Signing out everywhere** also revokes every OAuth grant you approved, and the **"This wasn't me" lockdown** revokes the OAuth grants of everyone in your organization. #### Frozen organizations While your organization is [frozen](dashboard.md#frozen-organizations), new approvals are refused (the client gets `error=access_denied`, `error_description=org_frozen`). On `/mcp`, an OAuth token is treated like an `ak_` key: `initialize`, `ping` and `tools/list` go through, and each tool call is accepted or rejected on its own. `create_machine`, `get_machine`, `list_machines`, `exec` and `create_checkout_session` fail with the tool error `org_frozen: This organization is frozen.`; `get_balance`, `get_usage` and `stop_machine` keep working. A blocked tool call returns HTTP `200` with a tool result that has `isError: true` and the code `org_frozen`, not an HTTP error; REST calls still get `403 org_frozen`. (`create_checkout_session` isn't available to OAuth clients anyway.) Revoking a grant and lowering its cap still work; raising it returns `403 org_frozen`. ### Keep the key safe Your MCP client sends this key with every call, so anyone who has it can spend up to the key's cap. - **Give each client its own key with a low spend cap**, for example one for Codex on your laptop and one for each cloud agent. A leaked key then costs at most its cap, and you can revoke just that one (it gets `401 key_revoked` right away). For now, CapVM issues and revokes keys for you. *Coming soon:* a signed-in person in your organization can create, cap and revoke keys through the [dashboard key routes](dashboard.md#api-keys). - *Coming soon:* **for a client you use interactively, such as Codex, prefer [OAuth](#connect-with-oauth-coming-soon).** No long-lived secret goes in its config, access tokens last 15 minutes, and each connection has its own spend cap. Keep `ak_` keys for headless agents. - **Keep the key out of files you share.** If your client can read the header value from an environment variable or your OS keychain, use that instead of pasting the key into its config. Never commit a config file that contains a key. - **Use an `ak_test_` key** while you're trying things out. The connection is always HTTPS, so a VPN isn't needed. > **`idempotency_key` is required on `create_machine`.** It follows the same rule as the REST `Idempotency-Key` header: 1 to 255 characters (UTF-16 code units) after trimming, no control characters, scoped to your API key. If you retry with the same key and the same `sku`/`ttl_seconds`, you get the **same machine back, with a single hold**. That makes it safe to retry after a timeout. Use a stable value per task, for example `job-42`. Today the rules for a blank key differ between `create_machine` and `create_checkout_session` (see each tool). ## Tools Money is always integer micro-USD (1 USD = 1,000,000). Successful results are JSON in a text content block. ### `create_machine` Rents a machine. The full TTL is held before launch, and a rejected hold launches nothing. | Param | Type | Required | Notes | |---|---|---|---| | `sku` | string | yes | `arm-small` ($0.20/h) or `gpu-l4` ($2.00/h). Must be on the key's allow-list. | | `ttl_seconds` | integer | yes | 60 to 7200 | | `idempotency_key` | string | **yes** | 1 to 255 visible characters (trimmed). Scoped to the API key and shared with the REST `Idempotency-Key`. Same key + same `sku`/`ttl_seconds` → the existing machine, no second hold. A different `sku` or `ttl_seconds` → `idempotency_conflict`. | Errors for the key (exact text): | Case | Tool error text | |---|---| | `idempotency_key` missing (or `null`) | `idempotency_key_required: idempotency_key is required.` | | Empty string `""` | `idempotency_key_required: idempotency_key is required.` | | Only whitespace, longer than 255 after trimming, or contains a control character | `idempotency_key_invalid: idempotency_key must be 1 to 255 visible characters.` | `create_checkout_session` treats a whitespace-only key as `idempotency_key_required` instead (see below). > **Coming soon:** one shared key check for machine create and checkout over REST and MCP (keys trimmed and stored trimmed, emoji allowed, only control characters rejected), with slightly different error messages. A rejected key takes no hold and launches nothing. Arguments: ```json {"sku":"arm-small","ttl_seconds":900,"idempotency_key":"job-42"} ``` Result (a Machine, the same shape as REST): ```json { "id": "m_9b1c0e6f2d8a4c3b9e7f1a2b3c4d5e6f", "sku": "arm-small", "state": "provisioning", "instance_id": "i-0abc…", "public_ip": null, "region": "eu-central-2", "ttl_seconds": 900, "price_per_hour_micro": 200000, "hold_micro": 50000, "charge_micro": null, "created_at": "2026-10-25T11:00:00Z", "expires_at": "2026-10-25T11:15:00Z", "ready_at": null, "stop_requested_at": null, "terminated_at": null } ``` ### `get_machine` | Param | Type | Required | |---|---|---| | `machine_id` | string (`m_…`) | yes | Returns a Machine. Machines created by another key aren't visible (`not_found`), even within the same organization. ### `list_machines` No params. Returns `{"machines":[Machine, …]}`: up to 100 machines for this key, newest first. ### `stop_machine` | Param | Type | Required | |---|---|---| | `machine_id` | string (`m_…`) | yes | Charges the billed seconds (at least 60, at most `ttl_seconds`) and releases the rest of the hold. Returns the Machine with `state: "terminated"` and `charge_micro` set. Stopping a machine that's already settled returns it again. This is the same as `DELETE /v1/machines/{id}`. ### `exec` | Param | Type | Required | Notes | |---|---|---|---| | `machine_id` | string (`m_…`) | yes | Must be `ready` and owned by this key | | `command` | string | yes | 1 to 8192 characters, no NUL | | `timeout_seconds` | integer | no | 1 to 300, **default 30**. Outside that range → `timeout_out_of_range: timeout_seconds must be between 1 and 300.` | | `working_directory` | string | no | Absolute path on the machine; leave it out for the default. Same rules as [REST](api-reference.md#post-v1machinesidexec-run-a-command), otherwise `working_directory_invalid` | Arguments: ```json {"machine_id":"m_9b1c0e6f2d8a4c3b9e7f1a2b3c4d5e6f","command":"uname -a","timeout_seconds":30} ``` Result: ```json {"stdout":"…","stderr":"","exit_code":0,"truncated":false} ``` The tool works like `POST /v1/machines/{id}/exec`, with a 256 KiB cap per stream (`truncated`) and the REST exec errors as `: ` text, for example `command_timeout: Command timed out.` or `provider_error: The machine did not report an exit code.` See [API reference → exec](api-reference.md#post-v1machinesidexec-run-a-command). ### `get_usage` No params. Same payload as `GET /v1/usage`, **for the calling key only**: other keys in the organization aren't included. `events` lists up to 100 recent charges, newest first. ```json { "spend_micro": 3334, "held_micro": 0, "spend_cap_micro": 5000000, "events": [ { "id": "3f0c2a9e-6b1d-4e8a-9c7f-2d5b8e1a4c6f", "machine_id": "m_9b1c0e6f2d8a4c3b9e7f1a2b3c4d5e6f", "sku": "arm-small", "seconds": 60, "amount_micro": 3334, "created_at": "2026-10-25T11:01:00Z" } ] } ``` `spend_micro` is what the key has been charged, `held_micro` is its open holds, and `spend_cap_micro` is its cap. Event `id` is a UUID. ### `get_balance` No params. The organization's balance, including holds from other keys: ```json {"available_micro":9796666,"held_micro":203334,"currency":"USD","unit":"micro_usd"} ``` ### `create_checkout_session` > **Coming soon.** For now, CapVM adds credits to your account. **The `amount_usd` format may change**, possibly to integer cents. Its errors don't use the [tool-error format](#errors) yet (see below). Starts a prepaid credit top-up by card: it creates a Stripe Checkout Session and returns its link. **A human must open the link and pay.** The agent can't. Same rules as [`POST /v1/checkout/sessions`](api-reference.md#post-v1checkoutsessions-start-a-card-top-up), including the Terms gate. Prices exclude VAT. Marked idempotent. | Param | Type | Required | Notes | |---|---|---|---| | `amount_usd` | number or string | yes | USD, the same rules as the REST body: a JSON number is whole dollars (`50`; `50.5` is rejected with `validation_error`), a string may have at most two decimals (`"50"`, `"50.00"`). $10 to $1000. Both forms are tested (REST). | | `idempotency_key` | string | yes | 1 to 255 visible characters after trimming (no control characters). A whitespace-only key is `idempotency_key_required` here (`create_machine` says `idempotency_key_invalid`). The same key from the same API key, with the same amount, returns the same session. Keys are per API key, as for `create_machine`. | | `success_url` | string | no | Absolute `http(s)` URL Stripe returns the payer to. Default `https://capvm.com/checkout/success` (page not built yet). | | `cancel_url` | string | no | Absolute `http(s)` URL if the payer cancels. Default `https://capvm.com/checkout/cancel` (page not built yet). | Result: ```json {"id":"cs_test_…","url":"https://checkout.stripe.com/…"} ``` Pass `url` to a human. Credits arrive in `get_balance` once Stripe confirms the payment. You're credited the amount before VAT, in USD. Errors use the same codes and messages as REST (`validation_error`, `idempotency_key_required`, `idempotency_key_invalid`, `min_topup_not_met`, `max_topup_exceeded`, `terms_not_accepted`, `idempotency_conflict`, `stripe_not_configured`, `stripe_error`). A missing, empty or blank `idempotency_key` gives `idempotency_key_required: idempotency_key is required.` One over 255 characters or with a control character gives `idempotency_key_invalid: idempotency_key must be 1 to 255 visible characters.` (`create_machine` uses its own codes, above). An open payment dispute doesn't block this tool; it blocks `create_machine` (`account_suspended`). **How errors come back today:** unlike the other tools, this one doesn't wrap CapVM's errors into the `: ` text and `structuredContent.error` described in [Errors](#errors): it lets them propagate to the MCP SDK, so the extra fields of `terms_not_accepted` (`required_versions`, `accept_url`) aren't passed on. `idempotency_key` is a required parameter in the tool schema. > **Coming soon:** this tool will return its errors in the same [format](#errors) as the other tools, so `terms_not_accepted` carries `required_versions` and `accept_url`. ## Errors A rejected tool call comes back as an MCP tool error (`isError: true`) whose text is `: `, using the same codes as the REST API, for example: ``` insufficient_credits: … ``` The same result also carries `structuredContent` with the same error object as the REST API: `code` and `message` nested under `error`, plus any extra fields the error has, inside `error` too: ```json {"error": {"code": "insufficient_credits", "message": "…"}} ``` An error without extra fields has only `code` and `message` inside `error`. Extra fields can't override `code` or `message`: an extra field with either name is dropped, so `error.code` and `error.message` are always the error's own. The text line and `error.message` carry the same message. This applies to every tool except `create_checkout_session` (see [above](#create_checkout_session)); that's Coming soon. Codes you may see: `idempotency_key_required`, `idempotency_key_invalid`, `sku_required`, `unknown_sku`, `ttl_out_of_range`, `insufficient_credits`, `spend_cap_exceeded`, `sku_not_allowed`, `account_limit_reached`, `concurrency_limit_exceeded`, `idempotency_conflict`, `capacity_unavailable`, `launches_disabled`, `provider_error`, `not_found`, `command_required`, `command_too_long`, `timeout_out_of_range`, `machine_not_ready`, `machine_not_running`, `terms_not_accepted`, `account_suspended`. See [API reference → Errors](api-reference.md#errors). - **`terms_not_accepted`** on `create_machine`, for example `terms_not_accepted: Accept the current Terms of Service and Acceptable Use Policy before creating machines, API keys, or adding credits.` The message can also be `A human has not confirmed the Terms of Service and Acceptable Use Policy for this organization.` (pending signup) or, on a production server before the Terms take effect, `No Terms of Service or Acceptable Use Policy version is in effect.` Over MCP there is no HTTP `403`. The tool error carries `required_versions` (`{"tos_version","aup_version"}`, or `null` before any version is in effect) and `accept_url`, the same as the REST body, for example `{"error":{"code":"terms_not_accepted","message":"…","required_versions":{"tos_version":"tos-0.2","aup_version":"aup-0.2"},"accept_url":"https://api.capvm.com/terms/accept"}}`. Only a human can fix it: see [Signup → 403 terms_not_accepted](signup.md#403-terms_not_accepted). - **`account_suspended`: New machines are suspended while a payment dispute is open.` from `create_machine` while your organization has an open card dispute. Also `insufficient_credits` with a negative balance after a refund or dispute. When a dispute opens or a refund leaves the balance negative, CapVM also stops and destroys your running machines within seconds and emails the account once; `get_machine` then shows them terminated. See [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes). - **`org_frozen`** `This organization is frozen.` *Coming soon:* while your organization is [frozen](dashboard.md#frozen-organizations), with an `ak_` key or an OAuth token, `initialize`, `ping` and `tools/list` work and `create_machine`, `get_machine`, `list_machines`, `exec` and `create_checkout_session` fail with the tool error `org_frozen: This organization is frozen.`; `get_balance`, `get_usage` and `stop_machine` keep working. The blocked call returns HTTP `200` with `isError: true` (see [Frozen organizations](#frozen-organizations)). - **Exec errors**: `command_timeout`, `working_directory_invalid`, `internal_error` and the others (see [`exec`](#exec)). ## MCP Apps views (Coming soon) > **Coming soon.** Details may change before release. CapVM will support the MCP Apps extension `io.modelcontextprotocol/ui` (spec `2026-01-26`). A host that supports it can show a small interactive page next to some tool results. | Tools | View | What it shows | |---|---|---| | `list_machines`, `get_machine` | `ui://capvm/machines.html` | One card per machine: state, SKU, id, TTL remaining (ticks every second), **Estimated cost** (see below), hold, price per hour, region, instance type, and public IP if it has one. A **Refresh** button asks the host to call the same tool again. | | `get_balance`, `get_usage` | `ui://capvm/balance.html` | `get_balance`: available and held credits. `get_usage`: spend, held, spend cap, and a table of recent charges (when, machine, SKU, seconds, amount). Both show a top-up form and a **Refresh** button. Refresh re-runs the tool that opened the view, with the arguments the host passed it: `get_usage` keeps the usage table, `get_balance` the balance. | `create_machine`, `stop_machine`, `exec` and `create_checkout_session` have no view. `exec` has no view yet. **Estimated cost is only an estimate.** The view works it out itself, with the clock of the device showing it: seconds from `created_at` to now (or to `expires_at` if that's earlier), at least 60, at most the TTL, then `ceil(price_per_hour_micro × seconds / 3600)`, at most the hold. Once the machine has a `charge_micro`, the view shows that amount as **Charged** instead. The view says so: "The charged amount is final and comes from the server." CapVM has no server-side running-cost field yet. **Where the data comes from.** The view reads the JSON text of the tool result that the host passes it. It holds no API key and makes no network requests of its own. Refresh and top-up are tool calls the view asks the host to make. The pages are `text/html;profile=mcp-app`, with inline CSS and script and no external origins. Their `_meta.ui` sets an empty CSP `connectDomains` and `resourceDomains`, and `prefersBorder: true`. Machine and charge fields are shown as text, not HTML. **Top-up from the balance view:** 1. Enter whole dollars from 10 to 1000. The view checks this before calling anything. 2. Click **Open checkout**. The button is disabled until the request finishes, so a double click sends one request. The view asks the host to call [`create_checkout_session`](#create_checkout_session) with that `amount_usd` and a random `idempotency_key` (`ui-` plus 32 hex characters). 3. If the result has a link starting `https://`, the view asks the host to open it (`ui/open-link`). Any other link is refused, and the view shows the result text instead (or "Checkout did not return an https link." if there is none). A human pays on Stripe's page; Stripe isn't embedded in the view. 4. The view keeps the same key for a retry of the same amount when the first try got no definite answer from CapVM: the host reported an error (for example a transport error or timeout), or the result had no usable `https://` link (not JSON, empty, or another scheme). The retry then returns the same Checkout Session if CapVM did create one. 5. The view makes a new key after CapVM returns a session with an `https://` link (even if the host then fails to open it), after a CapVM tool error (`isError`, or an `error` object in the result), and when the amount changes. So two successful clicks create two Checkout Sessions. Credits arrive only for a session that's paid. 6. The view doesn't update itself after payment. Click **Refresh** (or call `get_balance`) once Stripe has confirmed it. If the tool call fails, the view shows the error text as it gets it, for example a `terms_not_accepted` message. It doesn't offer the `accept_url`: a human still has to accept the Terms (see [Signup → 403 terms_not_accepted](signup.md#403-terms_not_accepted)). For how this tool's errors come back today, see [above](#create_checkout_session). **Clients without MCP Apps** get the same tool results as before: same text, and still no `structuredContent` on success. `tools/list` still lists `_meta.ui.resourceUri` on the four tools above for every client, and the server advertises the extension and the two resources to every client. A client that doesn't understand them can ignore them. ## Not in MCP - **Adding credits directly and issuing keys:** done by CapVM, not exposed. Buying credits by card will be [`create_checkout_session`](#create_checkout_session) (Coming soon), and a human still pays. - The OpenAPI document at `/openapi.json` covers the REST API only. --- # Dashboard: sign-in, keys and security (Coming soon) > **Coming soon.** Details may change before release. > > **What the pages show.** `/dashboard` shows your organization's name and status, a frozen banner, the balance (available and held), your machines with a **Stop** button, a **Connected apps** section on `/dashboard` and `/dashboard/keys`: one row per approved OAuth client with the app name (marked "Unverified app"), redirect host, spend cap, spent, created and last used (in micro-USD and `yyyy-MM-dd HH:mm:ss`), an **Update cap** field ($1 to $1000; raising needs a fresh sign-in) and a **Revoke** button, and **Sign out** and **Sign out everywhere** buttons. `/dashboard/keys` lists keys (label, prefix, created, created IP, last used, cap, revoked) and lets you create, edit and revoke them. The JSON routes below do the same. This page is for the people in your organization, not for agents. Agents keep using `ak_` keys (see [API reference](api-reference.md)) or [OAuth](mcp.md#connect-with-oauth-coming-soon). ## Signing in There are no passwords. Go to `https://api.capvm.com/signin`, enter your email address and click **Email me a link**. CapVM emails you (subject `Sign in to CapVM`): ``` Sign in to CapVM. Open this single-use link. It expires at 2026-10-26T14:15:00Z. https://…/signin/confirm/… Or enter this code on the sign-in page: 7K2QW9MD ``` Either open the link and click **Sign in**, or type the code into the **Code** field on the sign-in page and click **Sign in with code**. You then land on the page you came from, or `/dashboard`. - **Link and code are one sign-in.** Both expire **15 minutes** after the email is sent, and using one uses up the other. - **The code works only in the browser that asked for it** (it's bound to a sign-in cookie). Asking for a new email in that browser replaces it. - **The code** is 8 characters from `0-9` and `A-Z` without `I`, `L`, `O` and `U`. Case, spaces and dashes don't matter, and `I`/`L` are read as `1`, `O` as `0`. - **5 wrong codes** use up the sign-in; ask for a new email. - **The page always says "Check your email for a sign-in link."**, even for an address CapVM doesn't know, and even if the email couldn't be sent. If nothing arrives, ask for a new email (the rate limit below applies). - **Rate limit:** 5 emails per hour per IP and 5 per hour per email address, `429 rate_limited` `Sign-in rate limit exceeded.` with `Retry-After`. - **Every sign-in sends a security alert** (see [Alert emails](#alert-emails)). ### Sign-in errors The link page (`/signin/confirm/{token}`) shows the error on the page with the status: | Status | Code | Message | |---|---|---| | 400 | `validation_error` | `This sign-in link is not valid.` | | 400 | `link_used` | `This sign-in link was already used.` | | 410 | `link_expired` | `This sign-in link has expired.` | The code form (`POST /signin/code`) answers with a redirect on success, or JSON: | Status | Code | Message | |---|---|---| | 400 | `code_invalid` | `That code is not valid.` The error also has `tries_left`: `{"error":{"code":"code_invalid","message":"That code is not valid.","tries_left":4}}` | | 410 | `code_burned` | `This code can no longer be used.` (expired, already used, 5 wrong tries, or asked for in another browser) | | 400 | `validation_error` | `code is required.` / `Antiforgery token is required.` / `returnUrl must be a local path.` | `returnUrl` must be a path on this site (starting with a single `/`, no `\`, no `://`, no spaces, at most 2048 characters). A sign-in page with any other `returnUrl` ignores it. ## Sessions - The session is a cookie, `__Host-capvm_session` (HttpOnly, Secure, SameSite=Lax). - It ends after **12 hours without use** or **7 days** at the latest. - The session cookie isn't accepted on `/mcp` or on agent routes such as `/v1/machines`. ### Confirming it's you (reauth) Some actions need a sign-in or confirmation within the **last 5 minutes**: - creating an API key - raising a key's spend cap - approving an OAuth client and raising its cap (Coming soon) Otherwise the route returns `403 reauth_required` `Sign in again to continue.` (`Sign in again to raise this spend cap.` for an OAuth client's cap). Go to `/signin/reauth`, click **Email me a code** (subject `CapVM sign-in code`, same link and code), and enter it under **Confirm it's you**. Lowering a cap, renaming or revoking a key never needs it. A sign-in that came from a page that sent you to sign in (it carries a `returnUrl`, as `/dashboard` and the OAuth approval do) counts as fresh. A sign-in started at plain `/signin` doesn't: creating a key right after it asks you to confirm. ### Signing out - **Sign out** (`/signout`) ends this browser's session. - **Sign out everywhere** (`/signout/all`) ends **all your** sessions in every browser. It doesn't sign out other people in your organization and doesn't touch API keys. It also revokes every [OAuth grant](#connected-oauth-clients) you approved. Both are buttons on the dashboard and work while the organization is frozen. ## API keys Signed in, you can manage your organization's `ak_` keys with these routes (the dashboard's Keys page uses the same routes). Every key in the organization is listed, including revoked ones, newest first, with: | Field | | |---|---| | `id` | key id | | `label` | your name for it, or `null` | | `prefix` | the start of the key, to recognise it | | `created_at` | when it was created | | `created_ip` | the IP it was created from (`null` for keys CapVM issued) | | `last_used_at` | the last machine it created or usage it recorded, or `null` | | `revoked_at` | `null` while active | | `spend_cap_micro` | its spend cap | **Creating a key** needs a fresh sign-in and a spend cap between $1 and $1000 (in micro-USD; outside that range you get `400 cap_out_of_range`), plus an optional label (1 to 80 characters). The new key is an `ak_live_` key that may use every SKU and run up to **10 machines at once**. **The full key is shown only in the create response.** CapVM emails you an alert (subject `CapVM API key created`). Creating a key also needs a current Terms acceptance (`403 terms_not_accepted`). **Renaming** and **changing the cap** use the same route. Raising the cap needs a fresh sign-in; lowering it doesn't. A revoked key can't be changed. **Revoking** a key takes effect on its next call (`401 key_revoked`). Revoking twice is fine. Full request and error tables: [API reference → Organization](api-reference.md#organization-coming-soon). ## Machines and usage Signed in, you can list every machine in the organization, stop any of them, and read the organization's usage. Stopping works while the organization is frozen. See [API reference → Organization](api-reference.md#organization-coming-soon). ## Connected OAuth clients > **Coming soon.** Clients you approved through [OAuth](mcp.md#connect-with-oauth-coming-soon), such as Codex, are listed at `GET /v1/org/oauth/grants` with their name, `verified` (always `false`), redirect host, cap, amount spent, created and last-used time. You can change a client's cap ($1 to $1000; raising needs a fresh sign-in) or revoke it, which ends its tokens at once. A client can also revoke itself through `POST /oauth/revoke`. There's no Connected apps screen yet. See [API reference → OAuth grants](api-reference.md#oauth-grants-coming-soon). ## Alert emails CapVM emails the person concerned when: | Event | Subject | "This wasn't me" link | |---|---|---| | A sign-in or confirmation completes (`sign_in`) | `CapVM sign-in` | yes | | You create an API key (`key_created`) | `CapVM API key created` | yes | | You approve an OAuth client (`oauth_grant`) | `CapVM security alert` | yes | | An OAuth refresh token is reused (`refresh_reuse_detected`) | `CapVM security alert` | yes | The sign-in and key alerts look like this: ``` CapVM security alert. Event: sign_in Time (Europe/Zurich): 2026-10-26 15:00:00 Time (UTC): 2026-10-26 14:00:00 IP: 203.0.113.7 User-Agent: Mozilla/5.0 … This wasn't me: https://…/signin/lockdown/… That link is single-use and expires in 7 days. It signs out every session, revokes API keys created in the last 24 hours, and freezes the organization. ``` The OAuth alerts have the same layout with a `Client:` line (the client's name) after `User-Agent:`, the same "This wasn't me" link and sentence, and a last line `Questions: hello@capvm.com.` ## "This wasn't me" The link opens a page with a **Lock this organization** button. Clicking it: 1. signs out **every session of everyone in the organization**, 2. revokes **every API key in the organization created in the last 24 hours** (older keys keep working, within the freeze rules below), 3. **freezes the organization**. The page then says "Organization locked". It also revokes the OAuth grants of everyone in the organization (see [Connected OAuth clients](#connected-oauth-clients)). Only CapVM can unfreeze: contact hello@capvm.com. The page shows `400 validation_error` `This link is not valid.`, `400 link_used` `This link was already used.` or `410 link_expired` `This link has expired.` when it can't lock. ## Frozen organizations A "This wasn't me" lockdown or CapVM can freeze an organization. You can still sign in. The dashboard shows "This organization is frozen. The dashboard is read-only. You can still review usage, revoke keys, and sign out everywhere." | Still works | Returns `403 org_frozen` `This organization is frozen.` | |---|---| | Signing in, signing out, signing out everywhere | Creating a key | | Listing keys, revoking a key, lowering a key's cap | Raising a key's cap, renaming a key | | Listing and stopping the organization's machines, reading usage | Creating machines, exec, topping up | | `ak_` keys: `GET /v1/balance`, `GET /v1/usage`, `DELETE /v1/machines/{id}` (with or without a trailing slash); over MCP (also with an OAuth token) `initialize`, `ping`, `tools/list`, `get_balance`, `get_usage`, `stop_machine` | `ak_` keys: every other REST call; over MCP (also with an OAuth token) the tools `create_machine`, `get_machine`, `list_machines`, `exec`, `create_checkout_session` fail with `org_frozen` | | OAuth clients: revoking, lowering the cap, the MCP calls above | OAuth clients: approving, raising the cap, the MCP tools above (see [MCP](mcp.md#frozen-organizations)) | `GET /v1/account` shows `"frozen": true`. --- # FAQ Common questions about CapVM: hosting, access, pricing, credits, limits, MCP and data. **What is CapVM?** On-demand ARM and NVIDIA L4 GPU machines that AI agents create, use and pay for through an API, from prepaid credits and within caps you set. **Where are machines hosted?** In Zurich, Switzerland (AWS `eu-central-2`). **Who can use it?** Businesses and professionals. CapVM doesn't sell to private consumers. **How do I get access?** Sign up with `POST /v1/signup` ([Signup](signup.md)). API keys aren't self-serve: the CapVM team issues them after your organization signs up and a human accepts the Terms. *Coming soon:* people in your organization can sign in with an emailed link or code and create, cap and revoke API keys themselves; see [Dashboard](dashboard.md). **How does paying work?** You add credits up front, from $10. For now, CapVM adds credits to your account. Buying them by card through Stripe Checkout ($10 to $1000 per top-up, plus VAT) is Coming soon: see [Billing → Topping up by card](billing-and-caps.md#topping-up-by-card). Your agents spend them per second, with a 60-second minimum. When a machine is created, its full time limit is held. When it stops, only the time used is charged and the rest goes back to your balance. Machine holds never take your balance below zero. With card top-ups, a refund or card dispute can: see [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes). **Do credits expire?** No. Credits never expire. **Can I get a refund?** **Credits are non-refundable**, whether used or unused, including if you stop using CapVM or close your account. The exceptions are in Terms of Service §7.2: duplicate or wrong charges, if we end the service or close your account without cause, a machine failure caused by a fault on our side (credited back as credits, if you report it within 7 days), closing your account because you object to a material change to the Terms, and closing your account because you object to a new sub-processor under the Data Processing Agreement. There's no refund endpoint: CapVM handles these. When a card top-up is refunded in Stripe, CapVM takes back the matching credits before VAT. If you dispute a card payment, the disputed credits are taken back and new machines are suspended (`403 account_suspended`) until the dispute closes, and your running machines are stopped and destroyed within seconds, with no grace period (usage up to the stop is billed). You then get one email, "CapVM stopped your machines", listing the machines, the reason and your balance. A won dispute gives the credits back but doesn't restart those machines. A refund that leaves your balance negative also stops running machines, with a similar email that explains the next top-up covers the negative balance first. A bank inquiry alone changes nothing. For now, freezing your credits during a dispute or recovering dispute fees (Terms §8.2) isn't automatic: CapVM handles it manually if needed. See [Billing → Refunds and disputes](billing-and-caps.md#refunds-and-disputes). **What happens when an agent hits its cap?** CapVM checks the cap before anything launches. If a new machine would push the key over its cap, the request fails with `402 spend_cap_exceeded` and nothing starts. Machines that are already running have their full time limit paid for, so they can't overspend. **What are the limits?** Each machine stops at the end of its time limit, at most 2 hours (7200 s). Each machine may send at most 5 GB of outbound data. Outgoing mail ports 25, 465 and 587 are blocked. New accounts may run at most 1 GPU and 3 machines at a time. See [Limits](limits.md). **What happens to my data when a machine stops?** All data on a machine is permanently deleted when the machine is destroyed. CapVM provides no backups. **Can my agent run commands?** Yes. CapVM runs the command on the machine with a timeout of up to 300 seconds and output capped at 256 KiB per stream. If the machine isn't accepting commands yet, or the command was cancelled before it started, you get `409 machine_not_ready`: the command didn't run, so it's safe to retry. A `408 command_timeout` means the command hit a timeout and may or may not have started: it may have had effects, so don't blindly retry. If the machine reports no exit code you get `502 provider_error` (`The machine did not report an exit code.`). CapVM doesn't keep your command or its output: output is stored only temporarily in Zurich so it can be returned to you, and deleted once returned (at the latest after 1 day). See [API reference → exec](api-reference.md#post-v1machinesidexec-run-a-command). **Can my agent sign us up?** Yes. An agent can start a signup with `POST /v1/signup`, but only a human authorised to bind your business can accept the Terms, by opening the emailed link within 72 hours and clicking **I accept on behalf of my business**. Until then you get `403 terms_not_accepted`. Signup is limited to 5 requests per hour per IP and per email, and before the Terms take effect (effective date to be confirmed) signup is refused. If the link expired while signup is still pending, repeat the signup with the same email to get a new link (the old one stops working). If CapVM set up your account or a new Terms version needs accepting, ask CapVM to send a link. See [Signup and Terms acceptance](signup.md). **Is there an MCP server?** Yes, at `https://api.capvm.com/mcp`, with your `ak_` key. See [MCP](mcp.md). **Can I connect Codex without pasting an API key?** Coming soon: yes, with OAuth. Run `codex mcp add capvm --url https://api.capvm.com/mcp` and `codex mcp login capvm` (Codex 0.77.0 or later), sign in, and approve it with a spend cap from $1 to $1000 (default $25). Access tokens last 15 minutes; the connection ends after 7 days without use or 30 days at most. Disconnect it with `DELETE /v1/org/oauth/grants/{id}` or by revoking its token at `POST /oauth/revoke`. `ak_` keys keep working. See [MCP → Connect with OAuth](mcp.md#connect-with-oauth-coming-soon). **What if I get a sign-in alert I don't recognise?** Coming soon: click "This wasn't me" in the email. It signs out everyone in your organization, revokes API keys created in the last 24 hours and freezes the organization until CapVM unfreezes it. Once OAuth sign-in is available, it also disconnects your organization's OAuth clients, and the OAuth approval alert has the same link. See [Dashboard → "This wasn't me"](dashboard.md#this-wasnt-me). **Will my AI client show machines and balance visually?** Coming soon: hosts that support MCP Apps get small views for `list_machines`, `get_machine`, `get_balance` and `get_usage`, including an estimated running cost (not the charge) and a top-up button that opens Stripe Checkout through the host. Other clients get the same results as today. `exec` has no view yet. See [MCP Apps views](mcp.md#mcp-apps-views-coming-soon). **Do prices include VAT?** No. Prices are in USD, excluding VAT where applicable. Swiss customers pay Swiss VAT (currently 8.1%) on top. **What isn't allowed?** Read the Acceptable Use Policy. It rules out, among other things, crypto mining, attacking or scanning third parties, spam, malware, and getting around caps or limits. **Who runs CapVM?** MAKERSCLUB Molina, Thunstrasse 124, 3074 Muri bei Bern, Switzerland. hello@capvm.com