Retrieve bounces from an email send verified

Learn how to retrieve the number of bounces from an email send in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include WSProxy method.

WSProxy

var api = new Script.Util.WSProxy();

var cols = [
    "SubscriberKey", 
    "BounceType", 
    "SMTPCode", 
    "SMTPReason", 
    "BounceCategory", 
    "EventDate", 
    "EventType"
];

var result = api.retrieve("BounceEvent", cols, {
    Property: "TriggeredSendDefinitionObjectID",
    SimpleOperator: "equals",
    Value: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
});
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    try {

        var cols = [
            "SubscriberKey", 
            "BounceType", 
            "SMTPCode", 
            "SMTPReason", 
            "BounceCategory", 
            "EventDate", 
            "EventType"
        ];

        var result = api.retrieve("BounceEvent", cols, {
            Property: "TriggeredSendDefinitionObjectID",
            SimpleOperator: "equals",
            Value: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
        });

        Write(Stringify(result));

    } catch(error) {
        Write(Stringify(error));
    } 

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "SMTPCode": "-1",
            "BounceCategory": "Hard bounce - Domain Unknown",
            "SMTPReason": "5.1.2 (bad destination system: no such domain) ",
            "BounceType": "immediate",
            "SendID": 0,
            "SubscriberKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "EventDate": "2022-12-19T21:15:44.103",
            "EventType": "HardBounce",
            "TriggeredSendDefinitionObjectID": null,
            "BatchID": 0,
            "Client": null,
            "PartnerKey": null,
            "PartnerProperties": null,
            "CreatedDate": "0001-01-01T00:00:00.000",
            "ModifiedDate": null,
            "ID": 0,
            "ObjectID": null,
            "CustomerKey": null,
            "Owner": null,
            "CorrelationID": null,
            "ObjectState": null,
            "IsPlatformObject": false
        }
    ],
    "HasMoreRows": false
}

WARNING

Please use TriggeredSendDefinitionObjectID instead of SendID, as the latter doesn't seem to work for Triggered Sends.

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: