Webhooks

In this guide, we will look at how to receive booking updates via webhooks from TripEdge. With webhooks, your app can be notified when booking statuses change.

Registering webhooks

To register a webhook endpoint, contact your account manager with the URL where you want to receive webhook notifications. You will receive a security key to verify incoming webhook requests.

Consuming webhooks

When TripEdge sends a webhook to your endpoint, check the event_type field to determine what happened. The payload contains the updated booking data.

Example webhook payload

{
  "data": {
    "event_type": "bookings.changed",
    "data": [
      {
        "id": 98765,
        "status": "confirmed",
        "booking_reference": ["HTL123456"],
        "hotel_id": 12345,
        "check_in": "2024-03-15",
        "check_out": "2024-03-18",
        "first_name": "John",
        "last_name": "Smith",
        "price_chargeable": 450.00,
        "price_currency": "USD"
      }
    ]
  },
  "success": true,
  "message": null
}

Event types

  • Name
    bookings.changed
    Description

    A booking was created, updated, or had its status changed. This includes confirmations, cancellations, and commission updates.


Security

To verify that a webhook was sent by TripEdge, check the x-security-key header against the secret key provided by your account manager.

Verifying a request

const securityKey = req.headers['x-security-key']

if (securityKey === process.env.TRIPEDGE_WEBHOOK_SECRET) {
  // Request is verified
  const { event_type, data } = req.body.data
  // Process the webhook...
} else {
  // Request could not be verified
  res.status(401).send('Unauthorized')
}

Keep your webhook secret key safe and never commit it to version control.

Was this page helpful?