emailnewslettersendgrid

Adding list-unsubscribe header to email through SendGrid Marketing API


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


Solution

  • 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&to=destination@example.com&toname=Destination&subject=Example_Subject&text=testingtextbody&from=info@domain.com&header={"List-Unsubscribe": "unsubscribe_email@your_domain"}