Skip to contentSkip to navigationSkip to topbar
On this page

Personalizations


When sending an email with the v3 Mail Send endpoint, you define the various metadata about your message, such as the recipients, sender, subject, and send time, at the root level of a JSON request body. Personalizations allow you to override these various metadata for each email in an API request.

Personalizations is an array of objects. Think of the personalizations array like the envelope of a letter: the fields defined within personalizations apply to each email, not the recipient. Like an envelope, personalizations are used to identify who should receive the email as well as details about how you would like the email to be handled. For example, you can define when you would like it to be sent, what headers you would like to include, and any substitutions or custom arguments you would like to be included with the email.

Personalizations allow you to define:

  • "to", "cc", "bcc" - The recipients of your email.
  • "from" - The sender or return path address of your email.
  • "subject" - The subject of your email.
  • "headers" - Any headers you would like to include in your email.
  • "substitutions" - Any substitutions you would like to be made for your email.
  • "custom_args" - Any custom arguments you would like to include in your email.
  • "send_at" - A specific time that you would like your email to be sent.
(information)

Info

You must include at least one to object within the personalizations array.

Since the personalizations property is an array, you may include multiple objects allowing you to specify different handling instructions for different copies of your email. For example, you could 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@yourdomain.com",
3
"template_id": "YOUR TEMPLATE ID",
4
"personalizations": [
5
{
6
"to": [
7
{
8
"email": "john@example.com"
9
}
10
],
11
"send_at": 1600188812
12
},
13
{
14
"to": [
15
{
16
"email": "jane@example.com"
17
}
18
],
19
"send_at": 1600275471
20
}
21
]
22
}
(information)

Info

You may not include more than 1000 personalizations per API request. If you need to include more than 1000 personalizations, please divide these across multiple API requests.

Some properties can be defined both at the root level of the request body (message level) and at the personalizations level.

For example, the from, subject, headers, custom_arg, and send_at properties can all be defined at the message level or at the personalizations level. Individual fields within the personalizations array will override any message level properties that are defined outside of personalizations. For example, the email subject defined within personalizations will override the subject defined at the message level in the JSON payload.

Keys within objects such as custom_args will be merged. If any of the keys conflict, the keys in the personalizations object will replace the message level object's keys.

(information)

Info

All of the recipients in a single personalization object (specified in the to, cc, or bcc fields) will see the same email, as defined by the data in that personalization. Because of this, SendGrid does not allow duplicate email addresses among these three recipient arrays in a single personalization.


Personalization Examples

personalization-examples page anchor

Below are some examples of how you can use personalizations for various use cases.

Sending a single email to a single recipient

sending-a-single-email-to-a-single-recipient page anchor

The following example shows you what the personalization property would look like if you wanted to send a single email to a single recipient.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
}
8
],
9
"cc": [
10
{
11
"email": "recipient2@example.com"
12
}
13
],
14
"subject": "YOUR SUBJECT LINE GOES HERE"
15
}
16
]
17
}

Sending a single email to a single recipient with substitutions

sending-a-single-email-to-a-single-recipient-with-substitutions page anchor

The following example shows you what the personalization property would look like if you wanted to send a single email to a single recipient with substitutions.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient@example.com"
7
}
8
],
9
"substitutions": {
10
"%fname%": "recipient",
11
"%CustomerID%": "CUSTOMER ID GOES HERE"
12
},
13
"subject": "YOUR SUBJECT LINE GOES HERE"
14
}
15
]
16
}

Sending a single email to a single recipient with a CC

sending-a-single-email-to-a-single-recipient-with-a-cc page anchor

The following example shows how to send one email to recipient1@example.com with a carbon copy sent to recipient2@example@com. Both emails will have the same headers.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
}
8
],
9
"cc": [
10
{
11
"email": "recipient2@example.com"
12
}
13
],
14
"subject": "YOUR SUBJECT LINE GOES HERE"
15
}
16
]
17
}

Sending a single email to a single recipient with a CC and a BCC

sending-a-single-email-to-a-single-recipient-with-a-cc-and-a-bcc page anchor

The following example shows how to send one email to recipient1@example.com with a CC sent to recipient2@example.com and a BCC sent to recipient3@example.com.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
}
8
],
9
"cc": [
10
{
11
"email": "recipient2@example.com"
12
}
13
],
14
"bcc": [
15
{
16
"email": "recipient3@example.com"
17
}
18
]
19
}
20
]
21
}

