Email Resource
To send emails, retrieve individual email details, and list emails with filtering, use the Email resource. This resource represents an email message sent through the Twilio Email API.
Twilio Email retains data for seven days after creation. Requests for older records may yield incomplete results.
All URLs in the reference documentation use the following base URL:
https://comms.twilio.com/v1
A reference to an Email.
comms_email_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_email_[0-7][a-hjkmnpqrstv-z0-9]{25,34}The status of an Email. The status can be one of the following:
-
SCHEDULEDTheEmailis scheduled to be sent by Twilio in the future. -
QUEUEDTheEmailis queued in Twilio for sending. -
SENTTheEmailhas been sent by Twilio. -
DELIVEREDTheEmailhas been successfully delivered to the recipient. -
UNDELIVEREDTheEmailwas successfully sent by Twilio but has not been delivered to the recipient. -
OPENEDTheEmailhas been opened by the recipient. -
FAILEDTheEmailprocessing failed inside Twilio. -
CANCELEDTheEmailwas canceled via API request. -
INBOUNDTheEmailwas received by Twilio from an external source.
SCHEDULEDQUEUEDSENTDELIVEREDUNDELIVEREDOPENEDFAILEDCANCELEDINBOUNDA list of resources that are associated with the Email.
Custom metadata in the form of key-value pairs. Maximum size of a tag key is 128 characters. Maximum size of a tag value is 256 characters. There can be a maximum of 10 key-value pairs.
This field can be templated with Liquid.
Specify variables with each recipient for personalization.
10The scheduled send time of the Email.
This field is only present if the Email was created with a schedule.
The date and time when the Email was deleted.
POST https://comms.twilio.com/v1/Emails
Creates and sends emails to the specified recipients. The API processes requests asynchronously and returns a 202 Accepted response with an operationId you can use to track send status.
The full request size must not exceed 5 MB.
application/jsonA list of recipients to send the email(s) to.
1Max items: 10000The content of the Email.
- Use the Liquid templating language for personalization in any text-based field.
- When using a templated content, use the
variablesfield on each recipient to specify the values to substitute. - For each variable you specify in your template, you should have a matching key in each recipient's
variablesobject. - When targeting
Profilerecipients, you may specifyvariableswith values that reference stored traits, on theProfile-- for example:${Twilio.Profile.dateLastPurchase}${Twilio.Profile.firstName}or${Twilio.Profile.myCustomField}.
Custom metadata in the form of key-value pairs. Maximum size of a tag key is 128 characters. Maximum size of a tag value is 256 characters. There can be a maximum of 10 key-value pairs.
This field can be templated with Liquid.
Specify variables with each recipient for personalization.
10A schedule defines when a communication will be sent to a recipient.
1The name of the IP Pool to use for sending Emails.
If not specified, all dedicated IPs associated with your account will be considered for sending.
IP pools are only available to accounts with dedicated IPs.
This field can be templated with Liquid.
Specify variables with each recipient for personalization.
2Max length: 641import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "TWILIO_ACCOUNT_SID",6authToken: "TWILIO_AUTH_TOKEN",7});8await client.emails.send({9from: {10address: "support@example.company.io",11name: "Cool Co Support",12},13to: [14{15address: "bob@example.com",16name: "Bob Smith",17},18],19content: {20html: "<html><body>Hey, <br/><br/><b>Cake</b></body></html>",21text: "Hey, the cake is ready.",22subject: "Re: Wedding Cake",23attachments: [24{25filename: "filename",26contentType: "contentType",27content: "content",28},29],30},31});32}33main();
GET https://comms.twilio.com/v1/Emails/{emailId}
Retrieves a single Email based on its ID. Retains records for seven days after creation.
comms_email_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_email_[0-7][a-hjkmnpqrstv-z0-9]{25,34}GET https://comms.twilio.com/v1/Emails
Returns a paginated list of Emails. Retains data for seven days after creation.
Filter to Emails created in a specific Operation.
comms_operation_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_operation_[0-7][a-hjkmnpqrstv-z0-9]{25,34}Filter Emails by Delivery Status.
SCHEDULEDQUEUEDSENTDELIVEREDUNDELIVEREDOPENEDFAILEDCANCELEDINBOUNDMatch emails by one or many tags. If more than one tag is specified in the query, the search will return emails that have all the tags.
For Example: GET /Emails?tags=ageGroup:20s;industry:engineering;
key_1:value;key_2:value;Pattern: ^(?:[a-zA-Z0-9._~-]+:[a-zA-Z0-9._~-]+;){1,10}$The number of resources to return in a page.
50Example: 50Minimum: 1Maximum: 10001import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "TWILIO_ACCOUNT_SID",6authToken: "TWILIO_AUTH_TOKEN",7});8await client.emails.list({9operationId: "comms_operation_01h9krwprkeee8fzqspvwy6nq8",10startDate: new Date("2024-01-15T09:30:00Z"),11endDate: new Date("2024-01-15T09:30:00Z"),12status: "SCHEDULED",13tags: "key_1:value;key_2:value;",14pageToken: "pageToken",15pageSize: 50,16});17}18main();