Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Unique Arguments


(error)

Danger

This information will be stored as a "Not PII" field and may be used for counting or other operations as SendGrid runs its systems. These fields generally cannot be redacted or removed. You should take care not to place PII in this field. SendGrid does not treat this data as PII, and its value may be visible to SendGrid employees, stored long-term, and may continue to be stored after you've left SendGrid's platform.

The SMTP API JSON string allows you to attach an unlimited number of unique arguments to your email up to 10,000 bytes. The arguments are used only for tracking. They can be retrieved through the Event API or the Email Activity page.

Note that unique arguments are only used in the SendGrid SMTP API and V2 Mail Send API. The V3 Mail Send API uses custom arguments (with the parameter custom_args) instead of unique arguments.

(error)

Danger

When passing unique_args please make sure to only use strings as shown in our examples. Any other type could result in unintended behavior.

These arguments can be added using a JSON string like this:


_10
{
_10
"unique_args": {
_10
"customerAccountNumber": "55555",
_10
"activationAttempt": "1",
_10
"New Argument 1": "New Value 1",
_10
"New Argument 2": "New Value 2",
_10
"New Argument 3": "New Value 3",
_10
"New Argument 4": "New Value 4"
_10
}
_10
}

These arguments can then be seen in posts from the SendGrid Event Webhook. The contents of one of these POST requests would look something like this:


Example Webhook Post Data

example-webhook-post-data page anchor

_14
{
_14
"sg_message_id": "145cea24eb8.1c420.57425.filter-132.3382.5368192A3.0",
_14
"New Argument 1": "New Value 1",
_14
"event": "processed",
_14
"New Argument 4": "New Value 4",
_14
"email": "useexampexample@example.com",
_14
"email": "example@example.com",
_14
"smtp-id": "<145cea24eb8.1c420.57425@localhost.localdomain>",
_14
"timestamp": 1399331116,
_14
"New Argument 2": "New Value 2",
_14
"New Argument 3": "New Value 3",
_14
"customerAccountNumber": "55555",
_14
"activationAttempt": "1"
_14
}

(error)

Danger

Bounces returned with the Return-Path cause unique_args not to be attached to an event. This can cause issues when developing unique_args POST handling.

To apply different unique arguments to individual emails, you may use substitution tags. An example of this would look like:


_10
{
_10
"sub": {
_10
"-account_number-": ["314159", "271828"]
_10
},
_10
"unique_args": {
_10
"customerAccountNumber": "-account_number-"
_10
}
_10
}



Rate this page: