# 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.
