Skip to content
Last updated

Retrieving delivery reports with the Node SDK

Note:

For testing purposes, we recommend you first send a message using the Getting Started Guide. Alternatively, you can test this method using the provided code sample.

Retrieve a delivery report for a specific recipient

The getByPhoneNumber method retrieves a delivery report by phone number as well as batch ID.

const recipientPhoneNumber = response.to[0];
const requestData = {
  batch_id: response.id,
  recipient_msisdn: recipientPhoneNumber
};

sinchClient.sms.deliveryReports
  .getByPhoneNumber(requestData)
  .then((response) => console.log(response))
  .catch((error) => console.error("There was an error!", error.response));

When you run it, you should see an output like the following:
{
  at: '2024-06-07T14:03:26.536Z',
  batch_id: '01J06CY78GZ2F74YZNNH2VBWR6',
  code: 401,
  recipient: '447..3',
  status: 'Dispatched',
  type: 'recipient_delivery_report_sms'
}

The response contains a number of useful fields:

  • at is a timestamp of when a delivery report was created
  • code is the delivery report status code
  • status is the delivery status of a message

This information can help you ascertain whether a person successfully received a message, as well as allowing you to drill down into causes of failure.

See more delivery report tutorials