Staying in sync
Don't re-crawl everything. Read the change feed or subscribe to webhooks, and refetch only what changed.
Don't re-crawl everything. Read the change feed or subscribe to webhooks, and refetch only what changed.
| Event | What to do |
|---|---|
availability.changed, rates.changed | Refresh that room type's dates. |
property.updated | Refetch /properties/{code}. |
reservation.* | Your own bookings changed, including changes made at the property. |
Public events (rates, availability, content, promotions and reviews) are visible to every partner. Reservation and group-request events are visible only to the partner that owns them.
GET /changes is an append-only, ordered feed of events.
Start from zero
Call GET /changes?since=0 and process the events in order.
Store the cursor
Save meta.next_cursor and pass it as since next time. Keep calling straight away while meta.has_more is true.
Poll every minute or two
Narrow the feed with types (for example availability.changed,rates.changed) or property. limit goes up to 500.
curl "https://api.konghotels.cloud/changes?since=0&types=availability.changed,rates.changed&limit=100" \
-H "apikey: $KONG_HOTELS_API_KEY"
Create a subscription with POST /webhooks, and we push the same event envelope used by /changes to your endpoint. Send a test event with POST /webhooks/{webhookId}/ping, and inspect attempts with GET /webhooks/{webhookId}/deliveries. GET /webhooks/event-types lists every event type.
Each delivery is a POST with these headers:
| Header | Value |
|---|---|
Kong-Event | The event type |
Kong-Delivery | A unique delivery ID. Use it to de-duplicate. |
Kong-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256> |
Respond with any 2xx within 10 seconds. Failed deliveries are retried with backoff (30 s, 2 min, 10 min, 30 min, 1 h) before being marked failed.
Compute HMAC_SHA256(secret, "<t>.<raw request body>") and compare it with v1 in constant time. Reject deliveries where t is more than 5 minutes old.
[$t, $v1] = sscanf($_SERVER['HTTP_KONG_SIGNATURE'], 't=%d,v1=%s');
$valid = hash_equals(hash_hmac('sha256', $t.'.'.file_get_contents('php://input'), $secret), $v1)
&& abs(time() - $t) < 300;