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.
The List method retrieves a list of delivery reports. It comes with a number of optional parameters that enable features such as pagination and filtering by date range. Let's first look at the default form with no parameters.
var deliveryReportList = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest { });Display the result using:
Console.WriteLine(deliveryReportForNumber);When you run it you should get a response which is something like this:
[
{
"At": "2023-12-20T09:37:08.133Z",
"BatchId": "01HJ39C00N1H0EXVZ0227CGQ8W",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:37:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-20T09:32:25.282Z",
"BatchId": "01HJ3938JCJP0MTAHS4D4XN94X",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:32:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-14T10:46:05.274Z",
"BatchId": "01HHKYXVSERTFRH8YQFV0VTTVP",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-14T10:46:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-13T17:29:58.699Z",
"BatchId": "01HHJ3MNSFFYJV0KDX0TMRPQGK",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-13T17:29:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-11T14:17:53.358Z",
"BatchId": "01HHCKVM1HZMRZKAQZ56RD4JEY",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-11T14:17:00Z",
"Type": "recipient_delivery_report_sms"
}
]By default, List returns a list of delivery reports from the last 24 hours. The most recent delivery reports are first. In this example, four messages were sent in the last 24 hours so count=4. Each Delivery Report object includes a timestamp, a BatchId, Status and Code. The default method is fine if you've only sent a few batches. However real companies are likely to be sending a high volume of batches every day. To handle this, the SDK enables you to split results into "pages". Here's an example:
var deliveryReportList = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest
{
Page = 0,
PageSize = 2,
});Page is the page number you want to retrieve. Pages start from zero. PageSize is the maximum number of results displayed on each page. This example returns the two most recent delivery reports.
[
{
"At": "2023-12-20T09:37:08.133Z",
"BatchId": "01HJ39C00N1H0EXVZ0227CGQ8W",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:37:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-20T09:32:25.282Z",
"BatchId": "01HJ3938JCJP0MTAHS4D4XN94X",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:32:00Z",
"Type": "recipient_delivery_report_sms"
}
]What happens if you "skip" too many pages ahead? Let's say you made the following method call:
var deliveryReportList = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest
{
Page = 10,
PageSize = 50,
});Given the amount of messages you've sent in the last 24 hours, there probably aren't enough delivery reports to fill ten pages with fifty results each. The List method handles this situation by returning an empty list.
[]Suppose you want to view delivery reports previous to the last 24 hours. To do this you can use the StartDate and EndDate parameters. Here's an example that shows all messages from December 2023 to present:
var deliveryReportList = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest
{
StartDate = new DateTime(2023, 12, 01, 3, 14, 17, DateTimeKind.Utc),
});When you run it, you get a response which is something like this:
[
{
"At": "2024-10-25T10:02:42.148Z",
"BatchId": "01JB1J1M5BM5XQ8Q0ZWBM44E14",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2024-10-25T10:02:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2024-10-25T08:43:58.914Z",
"BatchId": "01JB1DH7J0DHQCZ37DAHZYH7JH",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2024-10-25T08:43:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2024-10-23T09:37:57.556Z",
"BatchId": "01JAWBTVTGCQ9VRRYH5HZC2Z67",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2024-10-23T09:37:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-20T09:37:08.133Z",
"BatchId": "01HJ39C00N1H0EXVZ0227CGQ8W",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:37:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-20T09:32:25.282Z",
"BatchId": "01HJ3938JCJP0MTAHS4D4XN94X",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-20T09:32:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-14T10:46:05.274Z",
"BatchId": "01HHKYXVSERTFRH8YQFV0VTTVP",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-14T10:46:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-13T17:29:58.699Z",
"BatchId": "01HHJ3MNSFFYJV0KDX0TMRPQGK",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-13T17:29:00Z",
"Type": "recipient_delivery_report_sms"
},
{
"At": "2023-12-11T14:17:53.358Z",
"BatchId": "01HHCKVM1HZMRZKAQZ56RD4JEY",
"Code": 0,
"Status": "Delivered",
"AppliedOriginator": null,
"ClientReference": null,
"NumberOfMessageParts": null,
"Operator": null,
"OperatorStatusAt": "2023-12-11T14:17:00Z",
"Type": "recipient_delivery_report_sms"
}
]If you want to retreive delivery reports from a specific time period, such as Christmas and new year, you can specify both StartDate and EndDate like this:
var deliveryReportList4 = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest
{
StartDate = new DateTime(2023, 8, 16, 3, 14, 17, DateTimeKind.Utc),
EndDate = new DateTime(2023, 8, 16, 3, 14, 17, DateTimeKind.Utc),
});You can also filter delivery reports by Status and Code
var deliveryReportList = sinch.Sms.DeliveryReports.List(new ListDeliveryReportsRequest
{
Status = new List<DeliveryReportStatus>
{
DeliveryReportStatus.Delivered, DeliveryReportStatus.Dispatched, DeliveryReportStatus.Queued
},
Code = new List<string> { "400", "405" },
});Note
It's worth mentioning that all these parameters can be freely combined to create an optimal query. For example,
PageandPageSizecan be used in conjunction withStartDateandEndDateto paginate a high volume of results.
- Index Page
- Retrieve a delivery report for a batch
- Retrieve a delivery report for a specific recipient
- Retrieve a list of delivery reports