# Channel Fallback

When sending messages, you can specify a primary channel and one or more fallback channels. If the message fails to deliver on the primary channel, Twilio will automatically attempt to send it via the fallback channel.

## Fallback with inline rich content

You can define rich content and fallback content directly within your API request without needing to create a template. The following example shows a card message that falls back to SMS when RCS is unavailable.

```bash
POST https://comms.twilio.com/preview/Messages
```

**Request body parameters**:

```json
{
  "from": {
       "senderPoolId": "comms_senderpool_xxxx"
   },
   "to": [
       {
           "address": "+14155550102",
           "channel": "PHONE"
       }
   ],
   "content": {
       "modules": [
           {
               "rcs": {
                   "richCard": {
                       "standaloneCard": {
                           "cardContent": {
                               "title": "Delivery arriving soon!",
                               "suggestions": [
                                   {
                                       "action": {
                                           "text": "Track package",
                                           "postbackData": "tracked_package",
                                           "openUrlAction": {
                                               "url": "https://u.r.l/track/20997"
                                           }
                                       }
                                   }
                               ]
                           }
                       }
                   }
               }
           },
           {
               "sms": {
                   "text": "Track your delivery here: https://u.r.l/track/20997!"
               }
           }
       ]
   }
}
```

## Fallback with text or Content Templates (RCS to SMS)

If you have an approved RCS sender and an SMS/MMS capable phone number, you can configure Twilio to attempt delivery over RCS and fall back to SMS when RCS isn't available. To enable this behavior, create a [Sender Pool](/docs/comms/sender-pools) that includes both the phone number and the RCS sender.

When your Sender Pool includes both a text-capable phone number and an RCS sender, Twilio automatically attempts to deliver via RCS first. If the recipient's device or carrier doesn't support RCS, the message falls back to SMS.

When sending rich content, use a Content Template that contains both the RCS elements and the corresponding SMS/MMS text or media.

```bash
curl -X POST 'https://comms.twilio.com/preview/Messages' \
--header 'Content-Type: application/json' \
--data '{
   "from": {
       "senderPoolId": "comms_senderpool_xxxx"
   },
   "to": [
       {
           "address": "+19143188062",
           "channel": "PHONE",
           "variables": {
               "1": "Darth",
               "2": "Vader"
           }
       },
       {
           "address": "+19143188063",
           "channel": "PHONE",
           "variables": {
               "1": "Spongebob",
               "2": "Squarepants"
           }
       }
   ],
   "content": {
       "contentId": "HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
   }
}' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Specify channel mix and fallback order

In some cases, you might want to limit the channels that can be used when using Sender Pools. Specify optional properties in the `from` parameter to control this behavior. In the following example, the `filterIn` property prevents Twilio from sending messages over WhatsApp, even when your Sender Pool contains active WhatsApp senders. The `priority` array sets the order in which Twilio attempts each channel.

```bash
curl -X POST 'https://comms.twilio.com/preview/Messages' \
--header 'Content-Type: application/json' \
--data '{
   "from": {
       "senderPoolId": "comms_senderpool_dk2n984h",
       "channels": {
           "filterIn": ["RCS", "SMS"],
           "priority": [
               { "channel": "RCS", "priority": 0 },
               { "channel": "SMS", "priority": 1 }
           ]
       }
   },
   "to": [
       {
           "address": "+19143188062",
           "channel": "PHONE"
       }
   ],
   "content": {
       "text": "Hello there, I'\''m trying RCS first and failing over to SMS!"
   }
}' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Include multiple addresses per recipient

When you configure fallback across channels other than `RCS` and `SMS`, include the recipient's address for every channel involved.

For example, to fall back to SMS after a failed WhatsApp message, specify both of the following:

* The recipient's phone number (for SMS delivery).
* The recipient's WhatsApp-enabled phone number (for WhatsApp delivery).

```bash
curl -X POST 'https://comms.twilio.com/preview/Messages' \
--header 'Content-Type: application/json' \
--data '{
   "from": {
       "senderPoolId": "comms_senderpool_dk2n984h"
   },
   "to": [
       {
           "addresses": [
               { "address": "+12223334455", "channel": "PHONE" },
               { "address": "+13334445566", "channel": "WHATSAPP"}
           ],
           "variables": {
               "name": "Harry"
           }
       }
   ],
   "content": {
       "text": "Hello {{name}}, your order has been shipped!"
   }
}' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
