Coasty/

Developer API

Machines

Status, start/stop, managed destroy, external revoke, and runtime billing

Lifecycle & TTL

Lifecycle & TTL, at a glance

Status, start/stop, managed destroy, external revoke, and runtime billing

PATCH /v1/machines/{id}
Managed machines move through explicit lifecycle states, meter runtime by state, and terminate automatically when their TTL expires.

The power-state lifecycle applies to kind: managed. On an external machine, owner-authenticated start, stop, and restart are logical dispatch gates: they increment the fencing generation and cancel outstanding commands, but never power the caller-owned host on or off. External machines use connection_status, cannot be snapshotted, and are not billed for runtime. A managed machine moves through a small set of statuses. status is the field you poll: drive the machine only while it is running. The runtime rate that applies in each status is shown below; exact per-hour USD numbers are in the Pricing section.

StatusBilledMeaning
creatingFreeProvisioned and booting. The cloud instance is coming up and getting an IP; not yet drivable. Poll until running.
runningRunning rateUp and ready. Connection details are populated and actions/runs can target it. This is the only status from which work executes.
startingRunning rateA stopped machine is booting back up after POST /start. Transitional — bills at the running rate. Poll until running.
stoppingRunning rateShutting down after POST /stop. Transitional — bills at the running rate until it settles into stopped.
restartingRunning rateRebooting after POST /restart. Transitional.
stoppedStopped ratePowered off but preserved (disk + snapshots kept). Bills the low keep-alive rate. Start it again with POST /start.
suspendedStopped rateAuto-stopped because the API wallet emptied mid-run. Identical to stopped; data is preserved. Top up the wallet and start it again.
errorFreeProvisioning or a lifecycle action failed. Not billed. You can start (retry) or terminate it.
terminatedFreeThe Coasty resource is gone and a later GET returns 404. Managed infrastructure is destroyed; external registration/device access is revoked while caller-owned host and storage remain untouched.

Start, stop, restart are POST /v1/machines/{id}/start (and /stop, /restart). Managed-machine power changes are asynchronous: the call returns a transitional status (starting / stopping) and you poll until it settles. External logical gates commit immediately and return running or stopped. They are state-checked — starting a machine that is already running, or stopping one that is not running, returns 409 INVALID_STATE with current_state and allowed_from in the body, so you can react without guessing. start is allowed from stopped or error; stop only from running.

Terminate with DELETE /v1/machines/{id}. For a managed machine this permanently tears down the VM and its disk. For an external machine it revokes only the Coasty registration, device token, and outstanding command leases; the caller-owned host and storage remain untouched. A later GET returns 404 MACHINE_NOT_FOUND. Delete is idempotent, so an exact retry after an already-completed deletion is safe.

curl — stop, then terminate
curl -X POST https://coasty.ai/v1/machines/$MACHINE_ID/stop   -H "X-API-Key: $COASTY_API_KEY"
curl -X DELETE https://coasty.ai/v1/machines/$MACHINE_ID       -H "X-API-Key: $COASTY_API_KEY"

Auto-destroy / auto-revoke (TTL). A managed machine left running bills until you destroy it, so set ttl_minutes as a safety net. A background sweep (every ~60s) terminates managed infrastructure once its auto_destroy_at passes. On an external machine, expiry revokes only its Coasty registration/token/leases and never powers off or deletes the host or its storage. Adjust it any time with PATCH /v1/machines/{id}: ttl_minutes is measured from now (so it doubles as a lease extension), accepts 510080 (5 min to 7 days), and 0 clears auto-destroy entirely. Anything else is 400 INVALID_TTL. Provisioning without a TTL works but adds a Warning response header nudging you to set one.

curl — extend the lease to 30 more minutes (0 to disable)
curl -X PATCH https://coasty.ai/v1/machines/$MACHINE_ID \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ttl_minutes": 30}'

Runtime billing. Machines bill the developer API wallet (separate from any subscription credits) by the minute, rounded down to whole credits in your favour. Published defaults are running Linux $0.05/hr, running Windows $0.09/hr, and a stopped or suspended machine the keep-alive rate of $0.01/hr; creating, error, and terminated are free. Transitional states (starting/stopping/restarting) bill at the running rate. The per-call control endpoints (actions, terminal, files, browser, screenshot, connection) are never billed. Managed-machine metering consists of runtime plus the separate one-time snapshot charge.

If the API wallet empties while a machine is running, the next sweep stops it (status becomes suspended) rather than destroying it — your disk and snapshots are preserved. Top up the wallet and POST /start to resume. You can watch live accrual for every metered machine at GET /v1/billing/active.
API reference — Coasty Computer Use API | Coasty - AI Computer-Use Agent