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

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

1
2
3
4
5
6
{
  "unique_args": {
    "customerAccountNumber": "55555",
    "activationAttempt": "1"
  }
}

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

1
2
3
4
5
6
{
  "email" : "ben@sendgrid.com",
  "test_param" : "test_value",
  "2nd_param" : "2nd_value",
  "event" : "processed"
}

Unique Arguments will also be shown in the Email Activity tab of your account.

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

1
2
3
4
5
6
7
8
9
10
11
{
  "sub" : {
    "-account_number-" : [
      "314159",
      "271828"
    ]
  },
  "unique_args" : {
  	"customerAccountNumber" : "-account_number-"
  }
}