Sending the same email to multiple recipients

sending-the-same-email-to-multiple-recipients page anchor

The following shows how to send one email to three different recipients: recipient1@example.com, recipient2@example.com, and recipient3@example.com. These recipients will all be able to see each other on the email.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
},
8
{
9
"email": "recipient2@example.com"
10
},
11
{
12
"email": "recipient3@example.com"
13
}
14
],
15
"subject": "YOUR SUBJECT LINE GOES HERE"
16
}
17
]
18
}

Sending a single email to a single recipient with multiple CCs and BCCs

sending-a-single-email-to-a-single-recipient-with-multiple-ccs-and-bccs page anchor

The following shows what personalizations are required to send the same email to one recipient, with multiple CCs and BCCs.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
}
8
],
9
"cc": [
10
{
11
"email": "recipient2@example.com"
12
},
13
{
14
"email": "recipient3@example.com"
15
},
16
{
17
"email": "recipient4@example.com"
18
}
19
],
20
"subject": "YOUR SUBJECT LINE GOES HERE"
21
}
22
]
23
}

Sending two different emails to two different groups of recipients

sending-two-different-emails-to-two-different-groups-of-recipients page anchor

The following shows how to send two different emails to two different groups of recipients.

1
{
2
"personalizations": [
3
{
4
"to": [
5
{
6
"email": "recipient1@example.com"
7
}
8
],
9
"cc": [
10
{
11
"email": "recipient2@example.com"
12
},
13
{
14
"email": "recipient3@example.com"
15
},
16
{
17
"email": "recipient4@example.com"
18
}
19
],
20
"subject": "YOUR SUBJECT LINE GOES HERE"
21
},
22
{
23
"to": [
24
{
25
"email": "recipient5@example.com"
26
}
27
],
28
"cc": [
29
{
30
"email": "recipient6@example.com"
31
},
32
{
33
"email": "recipient7@example.com"
34
},
35
{
36
"email": "recipient8@example.com"
37
}
38
],
39
"subject": "YOUR SUBJECT LINE GOES HERE"
40
}
41
]
42
}

Sending multiple emails from multiple senders to multiple recipients

sending-multiple-emails-from-multiple-senders-to-multiple-recipients page anchor

It is possible to specify multiple From addresses using personalizations. If a personalization object does not contain a from object, SendGrid will use the email address in the from object defined at the root level of the request body.

To successfully deliver email using multiple From addresses, the following conditions must be met.

  • A from object with an email property must be specified at the root level of the request body.
  • The domain of the from email property specified in any personalization must match the domain of the from email property specified at root level of the request body—SendGrid will reject requests if these domains do not match.
1
// This is valid
2
{
3
"from": {
4
"email": "support@example.com"
5
},
6
"personalizations": [
7
{
8
"from": {
9
"email": "noreply@example.com"
10
}
11
}
12
]
13
}
14
15
// This is invalid
16
{
17
"from": {
18
"email": "support@example.com"
19
},
20
"personalizations": [
21
{
22
"from": {
23
"email": "noreply@differentexample.com"
24
}
25
}
26
]
27
}

The following shows how to send multiple emails using three different from addresses on the same domain.

(warning)

Warning

You must complete domain authentication to send email from multiple addresses. SendGrid will reject requests from a sending domain that has not been authenticated.

1
{
2
"from": {
3
"email": "default@samedomain.com"
4
},
5
"personalizations": [
6
{
7
"subject": "YOUR SUBJECT LINE GOES HERE",
8
"to": [
9
{
10
"email": "recipient1@example1.com"
11
}
12
],
13
"from": {
14
"email": "sender1@samedomain.com"
15
}
16
},
17
{
18
"subject": "YOUR SUBJECT LINE GOES HERE",
19
"to": [
20
{
21
"email": "recipient2@example2.com"
22
}
23
],
24
"from": {
25
"email": "sender2@samedomain.com"
26
}
27
},
28
{
29
"subject": "YOUR SUBJECT LINE GOES HERE",
30
"to": [
31
{
32
"email": "recipient3@example3.com"
33
}
34
],
35
"from": {
36
"email": "sender3@samedomain.com"
37
}
38
}
39
]
40
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.