The SendGrid Event Webhook sends email event data as SendGrid processes it. This means you can receive data in nearly real-time, making it ideal to integrate with logging or monitoring systems.
Because the Event Webhook delivers data to your systems, it is also well-suited to backing up and storing event data within your infrastructure to meet your own data access and retention needs.
You can think about the types of events provided by the Event Webhook in two categories: deliverability events and engagement events.
Both types of events are important and should be monitored to understand the overall health of your email program. The Webhooks API allows you to configure your Event Webhook configurations.
Currently, data staged to be be posted through the webhooks is stored in the US.
This endpoint allows you to retrieve a single Event Webhook by ID.
If you do not pass a webhook ID to this endpoint, it will return your oldest webhook by created_date
. This means the default webhook returned by this endpoint when no ID is provided will be the first one you created. This functionality allows customers who do not have multiple webhooks to use this endpoint to retrieve their only webhook, even if they do not supply an ID. If you have multiple webhooks, you can retrieve their IDs using the Get All Event Webhooks endpoint.
Your webhook will be returned with all of its settings, which include the events that will be included in the POST request by the webhook and the URL where they will be sent. If an event type is marked as true
, the event webhook will send information about that event type. See the Event Webhook Reference for details about each event type.
The public_key
property will be returned only for webhooks with signature verification enabled.
You may share one OAuth configuration across all your webhooks or create unique credentials for each. The OAuth properties will be returned only for webhooks with OAuth configured.
Bearer <<YOUR_API_KEY_HERE>>
Optional
The on-behalf-of
header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID (e.g., on-behalf-of: account-id <account-id>
). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., on-behalf-of: <subuser-username>
). See On Behalf Of for more information.
The ID of the Event Webhook you want to retrieve.
Optional
Use this to include optional fields in the response payload. When this is set to include=account_status_change
, the account_status_change
field will be part of the response payload and set to false
by default. See Update an event webhook for enabling this webhook notification which lets you subscribe to account status change events related to compliance action taken by SendGrid.
Indicates if the Event Webhook is enabled.
The URL where SendGrid will send event data.
Indicates if the webhook is configured to send account status change events related to compliance action taken by SendGrid.
Indicates if the webhook is configured to send group resubscribe events. Group resubscribes occur when recipients resubscribe to a specific unsubscribe group by updating their subscription preferences. You must enable Subscription Tracking to receive this type of event.
Indicates if the webhook is configured to send delivered events. Delivered events occur when a message has been successfully delivered to the receiving server.
Indicates if the webhook is configured to send group unsubscribe events. Group unsubscribes occur when recipients unsubscribe from a specific unsubscribe group either by direct link or by updating their subscription preferences. You must enable Subscription Tracking to receive this type of event.
Indicates if the webhook is configured to send spam report events. Spam reports occur when recipients mark a message as spam.
Indicates if the webhook is configured to send bounce events. A bounce occurs when a receiving server could not or would not accept a message.
Indicates if the webhook is configured to send deferred events. Deferred events occur when a recipient's email server temporarily rejects a message.
Indicates if the webhook is configured to send unsubscribe events. Unsubscribes occur when recipients click on a message's subscription management link. You must enable Subscription Tracking to receive this type of event.
Indicates if the webhook is configured to send processed events. Processed events occur when a message has been received by Twilio SendGrid and is ready to be delivered.
Indicates if the webhook is configured to send open events. Open events occur when a recipient has opened the HTML message. You must enable Open Tracking to receive this type of event.
Indicates if the webhook is configured to send click events. Click events occur when a recipient clicks on a link within the message. You must enable Click Tracking to receive this type of event.
Indicates if the webhook is configured to send dropped events. Dropped events occur when your message is not delivered by Twilio SendGrid. Dropped events are accomponied by a reason
property, which indicates why the message was dropped. Reasons for a dropped message include: Invalid SMTPAPI header, Spam Content (if spam checker app enabled), Unsubscribed Address, Bounced Address, Spam Reporting Address, Invalid, Recipient List over Package Quota.
An optional friendly name assigned to the Event Webhook to help you differentiate it. The friendly name is for convenience only. You should use the webhook id
property for any programmatic tasks.
A unique string used to identify the webhook. A webhook's ID is generated programmatically and cannot be changed after creation. You can assign a natural language identifier to your webhook using the friendly_name
property.
The OAuth client ID SendGrid sends to your OAuth server or service provider to generate an OAuth access token.
The URL where SendGrid sends the OAuth client ID and client secret to generate an access token. This should be your OAuth server or service provider.
The public key you can use to verify the SendGrid signature.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const id = "ZGkrHSypTsudrGkmdpJJ";56const request = {7url: `/v3/user/webhooks/event/settings/${id}`,8method: "GET",9};1011client12.request(request)13.then(([response, body]) => {14console.log(response.statusCode);15console.log(response.body);16})17.catch((error) => {18console.error(error);19});
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const id = "ZGkrHSypTsudrGkmdpJJ";5const queryParams = {6include: "account_status_change",7};89const request = {10url: `/v3/user/webhooks/event/settings/${id}`,11method: "GET",12qs: queryParams,13};1415client16.request(request)17.then(([response, body]) => {18console.log(response.statusCode);19console.log(response.body);20})21.catch((error) => {22console.error(error);23});