provider Mail Send POST /mail/send
@utdk/sendgrid /mail/send
v3 Mail Send
The Mail Send endpoint allows you to send email over SendGrid’s v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). ## Helper Libraries Twilio SendGrid provides libraries to help you quickly and easily integrate with the v3 Web API in 7 different languages: * [C#](https://github.com/sendgrid/sendgrid-csharp) * [Go](https://github.com/sendgrid/sendgrid-go) * [Java](https://github.com/sendgrid/sendgrid-java) * [Node JS](https://github.com/sendgrid/sendgrid-nodejs) * [PHP](https://github.com/sendgrid/sendgrid-php) * [Python](https://github.com/sendgrid/sendgrid-python) * [Ruby](https://github.com/sendgrid/sendgrid-ruby) ## Dynamic Transactional Templates and Handlebars In order to send a dynamic template, specify the template ID with the `template_id` parameter. To specify handlebar substitutions, define your substitutions in the request JSON with this syntax: ``` "dynamic_template_data": {       "guest": "Jane Doe",       "partysize": "4",       "english": true,       "date": "April 1st, 2021"     } ``` For more information about Dynamic Transactional Templates and Handlebars, see our documentation and reference pages. * [How to send an email with Dynamic Transactional Templates ](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/) * [Using Handlebars](https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/) ## Mail Body Compression Mail body compression is available to some high volume accounts. Talk to your CSM if you are interested in this functionality. Mail body compression works by setting up a JSON payload as defined on this page, then compressing it with gzip (the gzip file can be no more than 30mb). To use mail body compression: 1. Add a `Content-Encoding` header, with a value of `gzip`. a. `Content-Encoding: gzip` 2. Send the gzip as a data-binary. a. `--data-binary '@data.json.gz' ` ## Multiple Reply-To Emails Using `reply_to_list` allows senders to include more than one recipient email address to receive reply and/or bounce messages from the recipient of the email. ### Usage Considerations * `reply_to` is mutually exclusive with `reply_to_list`. If both are used, then the API call will be rejected. * The `reply_to_list` object, when used, must at least have an email parameter and may also contain a name parameter. * Each email address in the `reply_to_list` should be unique. * There is a limit of 1000 `reply_to_list` emails per mail/send request. * In SMTP calls, we will omit any invalid emails. ### Possible 400 Error Messages * `reply_to` is mutually exclusive with `reply_to_list`. * The `reply_to_list` object, when used, must at least have an email parameter and may also contain a name parameter. * Each email address in the `reply_to_list` should be unique. * There is a limit of X `reply_to` emails per mail/send request. * The `reply_to_list` email does not contain a valid address. * The `reply_to_list` email exceeds the maximum total length of X characters. * The `reply_to_list` email parameter is required.

Try it

Authentication
Configure credentials for Email Activity (beta)
Gateway
The gateway proxies requests and injects credentials server-side. Configure credentials above, then enter your gateway URL.

Saved automatically to browser storage.

