Cubs

Docs

Recipes

Sign in, create a computer, pause it, add credit, audit the books. Each step shows the request and what comes back.

Every command below uses $ORIGIN for the deployment address. Set it once in your shell:ORIGIN=https://your-domain.example

1. Sign in

There is no password. A request returns a link, and opening it sets a session cookie. The link is bound to the browser that asked for it, so a link forwarded to someone else does nothing.

curl -i -c jar.txt -X POST $ORIGIN/api/auth/request \
  -H 'Content-Type: application/json' \
  -d '{"email":"you@example.com"}'

Until a mail transport is configured, the link is written to the server log instead of being sent. GET /api/health reports that as email delivery: degraded, so it is visible rather than assumed.

# the log line contains the link; open it in the same browser
open "$(grep -o 'http[^ ]*token=[^ ]*' server.log | tail -1)"

The callback sets cubs_session, an HttpOnly cookie. Every request below carries it, which is what -b jar.txt is for. Requests without it answer401 unauthenticated.

2. Create a computer

A machine starts paused. It is not running and not being charged until you resume it, so creating one by accident costs nothing.

curl -b jar.txt -X POST $ORIGIN/api/machines \
  -H 'Content-Type: application/json' \
  -d '{"name":"build-box","vcpus":4}'

The name must be a valid hostname: letters, digits and hyphens. vcpus is 2 to 32 in steps of two, and the price per hour comes from the vCPU count. The response includes theid used by every later call.

{"ok":true,"data":{"id":"6f1c…","name":"build-box","status":"paused","vcpus":4}}

3. Start billing, and stop it

Resuming charges by the second. Pausing stops the charge at the moment the request is handled, and the machine keeps its disk.

curl -b jar.txt -X POST $ORIGIN/api/machines/6f1c…/resume
curl -b jar.txt -X POST $ORIGIN/api/machines/6f1c…/pause

Both take no body. The balance is checked on every metering pass; when it cannot cover the time being billed the machine pauses itself and the event is recorded with the reasoncredit_exhausted.

4. Add credit

The idempotency key is yours to choose and must be unique. It is what makes a double click one payment: the second request with the same key is refused as a duplicate rather than credited again.

curl -b jar.txt -X POST $ORIGIN/api/billing/topup \
  -H 'Content-Type: application/json' \
  -d '{"amountUsd":20,"idempotencyKey":"topup-2026-12-03-001"}'

Without a payment provider connected, a top-up credits the balance and no money is taken. That is deliberate and reported: GET /api/health shows payments: degraded. In production the credit is written from the provider's webhook, not from this request, so this endpoint becomes the one that asks for a payment.

5. Audit the books

Every dollar is traceable to the row that produced it. This returns the balance, the per-kind breakdown, and any problem with the rows themselves.

curl -b jar.txt $ORIGIN/api/billing/reconcile
{"ok":true,"data":{"balanceMicro":45000000,"agrees":true,"clean":true,
  "byKind":[{"kind":"grant","entries":1,"micro":25000000},
            {"kind":"topup","entries":1,"micro":20000000}]}}

409 means a row does not make sense: a top-up that debits, a duplicate reference, a row that records no money. The database refuses all of those on write, so a 409 means a row arrived through a path the constraints did not see, a restored dump, a migration, a replica.

Checking the deployment

Two endpoints answer different questions. Health answers "is this doing its job", and can say no while the process is alive.

curl $ORIGIN/api/health   # 200 working, 503 something broken
curl $ORIGIN/status/      # the same report, for a person

The check that matters is metering. If the ticker has not completed a pass in three intervals, a running machine is not being charged, and health answers 503 with that sentence. A status page that only tests the HTTP listener would have saidok throughout.

Deleting an account

Machines and their disks are removed, the identity is replaced with placeholders, and the money trail stays. The request needs the phrase typed, because a boolean is something a form library fills in by itself.

curl -b jar.txt -X POST $ORIGIN/api/account/delete \
  -H 'Content-Type: application/json' \
  -d '{"confirm":"delete my account"}'

The session stops working immediately rather than when the cookie expires. Signing in again with the same address creates nothing: the request answers as it always does, and no account appears.

Get the download link

Enter your email and we will send the download link when the signed build ships. Open it on a Mac with Apple Silicon.

One message when the build is signed. No newsletter.