How to Solve SendGrid's One Webhook URL Limit
SendGrid’s Event Webhook only allows for one webhook URL. However, you may want your webhooks to go to multiple services, for example email analytics on top of your servers.
In this article, I’ll explain how to bypass this limitation by duplicating and routing webhooks within Hookdeck.
How to add Hookdeck’s webhook URL on SendGrid
- Copy the source URL in Hookdeck.
- Paste the source URL in SendGrid.
Click Save.
Confirm Hookdeck receives SendGrid event webhooks.
How to duplicate webhooks with Hookdeck
Great! Now that you are receiving SendGrid’s webhook in Hookdeck, we’ll take advantage of the fanning-out behavior. To duplicate (or fan-out) the webhook to a second destination, follow the steps outlined below.
- Create a new Connection with the same
source
. - Trigger an Event to validate that the webhook was duplicated.
But what if you only want specific webhooks to reach a connection?
How to route webhooks with Hookdeck
By adding a filter (conditional logic in JSON), you can define the criteria and choose which webhooks will be delivered to a connection.
Example: Filter SendGrid webhooks based on status
Lets say you only want webhooks with the status “cancelled” delivered to your analytics connection. You will add this JSON as a filter to your connection for the following payload.
Hookdeck filter:
[
{
"event": "cancelled"
}
]
SendGrid webhook payload:
[
{
"email": "example@test.com",
"timestamp": 1669193462,
"smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
"event": "processed",
"category": ["cat facts"],
"sg_event_id": "r4EQlb4UpE6iho4_z-RmLQ==",
"sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0"
}
]
Hookdeck walkthrough:
Conclusion
In this article, you learned how to bypass SendGrid’s one webhook URL limitation. With Hookdeck we were able to use one webhook URL, and then duplicate and route webhooks to fit our use case.
With Hookdeck’s transformations, you can even change the payload before arriving to your destination! Read the docs here.