Skip to contentSkip to navigationSkip to topbar
On this page

Test Event Notification Settings



API Overview

api-overview page anchor

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.

  • Deliverability events such as "delivered," "bounced," and "processed" help you understand if your email is being delivered to your customers.
  • Engagement events such as "open," and "click" help you understand if customers are reading and interacting with your emails after they arrive.

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.


POST/v3/user/webhooks/event/test

Base url: https://api.sendgrid.com (for global users and subusers)

Base url: https://api.eu.sendgrid.com (for EU regional subusers)

This endpoint allows you to test an Event Webhook.

Retry logic for this endpoint differs from other endpoints, which use a rolling 24-hour retry.

This endpoint will make a POST request with a fake event notification to a URL you provide. This allows you to verify that you have properly configured the webhook before sending real data to your URL.

Test OAuth configuration

test-oauth-configuration page anchor

To test your OAuth configuration, you must include the necessary OAuth properties: oauth_client_id, oauth_client_secret, and oauth_token_url.

If the webhook you are testing already has OAuth credentials saved, you will provide only the oauth_client_id and oauth_token_url—we will pull the secret for you. If you are testing a new set of OAuth credentials that have not been saved with SendGrid, you must provide all three property values.

You can retrieve a previously saved oauth_client_id and oauth_token_url from the Get an Event Webhook endpoint; however, for security reasons, SendGrid will not provide your oauth_client_secret.


Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>

on-behalf-ofstring

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.

Encoding type:application/json
SchemaExample
Property nameTypeRequiredDescriptionChild properties
idstring

Optional

The ID of the Event Webhook you want to retrieve.


urlstringrequired

The URL where you would like the test notification to be sent.


oauth_client_idstring or null

Optional

The client ID Twilio SendGrid sends to your OAuth server or service provider to generate an OAuth access token. When passing data in this property, you must also include the oauth_token_url property.


oauth_client_secretstring or null

Optional

The oauth_client_secret is needed only once to create an access token. SendGrid will store this secret, allowing you to update your Client ID and Token URL without passing the secret to SendGrid again. When passing data in this field, you must also include the oauth_client_id and oauth_token_url properties.


oauth_token_urlstring or null

Optional

The URL where Twilio SendGrid sends the Client ID and Client Secret to generate an access token. This should be your OAuth server or service provider. When passing data in this field, you must also include the oauth_client_id property.

204

No Content

Test Event Notification SettingsLink to code sample: Test Event Notification Settings
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const data = {
5
id: "77d4a5da-7015-11ed-a1eb-0242ac120002",
6
url: "https://emailengagment.example.com",
7
oauth_client_id: "a835e7210bbb47edbfa71bdfc909b2d7",
8
oauth_client_secret: "335a9b0c65324fd2a62e2953d4b158",
9
oauth_token_url: "https://oauthservice.example.com",
10
};
11
12
const request = {
13
url: `/v3/user/webhooks/event/test`,
14
method: "POST",
15
body: data,
16
};
17
18
client
19
.request(request)
20
.then(([response, body]) => {
21
console.log(response.statusCode);
22
console.log(response.body);
23
})
24
.catch((error) => {
25
console.error(error);
26
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.