postMailSend
POST/mail/send
The Mail Send endpoint allows you to send email over SendGrid’s v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). ## Helper Libraries Twilio SendGrid provides libraries to help you quickly and easily integrate with the v3 Web API in 7 different languages: * [C#](https://github.com/sendgrid/sendgrid-csharp) * [Go](https://github.com/sendgrid/sendgrid-go) * [Java](https://github.com/sendgrid/sendgrid-java) * [Node JS](https://github.com/sendgrid/sendgrid-nodejs) * [PHP](https://github.com/sendgrid/sendgrid-php) * [Python](https://github.com/sendgrid/sendgrid-python) * [Ruby](https://github.com/sendgrid/sendgrid-ruby) ## Dynamic Transactional Templates and Handlebars In order to send a dynamic template, specify the template ID with the `template_id` parameter. To specify handlebar substitutions, define your substitutions in the request JSON with this syntax: ``` "dynamic_template_data": {       "guest": "Jane Doe",       "partysize": "4",       "english": true,       "date": "April 1st, 2021"     } ``` For more information about Dynamic Transactional Templates and Handlebars, see our documentation and reference pages. * [How to send an email with Dynamic Transactional Templates ](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/) * [Using Handlebars](https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/) ## Mail Body Compression Mail body compression is available to some high volume accounts. Talk to your CSM if you are interested in this functionality. Mail body compression works by setting up a JSON payload as defined on this page, then compressing it with gzip (the gzip file can be no more than 30mb). To use mail body compression: 1. Add a `Content-Encoding` header, with a value of `gzip`. a. `Content-Encoding: gzip` 2. Send the gzip as a data-binary. a. `--data-binary '@data.json.gz' ` ## Multiple Reply-To Emails Using `reply_to_list` allows senders to include more than one recipient email address to receive reply and/or bounce messages from the recipient of the email. ### Usage Considerations * `reply_to` is mutually exclusive with `reply_to_list`. If both are used, then the API call will be rejected. * The `reply_to_list` object, when used, must at least have an email parameter and may also contain a name parameter. * Each email address in the `reply_to_list` should be unique. * There is a limit of 1000 `reply_to_list` emails per mail/send request. * In SMTP calls, we will omit any invalid emails. ### Possible 400 Error Messages * `reply_to` is mutually exclusive with `reply_to_list`. * The `reply_to_list` object, when used, must at least have an email parameter and may also contain a name parameter. * Each email address in the `reply_to_list` should be unique. * There is a limit of X `reply_to` emails per mail/send request. * The `reply_to_list` email does not contain a valid address. * The `reply_to_list` email exceeds the maximum total length of X characters. * The `reply_to_list` email parameter is required.

Input

An object allowing you to specify how to handle unsubscribes.

An array of objects where you can specify any attachments you want to include.

An ID representing a batch of emails to be sent at the same time. Including a `batch_id` in your request allows you include this email in that batch. It also enables you to cancel or pause the delivery of that batch. For more information, see the [Cancel Scheduled Sends API](https://sendgrid.com/docs/api-reference/).

An array of category names for this message. Each category name may not exceed 255 characters.

required

An array where you can specify the content of your email. You can include multiple [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of content, but you must specify at least one MIME type. To include more than one MIME type, add another object to the array containing the `type` and `value` parameters.

Values that are specific to the entire send that will be carried along with the email and its activity data. Key/value pairs must be strings. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This parameter is overridden by `custom_args` set at the personalizations level. Total `custom_args` size may not exceed 10,000 bytes.

required

An object containing key/value pairs of header names and the value to substitute for them. The key/value pairs must be strings. You must ensure these are properly encoded if they contain unicode characters. These headers cannot be one of the reserved headers.

The IP Pool that you would like to send this email from.

A collection of different mail settings that you can use to specify how you would like this email to be handled.

required

An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled. See our [Personalizations documentation](https://sendgrid.com/docs/for-developers/sending-email/personalizations/) for examples.

An array of recipients who will receive replies and/or bounces. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name. You can either choose to use “reply_to” field or “reply_to_list” but not both.

A unix timestamp allowing you to specify when you want your email to be delivered. This may be overridden by the `send_at` parameter set at the personalizations level. Delivery cannot be scheduled more than 72 hours in advance. If you have the flexibility, it's better to schedule mail for off-peak times. Most emails are scheduled and sent at the top of the hour or half hour. Scheduling email to avoid peak times — for example, scheduling at 10:53 — can result in lower deferral rates due to the reduced traffic during off-peak times.

required

The global or 'message level' subject of your email. This may be overridden by subject lines set in personalizations.

An email template ID. A template that contains a subject and content — either text or html — will override any subject and content values specified at the personalizations or message level.

Settings to determine how you would like to track the metrics of how your recipients interact with your email.

Enter a gateway URL above to enable sending.

Code snippet
Updates live as you fill in the form above.

TypeScript

import sendgrid from '@utdk/sendgrid';

await sendgrid.postMailSend()