REST Hooks are an alternative to polling. The main differences are allowing your customers’ Zaps to trigger instantly; and avoiding polling triggers’ numerous - and sometimes unnecessary - requests to your API’s endpoints to check for new data.
expiration_date
property containing an ISO8601 date. The platform will automatically attempt to resubscribe after the expiration date.subscribeHook
function is called with a payload of data that includes the unique URL to send data to in order to trigger the Zap. Store this URL, associating it with an id and use it whenever you want to trigger this Zap. Return that id in the response back to Zapier to be used later in the Unsubscribe.
When the Zap is turned off, the unsubscribeHook
function is called to notify your app to delete the unique URL previously stored for this Zap.
subscribeHook
FunctionsubscribeHook
function which provides the URL you will use to trigger the Zap. Include the following parameters:
url
should be bundle.targetUrl
which is an URL Zapier automatically generates for each activated Zap.performSubscribe
method on the module for the Trigger:
unsubscribeHook
FunctionunsubscribeHook
function which will be called when a Zap is turned off. This notifies your servers to delete the URL you’ve been storing and stop sending payloads to it. If your API continues posting notification payloads to the Zap after it has unsubscribed, you can expect to see a 410 response from Zapier.
bundle.subscribeData.id
is required — this is the ID of the hook in question. You could assign it to a hookID
variable or similar.
Include the following parameters:
performUnsubscribe
method on the module for the Trigger:
perform
Functionperform
function which is called each time your app delivers a notification payload to Zapier. This is what actually triggers the Zap. Typically, you would simply return the cleaned request in an array. The data returned by the request must be an array.
performList
FunctionperformList
function, used when testing the Trigger to collect sample data in the Zap editor. Though optional, not defining a performList is a sub-optimal experience for users and is required for public apps.
Most commonly this is a GET request to an endpoint of your API which will provide a response from the user’s account with the exact same schema as the data delivered via webhook when a trigger event happens.
Response data returned must be an array, even if the array contains only one object. It must have the exact same schema as the data delivered via webhook when a trigger event happens otherwise fields mapped from this sample in subsequent steps of a Zap will break when it runs live.
subscribeHook
targetUrl
parameter and store it securely as this URL is used to send data from your app to Zapier when the triggering event occurs, and thus trigger the Zap. You can see an example of this here.
unsubscribeHook
targetUrl
parameter. You need to deactivate or delete the URL from your storage completely as the Zap associated will no longer trigger when requests are made to it. If your API continues posting notification payloads to the Zap after it has unsubscribed, you can expect to see a 410 response from Zapier. You can see an example of this here.
perform
HTTP
request has to made here. As seen in the example app here, this can simply take the data from bundle.cleanedRequest
and build a new object that is returned within an array. It’s important to return this object within an array as specified here.
performList
performList
, not perform
. performList
ideally should make a HTTP
request to an endpoint that can return sample data to be mapped into subsequent steps of the user’s Zap. You can see an example of this here. Required for public apps and highly recommended for private apps to avoid user confusion when setting up a Zap.