verified
Retrieve the status of a Triggered Send messageLearn how to retrieve the status of a Triggered Send message in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the REST API methods.
REST API
var externalKey = "123456";
var recipientSendId = "654321";
var endpoint = restInstanceUrl + "messaging/v1/messageDefinitionSends/key:" + externalKey + "/deliveryRecords/" + recipientSendId;
var request = HTTP.Get(endpoint, ["Authorization"], ["Bearer " + accessToken]);
var result = Platform.Function.ParseJSON(String(request.Content));
<script runat="server">
Platform.Load("core", "1");
var api = new Script.Util.WSProxy();
var restInstanceUrl = "https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/",
accessToken = "YOUR_REST_API_TOKEN";
try {
var externalKey = "123456";
var recipientSendId = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var endpoint = restInstanceUrl + "messaging/v1/messageDefinitionSends/key:" + externalKey + "/deliveryRecords/" + recipientSendId;
var request = new Script.Util.HttpRequest(endpoint);
request.emptyContentHandling = 0;
request.retries = 2;
request.continueOnError = true;
request.setHeader("Authorization", "Bearer " + accessToken);
request.method = "GET";
request.contentType = "application/json";
var results = request.send();
var result = Platform.Function.ParseJSON(String(results.content));
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
{
"deliveryTime": "2023-09-17T16:30:00.000",
"id": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"messageId": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"status": "Sent",
"to": {
"address": "example@mail.com",
"id": 123456789,
"key": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
}
}
TIP
RecipientSendId value returned from the "/messageDefinitionSends" send service, which is the unique identifier for a single email send.
Reference
Ressources and references related to the current methods.
Official documentation