CapVM docs

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 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 are Coming soon. Every key has:

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

export CAPVM_KEY=ak_test_...
export CAPVM=https://api.capvm.com/v1

2. Check your balance

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.

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.

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

{
  "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

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.

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}

All fields and errors: API reference → exec.

6. Check spend, then stop

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.