Check Twilio's SMS service availability

Hi all, I'm developing an API health check endpoint on NestJS to verify if Twilio's SMS service is up & running. What's the best URL to check/ping this? Currently I'm thinking of https://status.twilio.com/api/v2/status.json Am I thinking right or there is a better alternative out there? Maybe Twilio's API offer this out of the box? (I didn't found anything, though) Thanks!

Tagged:

Answers

  • Hey @joao.fernandes! The best ways to subscribe to status updates for the Twilio service are under the "Subscribe to updates" button on the Status Page (top right of the page on desktop).

    Polling for the status is not the most efficient way to get real time updates, I'd recommend subscribing to get webhook notifications. That way your application can receive a notification that something is wrong with the Twilio API as soon as we know about it. You can also receive text messages or email notifications so that you can stay on top of status updates too.

  • Thanks for the tips and the quick reply, @pnash .

    Polling for the status is not the most efficient way to get real time updates, I'd recommend subscribing to get webhook notifications. That way your application can receive a notification that something is wrong with the Twilio API as soon as we know about it. You can also receive text messages or email notifications so that you can stay on top of status updates too.

    Although this seems like an interesting idea (and one that I will be definitely looking up in the future), in fact what I am looking right now is a more basic way to check Twillio's SMS service healthiness (i.e. on request). So I was wondering if there was a "magic" address where I could get this information, and if the closest to it is https://status.twilio.com/api/v2/status.json, or other URL.

  • Can you explain the intended use-case? I am concerned that the JSON URL you have there is not of a sufficient granularity to tell you enough about the service. For example, as I write this, that URL is reporting a partial degraded service, but that is due to inbound SMS failures to a subset of Twilio Denmark long codes. So if you are sending SMS messages, that doesn't have any bearing on that.

    So, if you can help me understand what you plan to do with the API health check endpoint we can work together on a good way to handle this.

  • After discussing this feature internally, I understand now that what I'm looking for is a different type of health check: for now, it will only try to authenticate to the Twilio account. After testing the authentication credentials, it should return if it was successful (or not). With this in mind, I searched a little and even came across a @pnash response @ S.O. :smile: : https://stackoverflow.com/a/48272545/1344434

    So, from what I've learned, after instantiating the Client object with the credentials, there isn't a dedicated endpoint to validate credentials, i.e. I'll have to pick another endpoint, like the one you mentioned there? (e. g. list my latest messages)

    Just confirming this since that answer is ~3.5 years old, something could have changed. Thanks!

  • Honestly, the easiest and best way to check whether the API is up is to make the API request that you need and handle any failures at that point. Calling an API endpoint that you don't need in order to check the API health or your credentials is just adding unnecessary load to the API. Just make sure you are handling and reporting on failures in your application and you will have a good experience.