Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

TwiML™ SMS: <Redirect>


The <Redirect> verb transfers control of a Message response to the TwiML at a different URL. All verbs after <Redirect> are unreachable and ignored.


Verb Attributes

attributes page anchor

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

Attribute NameAllowed ValuesDefault Value
methodGET, POSTPOST

method

attributes-method page anchor

The 'method' attribute takes the value GET or POST. This tells Twilio whether to request the <Redirect> URL via HTTP GET or POST. POST is the default.


The "noun" of a TwiML verb is the stuff nested within the verb that's not a verb itself; it's the stuff the verb acts upon. These are the nouns(link takes you to an external page) for <Redirect>:

NounTwiML Interpretation
plain textAn absolute or relative URL for a different TwiML document.

No verbs can be nested within <Redirect> and <Redirect> can't be nested in any other verbs.


Example 1: Absolute URL redirect

examples-1 page anchor

In this example, we have a <Redirect> verb. <Redirect> makes a request to http://www.foo.com/nextInstructions and transfers control to the TwiML returned from that request.

Absolute URL redirect

absolute-url-redirect page anchor
Node.js
Python
C#
Java
PHP
Ruby

_10
const MessagingResponse = require('twilio').twiml.MessagingResponse;
_10
_10
const response = new MessagingResponse();
_10
response.redirect('http://www.example.com/nextInstructions');
_10
_10
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Redirect>
_10
http://www.example.com/nextInstructions
_10
</Redirect>
_10
</Response>

Example 2: Relative URL redirect

examples-2 page anchor

Redirects flow control to a TwiML at a URL relative to the current URL.

Node.js
Python
C#
Java
PHP
Ruby

_10
const MessagingResponse = require('twilio').twiml.MessagingResponse;
_10
_10
const response = new MessagingResponse();
_10
response.redirect('../nextInstructions');
_10
_10
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Redirect>
_10
../nextInstructions
_10
</Redirect>
_10
</Response>


Rate this page: