TwiML™ Voice: <Reject>

The <Reject> verb rejects an incoming call to your Twilio number without billing you. This is very useful for blocking unwanted calls.

If the first verb in a TwiML document is <Reject>, Twilio will not pick up the call. The call ends with a status of 'busy' or 'no-answer', depending on the verb's 'reason' attribute. Any verbs after <Reject> are unreachable and ignored.

Note that using <Reject> as the first verb in your response is the only way to prevent Twilio from answering a call. Any other response will result in an answered call and your account will be billed.

Verb Attributes

The <Reject> verb supports the following attributes that modify its behavior:

Attribute Name Allowed Values Default Value
reason rejected, busy rejected

reason

The reason attribute takes the values "rejected" and "busy." This tells Twilio what message to play when rejecting a call. Selecting "busy" will play a busy signal to the caller, while selecting "rejected" will play a standard not-in-service response. If this attribute's value isn't set, the default is "rejected."

Nesting Rules

You can't nest any verbs within <Reject> and you can't nest <Reject> in any other verbs.

Notes

<Reject> won't work when handling calls to the (deprecated) Twilio Sandbox number. Twilio must pick up the call to ask for the pin, at which point it's too late to reject.

Examples

Example 1: Reject a call playing a standard not-in-service message

Loading Code Samples...
Language
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • TwiML
import com.twilio.twiml.Reject;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;


public class Example {
    public static void main(String[] args) {
        Reject reject = new Reject.Builder().build();
        VoiceResponse response = new VoiceResponse.Builder().reject(reject)
            .build();

        try {
            System.out.println(response.toXml());
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
    }
}
from twilio.twiml.voice_response import Reject, VoiceResponse

response = VoiceResponse()
response.reject()

print(response)
using Twilio.TwiML;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Reject();

        System.Console.WriteLine(response.ToString());
    }
}
<?php
require_once './vendor/autoload.php';
use Twilio\Twiml;

$response = new Twiml();
$response->reject();

echo $response;
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new
response.reject

puts response
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
response.reject();

console.log(response.toString());
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Reject />
</Response>
Reject a call playing a standard not-in-service message
Loading Code Samples...
Language
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • TwiML
import com.twilio.twiml.Reject;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;
import com.twilio.twiml.Language;

public class Example {
    public static void main(String[] args) {
        Reject reject = new Reject.Builder().reason(Reject.Reason.BUSY).build();
        VoiceResponse response = new VoiceResponse.Builder().reject(reject)
            .build();

        try {
            System.out.println(response.toXml());
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
    }
}
from twilio.twiml.voice_response import Reject, VoiceResponse

response = VoiceResponse()
response.reject(reason='busy')

print(response)
using Twilio.TwiML;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Reject(reason: "busy");

        System.Console.WriteLine(response.ToString());
    }
}
<?php
require_once './vendor/autoload.php';
use Twilio\Twiml;

$response = new Twiml();
$response->reject(['reason' => 'busy']);

echo $response;
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new
response.reject(reason: 'busy')

puts response
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
response.reject({
    reason: 'busy'
});

console.log(response.toString());
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Reject reason="busy" />
</Response>
Reject a call playing a busy signal

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • TwiML
import com.twilio.twiml.Reject;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;


public class Example {
    public static void main(String[] args) {
        Reject reject = new Reject.Builder().build();
        VoiceResponse response = new VoiceResponse.Builder().reject(reject)
            .build();

        try {
            System.out.println(response.toXml());
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
    }
}
from twilio.twiml.voice_response import Reject, VoiceResponse

response = VoiceResponse()
response.reject()

print(response)
using Twilio.TwiML;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Reject();

        System.Console.WriteLine(response.ToString());
    }
}
<?php
require_once './vendor/autoload.php';
use Twilio\Twiml;

$response = new Twiml();
$response->reject();

echo $response;
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new
response.reject

puts response
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
response.reject();

console.log(response.toString());
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Reject />
</Response>
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • TwiML
import com.twilio.twiml.Reject;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;
import com.twilio.twiml.Language;

public class Example {
    public static void main(String[] args) {
        Reject reject = new Reject.Builder().reason(Reject.Reason.BUSY).build();
        VoiceResponse response = new VoiceResponse.Builder().reject(reject)
            .build();

        try {
            System.out.println(response.toXml());
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
    }
}
from twilio.twiml.voice_response import Reject, VoiceResponse

response = VoiceResponse()
response.reject(reason='busy')

print(response)
using Twilio.TwiML;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Reject(reason: "busy");

        System.Console.WriteLine(response.ToString());
    }
}
<?php
require_once './vendor/autoload.php';
use Twilio\Twiml;

$response = new Twiml();
$response->reject(['reason' => 'busy']);

echo $response;
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new
response.reject(reason: 'busy')

puts response
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
response.reject({
    reason: 'busy'
});

console.log(response.toString());
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Reject reason="busy" />
</Response>