Skip to contentSkip to navigationSkip to topbar
On this page

Send a Test Marketing Email



Operation overview

operation-overview page anchor

POST/v3/marketing/test/send_email

Base url: https://api.sendgrid.com (The Twilio SendGrid v3 API)

This endpoint allows you to send a test marketing email to a list of email addresses.

Before sending a marketing message, you can test it using this endpoint. You may specify up to 10 contacts in the emails request body field. You must also specify a template_id and include either a from_address or sender_id. You can manage your templates with the Twilio SendGrid App(link takes you to an external page) or the Transactional Templates API.

Please note that this endpoint works with Dynamic Transactional Templates only. Legacy Transactional Templates will not be delivered.

For more information about managing Dynamic Transactional Templates, see How to Send Email with Dynamic Transactional Templates.

You can also test your Single Sends in the Twilio SendGrid Marketing Campaigns UI(link takes you to an external page).


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Encoding type:application/json
SchemaExample
Property nameTypeRequiredDescriptionChild properties
template_idstring<uuid>required

The ID of the template that you would like to use. If you use a template that contains a subject and content (either text or HTML), then those values specified at the personalizations or message level will not be used.


version_id_overridestring<uuid>Optional

You can override the active template with an alternative template version by passing the version ID in this field. If this field is blank, the active template version will be used.


sender_idintegerOptional

This ID must belong to a verified sender. Alternatively, you may supply a from_address email.


custom_unsubscribe_urlstringOptional

A custom unsubscribe URL.


suppression_group_idintegerOptional

emailsarray[string<email>]required

An array of email addresses you want to send the test message to.


from_addressstring<email>Optional

You can either specify this address or specify a verified sender ID.

202400
Schema
Property nameTypeRequiredDescriptionChild properties

No properties defined

Send a Test Marketing EmailLink to code sample: Send a Test Marketing Email
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const data = {
5
template_id: "f8f77db8-b9fa-4b3c-9ee8-de3d582016b8",
6
version_id_override: "7734f757-8eb8-4d22-b7f0-779a72f32986",
7
sender_id: 6060664,
8
custom_unsubscribe_url: "https://example.com/unsubscribe",
9
suppression_group_id: 21865513,
10
emails: ["janedoe@example.com", "tiramisu@example.com", "bundt@example.com"],
11
};
12
13
const request = {
14
url: `/v3/marketing/test/send_email`,
15
method: "POST",
16
body: data,
17
};
18
19
client
20
.request(request)
21
.then(([response, body]) => {
22
console.log(response.statusCode);
23
console.log(response.body);
24
})
25
.catch((error) => {
26
console.error(error);
27
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.