Retry creation without losing the machine
Your launch request times out. The machine might already be running; you just didn’t get the reply. Sending another request with a fresh key can leave you paying for two machines while your agent knows about only one. Mainbrella’s creation API accepts an Idempotency-Key so the retry can find the original reservation.
One key per launch
Generate a key when you decide to launch a machine, then keep it with the exact image selection. If the response is missing or unclear, repeat the same POST body and key. The documented reservation window is 24 hours. Generating a new UUID on each retry turns a recovery attempt into another launch.
POST /containers
Authorization: Bearer mb_<your-key>
Content-Type: application/json
Idempotency-Key: <one-key-for-this-launch>
{"catalogId":"node"}
A keyed request returns a creation record. Wait for its status to become running, then match creation.containerId and creation.createdAt to a running entry in containers. Picking the first machine in the list is a nasty shortcut: it might belong to another task.
The slot can hold a different machine tomorrow
The container ID names a slot in your account. After a stop, we can reuse that slot for a new instance. Keep the exact returned createdAt timestamp alongside the ID. Together they identify the machine you launched, and both belong on requests to execute commands, transfer files, issue SSH access, or delete it.
Suppose a cleanup request arrives late, after another agent has put a new machine in that slot. Deleting by slot alone could kill the replacement. With the timestamp, the server can recognize the request as stale and reject it. Use URL utilities to construct query strings; timestamps and file paths need proper encoding.
Cleanup shouldn’t guess
Our verification script retries creation up to three times with the same key. It proceeds only after matching the creation record to a running instance, then deletes that exact instance in finally. Our agent skill gives coding agents the same instructions for selecting and cleaning up their machines.
If those attempts still leave creation unresolved, the report keeps the key for manual reconciliation. It doesn’t grab a machine from the account list and delete it to tidy up. If cleanup itself fails, the report keeps the known ID and timestamp so the caller can recover.
Be more careful when retrying commands
The creation key applies to launching a machine. It doesn’t make commands safe to repeat. An execution response can disappear after a write or deployment has succeeded, and rerunning the command can repeat its side effects. Check the resulting files or application state before retrying a mutation.