A webhook is a simple HTTP callback, which uses a HTTP POST when an event happens. We use these webhooks to receive events to let us know new information about your email. Your Email Service Provider (ESP) will send us webhooks when your email is clicked, opened, etc. This gives you the ability to see all your email analytics in your Sendwithus dashboard.

Sendwithus is also able to redirect these events to an endpoint of your choosing. The webhooks are virtually unchanged, the only difference being that we add a few extra bits of Sendwithus related information to your webhook.

How do I relay webhook events to my server?

Click Delivery Settings on the navigation bar in your Sendwithus dashboard. Click on the Actions dropdown menu, and select “Settings” for the ESP account to relay the webhooks.

ESP settings

Enter a URL for Sendwithus to send webhooks too, and click Save when you are done.

Webhooks Go Here

Does Sendwithus forward all of my ESP’s webhooks?

Yes! All webhooks are forwarded to the endpoint you specify, even if the email didn’t originate from Sendwithus.

What do these webhooks look like?

The following are sample webhooks for their respective ESP. Note: Some of these samples do not include all properties.

For more information visit SendGrid Webhooks Overview

                [
                  {
                    "response": "250 2.0.0 OK 1444932357 g7si74876igq.93 - gsmtp ",
                    "sg_event_id": "BEfpqsQ1QAmNJ2iDX814rg",
                    "sg_message_id": "sSk9ILQ.filterdw1.112.47.0",
                    "event": "delivered",
                    "email": "us@sendwithus.com",
                    "timestamp": 1444932357,
                    "smtp-id": "<9ogM8LQ@ad1.sendgrid.net>",
                    "receipt_id": "log_b3463626f2c17",
                    "swu_template_id": "tem_hDf3VtdT",
                    "swu_template_version_id": "ver_YaPiU9j",
                    "drip_campaign_id":"dc_97BicUNtuJuvzrWK",
                    "drip_campaign_step_id":"dcs_QGf9AKStczsnMVmF",
                    "tls": 1,
                    "ip": 127.0.0.1
                  }
                ]
                
Sendwithus adds the following addition information to SendGrid's webhook: swu_template_id, swu_template_version_id, receipt_id, drip_campaign_id (if applicable), and drip_campaign_step_id (if applicable).
For more information visit Mailgun's Webhooks Documentation

                [
                  [
                    "Sender",
                    "us=sendwithus.com@mailgun.org"
                  ],
                  [
                    "Date",
                    "Thu, 15 Oct 2015 22:40:57 +0000"
                  ],
                  [
                    "X-Mailgun-Sid",
                    "XMuBfD9tIiwgIj23fhYjEwOCJd"
                  ],
                  [
                    "Received",
                    "by luna.mailgun.net with HTTP; Thu, 15 Oct 2015 22:40:55 +0000"
                  ],
                  [
                    "X-Mailgun-Variables",
                    "{\"swu_template_version_id\": \"ver_omN5gXtLHJHwQcpYaPiU9j\", \"receipt_id\": \"log_d3b7mm5lH255e6f\", \"swu_template_id\": \"tem_hDf3mfkTNrPjBfdsfk300dsDpLZ4\", \"drip_campaign_step_id\": \"dcs_QGf9AKStczsnMVmF\", \"drip_campaign_id\": \"dc_97BicUNtuJuvzrWK\"}"
                  ],
                  [
                    "X-Swu-Receipt-Id",
                    "log_d3b7mm5lH255e6f"
                  ],
                  [
                    "X-Mailgun-Track-Opens",
                    "true"
                  ],
                  [
                    "X-Mailgun-Track-Clicks",
                    "true"
                  ],
                  [
                    "Content-Type",
                    [
                      "multipart/alternative",
                      {
                        "boundary": "iuyib7882f7"
                      }
                    ]
                  ]
                ]
                
Sendwithus adds the following addition information into X-Mailgun-Variables: swu_template_version_id, receipt_id, swu_template_id, drip_campaign_step_id (if applicable), and drip_campaign_id (if applicable).
For more information visit SparkPost's Webhooks Documentation

                [
                  {
                    "msys": {
                      "message_event": {
                        "customer_id": "000",
                        "template_id": "template_194944",
                        "message_id": "0039fs2743",
                        "rcpt_tags": [],
                        "rcpt_meta": {
                          "receipt_id": "log_f03388f03nkjnfo974",
                          "swu_template_id": "tem_hDf3VtdT",
                          "swu_template_version_id": "ver_YaPiU9j"
                        },
                        "template_version": "0",
                        "subject": "Invoice for",
                        "msg_from": "msprvs1=163ll299bJ1=bounces-000@sparkpostmail.com",
                        "rcpt_to": "us@sendwithus.com",
                        "msg_size": "19006",
                        "timestamp": "1444951247",
                        "friendly_from": "us@sendwithus.com",
                        "routing_domain": "sendwithus.com",
                        "type": "injection",
                        "transmission_id": "329184844"
                      }
                    },
                    "cust": {
                      "id": "000"
                    }
                  }
                ]

                
Sendwithus adds the following addition information to Sparkpost's webhook: receipt_id, swu_template_id, and swu_template_version_id.
For more information visit Mailjet's Event Documentation

                {
                  "event": "sent",
                  "time": 1444950669,
                  "MessageID": 74500,
                  "email": "us@sendwithus.com",
                  "mj_campaign_id": 25807,
                  "mj_contact_id": 233,
                  "customcampaign": "",
                  "mj_message_id": "90098100",
                  "smtp_reply": "sent (250 2.0.0 OK 0668 2f8efb.63 - gsmtp)",
                  "CustomID": "log_f1fiozfi03b",
                }

                
Sendwithus adds the following addition information to Mailjet's webhook: CustomID is equivalent to receipt_id.
For more information visit Postmark's Webhooks Overview.

                {
                  "ServerID": 1234,
                  "MessageID": "883953f4-6105-42a2-a16a-77a8eac79483",
                  "Recipient": "us@sendwithus.com",
                  "Tag": "welcome-email",
                  "DeliveredAt": "2017-11-01T16:33:10-04:00",
                  "Details": "smtp;250 2.0.0 OK 1560987833 3ff47382"
                }
                
Sendwithus does not add any additional information to Postmark's webhook.
For more information visit Mandrill's Introduction to Webhooks.

                [
                  {
                    "event": "send",
                    "_id": "64dscf222f940081",
                    "msg": {
                      "ts": 1444948089,
                      "subject": "Invoice for",
                      "email": "us@sendwithus.com",
                      "tags": [],
                      "opens": [],
                      "clicks": [],
                      "state": "sent",
                      "smtp_events": [],
                      "subaccount": null,
                      "resends": [],
                      "reject": null,
                      "_id": "64dscf222f940081",
                      "metadata": {
                        "receipt_id": "log_66e67ef9f941",
                        "swu_template_id": "tem_hDf3VtdT",
                        "swu_template_version_id": "ver_YaPiU9j"
                      },
                      "sender": "us@sendwithus.com",
                      "template": null
                    },
                    "ts": 1444948090
                  }
                ]
                
Sendwithus adds the following addition information to Mandrill's webhook: receipt_id, swu_template_id, and swu_template_version_id.

ESP specific Webhook information can be found here:

How can I test my webhooks?

You can test and debug your webhooks using an external tool like ngrok. ngrok helps you create a public URL to expose a web site running locally to the internet. They also provide a real-time web interface where you can track HTTP traffic at http://localhost:4040. For more information on getting started with ngrok check their documentation.