Create a SendGrid Event Webhook receiver
You can create an iHook receiver to receive SendGrid Event Webhooks, and send email/Slack notifications whenever a SendGrid event is fired.
1. Create receiver
After signing into the iHook dashboard, go to the Receiver
tab, and click the CREATE RECEIVER
button at the top left corner:
A new receiver will be created. Under the Receiver Settings
section, you can see the receiver's unique URL, which you will use to receive SendGrid events. The endpoint accepts GET
and POST
requests.
Click the EDIT
button at the top right corner of the Receiver Settings
section, and provide the following values:
Field | Value | Description |
---|---|---|
Name | SendGrid webhook receiver | The name of the receiver. |
Status Code | 200 | The response status code of the endpoint. |
Content Type | text/plain | The response content type of the endpoint. The value will appear in response header content-type |
Response Body | The response body to be sent back to SendGrid. You may leave this field as empty. |
Then click SAVE
. With the new settings, the receiver will respond to HTTP callers (SendGrid) with a 200
status code and empty response body.
2. Setup notification
Next let us set up an email notification, so we can be notified whenever the receiver gets a SendGrid event.
Under the Notification
section, click on ADD
button next to Email
label:
Then a notification setup dialog will show up:
Enter your email address, and click SAVE
, you will see the new notification appear under the Notification
section.
Note that in the message template, you can use JSON path expression to extract desired objects/properties in ${requestBody}
, e.g. ${requestBody[0]}
.
3. Register a SendGrid Event Webhook
Now you can register your receiver URL in your SendGrid account. Go to your SendGrid Event Webhook setting page (Settings -> Mail Settings -> Event Webhook), provide the following values:
Field | Value | Description |
---|---|---|
Authorization Method | None | No authorization method. |
HTTP Post URL | https://ihook.us/receivers/{your-receiver-unique-id} | The iHook receiver URL. |
Deliverability Data | Dropped and Bounced | Tells SendGrid to notify the iHook receiver whenever an SendGrid email delivery is dropped or bounced. |
Then click Test Your Integration
, you should receive an email that contains the test data generated by the SendGrid event webhook.
Finally, toggle the SendGrid Event Webhook status to ENABLED
, and click Save
.
Congratulations! You've successfully created a receiver that accepts SendGrid Event Webhooks, with email notification enabled!