Skip to contentSkip to navigationSkip to topbar
Rate this page:
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

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>>
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 Email

send-a-test-marketing-email page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_30
const client = require('@sendgrid/client');
_30
client.setApiKey(process.env.SENDGRID_API_KEY);
_30
_30
const data = {
_30
"template_id": "f8f77db8-b9fa-4b3c-9ee8-de3d582016b8",
_30
"version_id_override": "7734f757-8eb8-4d22-b7f0-779a72f32986",
_30
"sender_id": 6060664,
_30
"custom_unsubscribe_url": "https://example.com/unsubscribe",
_30
"suppression_group_id": 21865513,
_30
"emails": [
_30
"janedoe@example.com",
_30
"tiramisu@example.com",
_30
"bundt@example.com"
_30
]
_30
};
_30
_30
const request = {
_30
url: `/v3/marketing/test/send_email`,
_30
method: 'POST',
_30
body: data
_30
}
_30
_30
client.request(request)
_30
.then(([response, body]) => {
_30
console.log(response.statusCode);
_30
console.log(response.body);
_30
})
_30
.catch(error => {
_30
console.error(error);
_30
});


Rate this page: