Layerbeat
Guides

Quickstart

The whole flow in `curl`. Each step is explained in the reference below.

The whole flow in curl. Each step is explained in the reference below.

# 1. Create an account. The response contains a session token (shown once).
curl -s -X POST $BASE/v1/auth/signup -H 'Content-Type: application/json' \
  -d '{"email":"you@example.com","password":"a long passphrase","org_name":"My Company"}'
export SESSION=lb_sess_...            # from the response: session.token

# 2. Create an API key for your program (the key is shown once).
curl -s -X POST $BASE/v1/api-keys -H "Authorization: Bearer $SESSION" -H 'Content-Type: application/json' \
  -d '{"name":"ci","scopes":["vm:read","vm:write","ssh_key:read","ssh_key:write","billing:read","billing:write"]}'
export KEY=lb_live_...                # from the response: key

# 3. Top up credit first. Pay using the returned instructions, then wait for confirmed credit.
curl -s -X POST $BASE/v1/billing/top-ups -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" -d '{"method":"usdc_solana","amount":"25.00"}'
export PAY=pay_...                   # from the response: id
curl -s $BASE/v1/billing/payments/$PAY -H "Authorization: Bearer $KEY"
curl -s $BASE/v1/billing/wallet -H "Authorization: Bearer $KEY" # only available credit can be spent

# 4. Register your SSH public key.
curl -s -X POST $BASE/v1/ssh-keys -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"name\":\"laptop\",\"public_key\":\"$(cat ~/.ssh/id_ed25519.pub)\"}"
export SSH_KEY_ID=key_...             # from the response: id

# 5. Browse the catalog (no authentication needed) and price a server.
curl -s "$BASE/v1/plans?region=sgp"
curl -s -X POST $BASE/v1/quotes -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"region":"sgp","plan":"small","image":"ubuntu-24-04","term_months":1}'

# 6. Buy the server from available credit. The price is held from your prepaid wallet; creation is asynchronous.
curl -s -X POST $BASE/v1/vms -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" \
  -d "{\"name\":\"web-1\",\"region\":\"sgp\",\"plan\":\"small\",\"image\":\"ubuntu-24-04\",\"term_months\":1,\"ssh_key_ids\":[\"$SSH_KEY_ID\"]}"
export OP=op_...  VM=vm_...          # from the response: operation.id, vm.id

# 7. Wait until the operation succeeds, then read the server's IP address.
curl -s $BASE/v1/operations/$OP -H "Authorization: Bearer $KEY"      # repeat until status is "succeeded"
curl -s $BASE/v1/vms/$VM -H "Authorization: Bearer $KEY"             # ipv4 is set when running

# 8. Connect (password login is disabled; only your SSH key works).
ssh root@<ipv4>

A new user starts with zero personal credit. Complete a top-up before purchasing a VM; an unfunded request returns 402 insufficient_balance and creates no VM or operation. A top-up never submits a purchase automatically.