Delivery Report Webhook

When delivery reports are enabled on your account, Gupshup sends an HTTP POST to the webhook URL you provide each time delivery events are available.

Request format

HTTP methodPOST
Content-Typeapplication/x-www-form-urlencoded;charset=utf-8
Parameterresponse
ValueJSON array of event objects

Event object

FieldTypeDescription
timestampstringEvent time as a Unix timestamp in seconds.
emailstringRecipient email address.
eventstringEvent type, e.g. DELIVERED, SOFT_BOUNCE, CLICK.
campaignidstringID of the campaign the event belongs to.
linkstringThe clicked URL. Present only for click events.

Payload examples

[
  {
    "timestamp": "1493577000",
    "email": "[email protected]",
    "event": "DELIVERED",
    "campaignid": "3319237025400370211"
  }
]
[
  {
    "timestamp": "1493577000",
    "email": "[email protected]",
    "event": "DELIVERED",
    "campaignid": "3319237025400370211"
  },
  {
    "timestamp": "1493577001",
    "email": "[email protected]",
    "event": "SOFT_BOUNCE",
    "campaignid": "3319237025400370211"
  },
  {
    "timestamp": "1493577001",
    "email": "[email protected]",
    "event": "CLICK",
    "link": "http://www.example.com",
    "campaignid": "4019237025400370222"
  },
  {
    "timestamp": "1493577004",
    "email": "[email protected]",
    "event": "DELIVERED",
    "campaignid": "4319237025400370233"
  }
]
👍

Always handle arrays

A single call can contain several events. Parse response as an array from the start so you won't need to change your code later.

Handling events in Java

String response = req.getParameter("response");
JSONArray jsonArray = new JSONArray(response);

for (int i = 0; i < jsonArray.length(); i++) {
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    String campaignid = jsonObject.getString("campaignid");
    callBusinessMethod(jsonObject);
}

Did this page help you?