Skip to contentSkip to navigationSkip to topbar
On this page

Delivery Receipts Overview


With the Delivery Receipts feature, you can obtain information about the status of Conversations Messages sent to non-Chat Participants (i.e. SMS and WhatsApp channels).

You can verify if the Messages were sent, delivered or even read (for OTT(link takes you to an external page)) by other Conversations Participants.

Let's get started!


What are Delivery Receipts?

what-are-delivery-receipts page anchor

Delivery Receipts are summaries that contain detailed information about the messages sent to Participants in non-Chat channels.

This feature includes information about:

  • A summary of the Message's delivery statuses
  • The number of Messages sent
  • The number of Conversation Participants the message(s) was sent to

Types of Delivery Receipt Message Statuses

types-of-delivery-receipt-message-statuses page anchor

Delivery Receipts can contain the following message statuses:

  • sent
  • delivered
  • read
  • failed
  • undelivered

Aggregated Delivery Receipts

aggregated-delivery-receipts page anchor

An Aggregated Delivery Receipt contains a general summary of the delivery statuses of a Message to all non-Chat Participants in the Conversation.

Use aggregated receipts to represent the overall delivery status of a Message.

You can retrieve the Aggregated Delivery Receipts summaries from any Message object in a Conversation that contains non-Chat recipients. This is often enough to confirm successful delivery of the message.

Aggregated Delivery ReceiptsLink to code sample: Aggregated Delivery Receipts
1
/* Retrieving Delivery Receipts (aggregated and detailed) for rendering */
2
3
const aggregatedDeliveryReceipt = message.aggregatedDeliveryReceipt;
4
5
// get amount (DeliveryAmount) of participants with particular delivery status
6
const deliveredReceipts = aggregatedDeliveryReceipt?.delivered;
7
const failedReceipts = aggregatedDeliveryReceipt?.failed;
8
const readReceipts = aggregatedDeliveryReceipt?.read;
9
const sentReceipts = aggregatedDeliveryReceipt?.sent;
10
const undeliveredReceipts = aggregatedDeliveryReceipt?.undelivered;
11
// get the amount of participants which have the status for the message
12
const totalReceipts = aggregatedDeliveryReceipt?.total;
13
14
if (undeliveredReceipts !== "none") {
15
// some delivery problems
16
alert(`Out of ${totalReceipts} sent messages, ${deliveredReceipts} were delivered, ${failedReceipts} have failed.`);
17
}

Detailed Delivery Receipts

detailed-delivery-receipts page anchor

A Detailed Delivery Receipt represents the Message delivery status to a specific non-Chat Participant in the Conversation.

Use detailed receipts when you want to show the specific recipient who didn't receive the message.

You can also get a list of the Detailed Delivery Receipts by calling the correct method on the same object. This is useful if you want to render separate sent/delivered/read statuses for specific Participants.

1
// get the list of of delivery receipts
2
const detailedDeliveryReceipts = await message.getDetailedDeliveryReceipts();
3
4
const statusMap = {};
5
6
detailedDeliveryReceipts.map((detailedDeliveryReceipt) => {
7
// get status of the delivery receipts
8
const receiptStatus = detailedDeliveryReceipt.status;
9
const participantSid = detailedDeliveryReceipt.participantSid;
10
statusMap[participantSid] = receiptStatus;
11
12
});

Delivery Receipts Error Handling

delivery-receipts-error-handling page anchor

Retrieving detailed receipts is necessary for error retrieval and handling. Each detailed receipt for a message that failed will contain a Twilio error code indicating the failure reason.

If the message status is failed or undelivered, you can handle the error code accordingly.

Read more in the Troubleshooting Undelivered Twilio SMS Messages support article.(link takes you to an external page)

1
/* Checking delivery receipts for errors */
2
3
// get the list of aggregated delivery receipts
4
const aggregatedDeliveryReceipt = message.aggregatedDeliveryReceipt;
5
6
// retrieve delivery receipt status
7
if (aggregatedDeliveryReceipt.failed !== "none" || aggregatedDeliveryReceipt.undelivered !== "none") {
8
// handle error
9
}
10
11
// get the list of delivery receipts
12
const detailedDeliveryReceipts = await message.getDetailedDeliveryReceipts();
13
14
detailedDeliveryReceipts.map((detailedDeliveryReceipt) => {
15
// check delivery receipt status
16
if (!detailedDeliveryReceipt.status === "undelivered" && !detailedDeliveryReceipt.status === "failed") {
17
return;
18
}
19
20
// handle error. the error codes page: https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors
21
if (detailedDeliveryReceipt.errorCode === 30006) {
22
alert("The destination number is unable to receive this message.");
23
return;
24
}
25
26
if (detailedDeliveryReceipt.errorCode === 30007) {
27
alert("Your message was flagged as objectionable by the carrier.");
28
}
29
});

Great work! You've learned the foundations of Delivery Receipts, you can continue with any of the following guides:

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.