How Can I Stop Receiving or Block Incoming Phone Calls?

All Twilio phone numbers go through a testing process before they're made available for purchase. Unfortunately, some unwanted calls may continue to reach your Twilio line. Here are some tips to help prevent these calls from becoming a problem.

Block All Incoming Calls

If you do not want to receive any phone calls on your Twilio phone number, you can configure your number with a blank Voice Webhook URL. With an empty webhook, this phone number is considered 'out of service' for inbound calls. You will not be charged for any incoming calls in this state, nor will these calls be received and logged in your project.

Steps for submitting a blank Voice Webhook URL on your on your Twilio number can be found here: Configuring Phone Numbers to Receive Voice Calls.

Reject and Track All Incoming Calls

You can achieve similar results by responding to incoming calls with the <Reject> TwiML verb. The only difference is that using <Reject> logs these incoming calls in your Twilio project logs; calls will continue to be blocked at no charge to you.

The easiest way to do this is with a TwiML Bin. Here are the instructions:

  1. Login to your account at www.twilio.com/console.
  2. Click Runtime from the left-side navigation bar.
    NOTE: If Runtime is not visible, you may first need to click All Products & Services.
  3. Click TwiML Bins, and then select Create New TwiML Bin, or the red plus + sign button.
  4. Add a Friendly Name and some TwiML, and then click Create.
    • Friendly Name: This is up to you - we select using something that gives an idea of what the TwiML Bin will do like “Reject Calls”.
    • TwiML: For the code, you will use the <Reject> verb. Your code should look something like this:
      <Response>
          <Reject />
      </Response>
  5. Configure this TwiML bin on your Twilio number by following the steps here: Configuring phone numbers to receive calls or SMS messages.

Reject Specific Callers

To reject phone calls coming from specific numbers, you can create a "virtual blacklist" with a few lines of code. This will respond to any unwanted callers you list with the <Reject> TwiML verb, and then forward other callers as normal. Here are some instructions along with example code for use with Twilio Functions (Beta):

  1. Login to your account at www.twilio.com/console.
  2. Click Runtime from the left-side navigation bar.
    NOTE: If Runtime is not visible, you may first need to click All Products & Services.
  3. Click Functions, and then select Create a Function, or the red plus + sign button.
  4. Select the Blank template, and then click Create.
  5. Add a Path and update the CODE field, and then click Save.
    • Path: This is up to you - we select using something that gives an idea of what the Function will do like “blacklist”.
    • CODE: In this field, copy and paste the code below. Be sure to update line 2 with your target forward-to phone number ("+13105555555"), and line 3 with the phone numbers you want to block calls from ("+12125551234", "+17025556789").
      exports.handler = function(context, event, callback) {
        let phoneNumber = event.PhoneNumber || "+13105555555";
      let blacklist = event.blacklist || [ "+12125551234", "+17025556789" ]; let twiml = new Twilio.twiml.VoiceResponse();
      let blocked = true;
      if (blacklist.length > 0) {
      if (blacklist.indexOf(event.From) === -1) {
      blocked = false;
      }
      } if (blocked) {
      twiml.reject();
      }
      else {
      twiml.dial(phoneNumber);
      }
      callback(null, twiml);
      };
  6. Configure this Function on your Twilio number by following the steps here: Configuring Phone Numbers to Receive Voice Calls.

Twilio Marketplace Add-ons (Beta)

We have also begun offering pre-integrated partner technologies to help block calls. We offer a number of add-ons to help diagnose both suspected spam and robocalls. More details can be found on our Marketplace Add-ons site.

Have more questions? Submit a request
Powered by Zendesk