How can an application subscribe to a webhook?
A webhook can be created by an administrator or an external application can subscribe to a webhook via the API.
Request via the API
Several methods are available for registering a webhook.
In all cases a valid connection needs to be setup. Oauth 2.0 is the recommended way.
If a valid connection is created and the administrator has the correct rights, an application can register a webhook.
Usually a unique URL is created for receiving a webhook.
The application is telling i-Reserve where the data needs to be delevered.
The application can also delete the webhook (unsubscribe). The available methods in the API are:
- POST hook
- POST hook/subscribe/{event}
- DELETE hook/{id}
The two methods for subscribing to a webhook are different in syntax but create the same result.
This is needed for the available methods used on several integration platforms.
Example integration
Zapier is an example of an integration platform which is using webhooks as the method of integrating.
The platform is based on zaps, which contain triggers and actions.
An example of a trigger is "Booking created" which is executed when a booking is made in i-Reserve.
In Zapier setup this trigger needs to be configured.
In the trigger settings there is a possibility to setup a "REST Hook Subscribe URL".
The URL to enter here is "https://{{endpoint}}/api/rest/hook/" where {{endpoint}} is the base URL of the requested i-Reserve environment.
At the moment that Zapier is activating a Zap a POST request is fired to the i-Reserv API hook method
The event is "booking_created" and target_url: "https://hooks.zapier.com/hooks/standard/2925541/4be1a53be005409fae79c272360cf7ae/"
From that moment on the bookings are pushed to the target_url
Zaper can then be configured for an action to another application. .