In case of low (zero) account balance in Twilio,
1. Will Twilio stop to hit the Application VoiceUrl associated with the account
2. Is there any way to know the low balance without reaching Twilio console?

- 75
- 8
2 Answers
Twilio developer evangelist here.
When you are at a low, non-zero balance, Twilio will continue to act as normal.
When you hit zero, from the Twilio help centre:
When your account balance reaches zero you will no longer be able to make and receive phone calls or send and receive SMS messages. You won't lose your phone numbers right away.
We will continue to bill your account for 60 days for the phone numbers you've purchased. If you pay off your balance and fund your account with a minimum of $20, you’ll be able to use your phone numbers again. After 60 days, if you haven't replenished your Twilio account balance, we may close your account and return your phone numbers to our pool of available numbers.
In order to stop your account seizing up, you can set up an auto recharge trigger which will top up your account when it gets low.
Alternatively, according to this page
It is possible to also set a notification trigger that will just email you when your balance falls below a chosen threshold. If you'd like to enable this please contact Support.
So, you can get a trigger at a chosen balance which you know.
Let me know if this helps at all.
-
So, if my account has zero balance and my application's Twilio Client calls Twilio.Device.connect(params), the webhook associated with the application won't be called. Is it right? – Aatitya Nov 02 '16 at 10:35
-
I'm not 100% sure what happens here, but my guess is that the `Twilio.Device` won't connect and you will receive an error. Alternatively, the `Twilio.Device` may receive an error event when you try to set it up and never receive the `ready` callback. If you have zero balance, you won't be able to make calls. – philnash Nov 02 '16 at 10:39
-
1Is there any specific error code or message so as to identify it and inform the app-users? – Aatitya Nov 02 '16 at 10:49
-
I don't actually have any experience of this myself. I'd look out for [Error 10001](https://www.twilio.com/docs/api/errors/10001) or you may just get a [31000 or 31002](https://www.twilio.com/docs/api/client/errors). I'd recommend setting up auto recharge so that you don't receive these errors at all though. – philnash Nov 02 '16 at 10:54
-
Thanks a lot! In fact, I am trying to develop an app which can inform the users about the zero account balance in case of call failure due to it. – Aatitya Nov 02 '16 at 11:16
-
In that case I would test against an account that has run out and see what error you get. But I would look for it in the `Twilio.Device.error(function(err) { });` callback. – philnash Nov 02 '16 at 16:58
Just query the account balance first before making calls / sending SMS:
using System.Net;
using Newtonsoft.Json;
string url = "https://api.twilio.com/2010-04-01/Accounts/" + accountSid + "/Balance.json";
var client = new WebClient();
client.Credentials = new NetworkCredential(accountSid, authToken);
string responseString = client.DownloadString(url);
dynamic responseObject = JsonConvert.DeserializeObject<object>(responseString);
double accountBalance = Double.Parse(responseObject["balance"].Value);
accountBalance = Math.Round((double)accountBalance,2);
https://support.twilio.com/hc/en-us/articles/360025294494-Check-Your-Twilio-Project-Balance

- 356
- 3
- 11