Idempotency
Networks fail. If your request times out you can't know whether the booking happened. Send an Idempotency-Key header with POST /bookings and retry safely:
curl -X POST https://sandbox-api.flyrail.space/v1/bookings -H "Idempotency-Key: order-1001-attempt-1" ...
- Same key, same request: you get the first answer again with
Idempotent-Replayed: true. Nothing is booked twice and you are charged once. - Same key, different request:
422 idempotency_key_reuse. - The first request is still running:
409 request_in_progress. Retry in a moment.
Use a value you can reconstruct (your order id plus an attempt number), 8 to 80 characters of letters, digits and - _ : .. Keys are remembered for 24 hours and are separate per API key.
The header is required on POST /bookings; without it you get 400 idempotency_key_required.