How to Get an SMS Delivery Receipt in ASP .NET MVC

Published July 21, 2017 by Rabeb Othmani

Now that you have successfully sent an SMS and received an SMS using your Nexmo number, it’s time to check the status of the message to ensure it was delivered. To do this, we have to fetch the delivery receipt, which will return the delivery status of the message.


  • A Visual Studio project
  • Nexmo Account. You can sign up here.
  • A project set up as described in the previous blog post in this tutorial series which you can find on GitHub.
  • Optional: Nexmo CLI

Receive webhooks on your localhost

The Nexmo SMS API uses webhooks to inform the ASP.NET app of the status of the sent text message. As explained in the previous tutorial, we will be using ngrok to expose the port to the internet so Nexmo’s servers can connect to it while testing.

Go back to Visual Studio and run your program, then head over to the Nexmo Dashboard . On the Settings page, towards the bottom, you will see Callback for Delivery Receipt under the API Settings. Paste the ngrok URL inside the textbox and add /SMS/DLR to the end of it. This will route the message to the Receive action in the SMS controller.

Diving into code

In this tutorial series, we started by learning how to send an SMS.

In this first tutorial, we created an ASP.NET MVC project and added a controller called SMSController.cs. Afterwards, we created two action methods. One of which was to present the view for the details of the SMS (destination number and message text) and the other was to retrieve the values from the form and send an SMS.

In the second tutorial, we created another action method to print the details of incoming SMS message to the output window.

In order to read the delivery receipt, we will create an action method called DLR in the SMSController.cs.

As you can see in the code above, you need to add [FromUri] in the parameter to be able to read the delivery receipt. Above this method, add a HTTPGetAttribute to restrict the method to handling GET requests. Print the messageID (message ID), msisdn (Nexmo virtual number), to (destination number), and the status (status message) to the output window using ‘Debug.WriteLine’.
You can check the list of status codes here.

Now you are ready to go! Send an SMS using your Nexmo virtual number and open up the output window in Visual Studio. There you should see the delivery receipt for the text you have sent! You have now successfully setup your virtual number to return a status for a text message via a webhook!

Helpful links

Nexmo Logo

Leave a Reply

Your email address will not be published.

Get the latest posts from Nexmo’s next-generation communications blog delivered to your inbox.

By signing up to our communications blog, you accept our privacy policy , which sets out how we use your data and the rights you have in respect of your data. You can opt out of receiving our updates by clicking the unsubscribe link in the email or by emailing us at