Personalizations
When you send an email message using the Mail Send v3 endpoint, you define properties about the email message: who sends it (from), who receives it (to), and what the message concerns (subject). The common name for these properties is metadata. If you want to send one email message to multiple recipients, you can customize the message sent to each recipient using Personalizations.
Write personalizations as an array of JSON objects in the API request body. The personalizations array works like the envelope of a letter: the properties you define within personalizations apply to the email message sent to the recipient. Like an envelope, personalizations identify who should receive the email and how Twilio should handle the email message. Each personalization object applies to one recipient, set with the to property.
Personalizations limit
Each API request has a limit of 1,000 personalization objects. To include more than 1,000, divide the objects across multiple API requests.
Personalizations differ from Substitutions, which customize the content of an email message. Personalizations can include Substitutions, but Substitutions don't contain Personalizations.
In the personalizations array, you can customize one or more of the following properties for your email messages:
| Property | Necessity | Purpose |
|---|---|---|
to | Required | One or more intended addressed recipients displayed in your message. |
cc | Optional | The additional recipients of your message displayed to the intended recipient. |
bcc | Optional | The additional recipients of your message hidden from the intended recipient. |
from | Optional | The email address displayed as the sender of your message. |
subject | Optional | The subject line that your message displays. |
headers | Optional | Any email metadata headers your message should include. |
substitutions | Optional | Any message body substitution text your message should include. |
custom_args | Optional | Any unique custom metadata your message should include. |
send_at | Optional | The specific time that your message sends expressed in UNIX Epoch time. |
Within the personalizations array, you define handling instructions for different recipients of your email message.
- Some properties you can define for each email message and each recipient.
- Message-level properties are defined at the root level of the request body.
- Recipient-level properties are defined in the
personalizationsarray. - These properties include
from,subject,headers,custom_args, andsend_at.
- Individual properties within the
personalizationsarray override any message-level properties defined outside ofpersonalizations. - Keys within objects such as
custom_argsget merged. If any of the keys conflict, thepersonalizationsobject keys override the message-level object keys. - You can't repeat email addresses in any of the
to,cc, orbccproperties within the samepersonalizationsarray. - Each object in the
personalizationsarray limits itssubstitutionsobject to 150 properties.
Example: Send messages at different times to different recipients
To send the same email to both john@example.com and jane@example.com but set each email to be delivered at different times.
1{2"from": "sender@example.com",3"template_id": "YOUR TEMPLATE ID",4"personalizations": [{5"to": [{6"email": "john@example.com"7}],8"send_at": 16001888129},10{11"to": [{12"email": "jane@example.com"13}],14"send_at": 160027547115}]16}
The following examples show how to use personalizations for common use cases. These use cases include sending to a single recipient, adding CC and BCC recipients, sending to multiple recipients, and sending from multiple senders.
The following example shows you what the personalization property would look like if you wanted to send one email to one recipient.
1{2"personalizations": [{3"to": [{4"email": "recipient1@example.com"5}],6"cc": [{7"email": "recipient2@example.com"8}],9"subject": "YOUR SUBJECT LINE GOES HERE"10}]11}
To send one email to three different recipients, follow this example:
1{2"personalizations": [{3"to": [{4"email": "recipient1@example.com"5},{6"email": "recipient2@example.com"7},{8"email": "recipient3@example.com"9}],10"subject": "YOUR SUBJECT LINE GOES HERE"11}]12}
All recipients can see all other recipients to the email.
To send email messages from more than one sender, use personalizations.
- Set a
from.emailproperty at the root level of the request body. - Add more
from.emailaddresses in thepersonalizationsarray. - If a personalization object doesn't contain a
from.emailproperty, Twilio SendGrid uses the email address in thefrom.emailproperty in the root level of the request body.
Email address restrictions
Twilio SendGrid rejects requests from a sending domain under two conditions:
- The domain of the
from.emailandpersonalizations.from.emaildon't match. All email messages must come from the same sending domain. - The sneding domain hasn't undergone domain authentication.
If these domains don't match or haven't been authenticated, Twilio SendGrid rejects the request.
To send email messages using multiple From addresses, following this example:
1// This is valid2{3"from": {4"email": "support@example.com"5},6"personalizations": [{7"from": {8"email": "noreply@example.com"9}10}]11}
1// This is invalid2{3"from": {4"email": "support@example.com"5},6"personalizations": [{7"from": {8"email": "noreply@differentexample.com"9}10}]11}