Retrying a capped booking
If the reply to a booking is lost, repeat only that request with the same key and arguments. Do not start a second booking. The resource endpoint gives you current status.
If the connection drops or times out before you get an answer to create_instance or submit_job, you do not know whether X9 booked it. Send the same call with the same arguments, the same API credential, and the same idempotency_key (the Idempotency-Key header over HTTP). Save that key before sending the first request. If X9 already booked it, the replay returns the original resource ID and marks the answer idempotent_replay: true. It does not book another rental or reserve more money.
Once you have the ID, poll get_resource for the current status. The replayed booking answer can still say booting because it is the original answer. If you get a definite refusal, read the error and its suggested next steps. Use a fresh idempotency key only for a new booking that you mean to make, not to recover an answer you missed.
Set max_spend_usd on the quote, or on submit_job if you submit requirements instead of a quote. A hold is money set aside for this booking. Charges use that hold, so count what has been charged plus what is still held, not the original hold plus the charges. The booking limit is separate from the agent credential's spending limit across bookings.
When a job loses its host
The two kinds of retry are different. Resending the same request recovers the original booking result. Setting allow_retry_on_other_host: true lets X9 run that same job once more on a suitable replacement if the first host is lost before any output was saved. X9 cancels the first attempt's charges and reuses the original hold. The replacement can incur normal charges within that same cap. If no eligible replacement is available, the job can wait for capacity. If the wait expires, the job fails and X9 releases the remaining hold. Check the end reason on the original resource. Keep polling the original resource ID instead of submitting a new job. Opt in only if another host may receive the job and it's safe for the job itself to run again. Cancelling charges does not undo work the first attempt already did.