VANITYPASS
B2B API

Idempotency

How to ensure safe retries with idempotency keys.

Idempotency

Some endpoints support idempotency: if you retry a request with the same Idempotency-Key, the server returns the cached response instead of processing the request twice.

Endpoints Supporting Idempotency

  • POST /v1/travel/bookings (booking creation)
  • POST /v1/hotel/booking/initiate
  • POST /v1/hotel/booking/pay
  • POST /v1/travel/experiences/bookings/hold
  • (Check endpoint documentation for the idempotency-key field)

How It Works

  1. Generate a unique ID (UUID v4 or similar) for your idempotency key.
  2. Include the header:
    Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
  3. Send the request. Server processes it and caches the response.
  4. Retry with the same key. Server returns the cached response without re-processing.

Expiration

Idempotency cache is valid for 24 hours. After that, the same key will be treated as a new request.

Example

curl -X POST https://cloud.vanitypass.com/v1/travel/bookings \
  -H 'X-Api-Key: vp_test_...' \
  -H 'Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000' \
  -d '{...}'

# If the network drops, retry with the same Idempotency-Key.
# You get the same response without double-charging.