Reputation: 577
We are using SendGrid Marketing Email API for pushing newsletters to our subscribers, and wish to include a custom list-unsubscribe header in each of the emails. However I cannot see any API method supporting adding headers to the message. Am I completely blind or are there just no methods for adding custom headers to SendGrid emails?
Thank you Brgds Lukas
Upvotes: 1
Views: 1627
Reputation: 1511
If you're using the Marketing Email API there is no way to intercept the email and add headers to it at the moment.
You could do this if you were just using the Marketing Email API to manage lists and then sending the emails yourselves through SendGrid, because you could then build out the headers however you wanted.
For Marketing Emails, the list-unsubscribe header is automatically set by the Unusubscribe Application, as detailed in this Knowledge Base article.
Upvotes: 1
Reputation: 2273
When using the Marketing Email platform, you cannot add custom headers; you can do that with the main Web or SMTP API only. However, if you're using the main Web or SMTP API, you can specifically use Substitution Tags in the List-Unsubscribe field, for easy customization.
Upvotes: 0
Reputation: 6758
You can add custom header via their Web API with the header
argument (must be in valid JSON format without integers), as described in their doc:
POST: https://api.sendgrid.com/api/mail.send.json
POST Data:
api_user=your_sendgrid_username&api_key=your_sendgrid_password&[email protected]&toname=Destination&subject=Example_Subject&text=testingtextbody&[email protected]&header={"List-Unsubscribe": "unsubscribe_email@your_domain"}
Upvotes: 2