Idempotency

If your server ever responds with a 5xx HTTP error, or there was an error on the HTTP connection, City Connect will retry the same request. It is important therefore for any requests that will potentially change the state of your system (e.g. booking and reservation requests), to implement our Idempotency-Key header.

The way it works, is we will provide a unique UUID as a HTTP header for each request. If the request fails, we'll retry the exact same request with the same Idempotency-Key. Your server should be aware of this and be sure not to retry the same request twice, as this could lead to double bookings.

POST /your-server/reservation HTTP/1.1
Host: www.example.com
Idempotency-Key: 5352b1f5-cf41-4503-b84b-c31b4e13c040
Content-Type: application/json

{
  "agent": "viator.com",
  "product": "WINETOUR",
  "option": "WITHLUNCH",
  "time_slot": "10:30",
  "date": "2017-10-07",
  "adult": 2,
  "child": 1,
  "expires": "2017-03-18T21:24:50Z"
}

Note we will only send a Idempotency-Key for POST, PUT, PATCH and DELETE requests.

When you respond to a second request that contains the same Idempotency-Key, you MUST respond with exactly the same body and headers.