Webhook Events
Summary
The Lead Post Webhook Notifications feature allows users to receive real-time updates about various lead post events. By setting up webhooks, users can get notified instantly when these events occur, with detailed information sent to their specified URLs.
Key Features
Event Notifications
- Receive notifications for lead post events.
Customizable Webhooks
- Configure webhooks with specific URLs to receive event notifications.
- Add custom headers to webhook requests for authentication or other purposes.
- Configure rulesets to filter webhook requests based on lead field conditions.
Detailed Payload
- Each webhook notification includes a payload with detailed information about the event, such as the result, message, and customized lead details.
How It Works
Set Up Webhooks:
- Users can set up webhooks by specifying the URL where they want to receive notifications under Account settings.
- Optionally, users can add custom headers for the webhook requests.
Signing Requests: When setting up, please create a random secret to sign webhook requests. Generating the secret could be a uuid or some other form of random sequence. The package will use the secret to sign all webhook calls.
By default, the package will add a header called Signature that will contain a signature the receiving app can use if the payload hasn't been tampered with. This is how that signature is calculated:
$payloadJson = json_encode($payload);
$signature = hash_hmac('sha256', $payloadJson, $secret);
if $signature === $headers['Signature'] the payload has not been tampered.
Subscribe to Events
- Users can subscribe to specific lead post events they are interested in.
Receive Notifications
- When a subscribed event occurs, a webhook notification is sent to the configured URL.
- The notification includes a payload with the event details.
Retrying Failed Webhooks When the app to which we're sending the webhook fails to send a response with a 2xx status code the request will be considered failed. The call will also be considered failed if the app doesn't respond within 3 seconds.
When a webhook call fails, we'll retry the call two more times. To not hammer the remote app we'll wait some time between each attempt. By default, we wait 10 seconds between the first and second attempts, 100 seconds between the third and the fourth, 1000 between the fourth and the fifth, and so on. The maximum amount of seconds that we'll wait is 100 000, which is about 27 hours.
Example Payload
When a lead post event occurs, the webhook notification will include a payload like this:
{
"result": "accepted",
"message": "Lead post was accepted.",
"lead": {
"id": 12345,
"is_organic": true
}
}