

# Phone number override rules in AWS End User Messaging SMS
<a name="protect-rule-override"></a>

You can use a phone number override rule to override the country mode and ensure important phone numbers are always allowed or blocked. For example if you have an application that you only want to be able to send messages to your employees, you could block sending to every country and add phone number override rules for each employee phone number.

Additionally, you can integrate with your customer data platforms (CDPs), contact centers, or other internal tools to dynamically apply overrides based on customer value or support requests. For example, high-value customers identified in a CDP could receive SMS message allowlists, or a customer support agent could initiate an override for a customer complaining about not receiving SMS messages. Phone number overrides can be set as permanent or with an expiration date.

**Topics**
+ [How phone number override rules are processed](protect-rule-override-rules-processing.md)
+ [Create a phone number override rule](protect-rule-override-rules-create.md)
+ [Query phone number override rule](protect-rule-override-rules-querying.md)
+ [Edit a phone number override rule](protect-rule-override-rules-update.md)
+ [Delete a phone number override rule](protect-rule-override-rules-delete.md)

# How phone number override rules are processed in AWS End User Messaging SMS
<a name="protect-rule-override-rules-processing"></a>

If a phone number is in the opt-out list then the message is not sent regardless if there is an override to allow. The phone number override always takes precedent over the country rule mode. For example, if the country rule mode is block and a phone number override rule is always allow then sending to the phone number is allowed. The opposite is also true, if the country rule mode is allow and a phone number override rule is always block then sending to the phone number is not allowed. 

![\[Shows the decisions for using a phone number override rule.\]](http://docs.aws.amazon.com/sms-voice/latest/userguide/images/phone-number-override-rule-process.png)


# Create a phone number override rule in AWS End User Messaging SMS
<a name="protect-rule-override-rules-create"></a>

To create a new phone number override rule, you can use the AWS End User Messaging SMS console, the [PutProtectConfigurationRuleSetNumberOverride](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_PutProtectConfigurationRuleSetNumberOverride.html) action in the AWS End User Messaging SMS and voice v2 API, or the [put-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/put-protect-configuration-rule-set-number-override.html) command in the AWS CLI. This section shows how to create a phone number override rule using the AWS End User Messaging SMS console and the AWS CLI.

------
#### [ Create a phone number rule override (Console) ]

To create a phone number override rule using the AWS End User Messaging SMS console, follow these steps:

1. Open the AWS End User Messaging SMS console at [https://console.aws.amazon.com/sms-voice/](https://console.aws.amazon.com/sms-voice/).

1. In the navigation pane, under **Protect**, choose **Protect configuration** and then choose the protect configuration to add a new phone number override rule to.

1. Choose the **Rule overrides** tab and in the **Rules override** section choose **Add override**.

1. In the **Rule override details** section, enter the following:

   1. For **Destination phone number** enter the phone number to create the rule for. The phone number must start with a '\$1' and can't contain any spaces, hyphens, or parentheses. For example, `+1 (206) 555-0142` is not in the correct format, but `+12065550142` is.

   1. For **Override type** choose either **Always allow** or **Always block**.

   1. For **Expiration date – optional** choose a date for the rule expire or leave it blank for the rule to never expire.

1. Choose **Add rule override**.

------
#### [ Create a phone number rule override (AWS CLI) ]

You can use the [put-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/put-protect-configuration-rule-set-number-override.html) AWS CLI command to create a new phone number rule override. 

**Note**  
Because `--expiration-timestamp` is not specified this rule will never expire.

```
$ aws pinpoint-sms-voice-v2 put-protect-configuration-rule-set-number-override --protect-configuration-id ProtectConfigurationID --destination-phone-number +12065550150 --action ACTION
```

In the preceding command, make the following changes:
+ Replace *ProtectConfigurationID* with the unique identifier of the protect configuration.
+ Replace *\$112065550150* with the phone number to create a rule for.
+ Replace *ACTION* with *ALLOW* to allow messages to be sent to the phone number or *BLOCK* to not allow messages to the phone number.

------

# Query phone number override rule in AWS End User Messaging SMS
<a name="protect-rule-override-rules-querying"></a>

To query phone number override rules, you can use the AWS End User Messaging SMS console, the [ListProtectConfigurationRuleSetNumberOverrides](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_ListProtectConfigurationRuleSetNumberOverrides.html) action in the AWS End User Messaging SMS and voice v2 API, or the [list-protect-configuration-rule-set-number-overrides](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/list-protect-configuration-rule-set-number-overrides.html) command in the AWS CLI. This section shows how to query phone number override rules using the AWS End User Messaging SMS console and the AWS CLI. 

------
#### [ List phone number rule override (Console) ]

To query a phone number override rule using the AWS End User Messaging SMS console, follow these steps:

1. Open the AWS End User Messaging SMS console at [https://console.aws.amazon.com/sms-voice/](https://console.aws.amazon.com/sms-voice/).

1. In the navigation pane, under **Protect**, choose **Protect configuration** and then choose the protect configuration.

1. Choose the **Rule overrides** tab.

1. In **Query rule overrides** you can search for rules with a combination of all three of the available fields **Destination phone number**, **Override type**, and **Date**:

   1. For **Destination phone number**:
      + All numbers – Do not filter out any phone numbers.
      + Number lookup – Enter a prefix or full phone number to filter on.
      + By country – Choose a country to filter on.

   1. For **Override type**:
      + Always allowed – Only return allow rules.
      + Always blocked – Only return block rules.

   1. For **Date**
      + All dates – Do not filter out any dates.
      + Recently added – Return phone number override rules that were created in the last 24 hours.
      + Expires before – Return phone number override rules that expire before the specified date.
      + Expires on – Return phone number override rules that expire on the specified date.
      + Expires after – Return phone number override rules that expire after the specified date.

1. Choose **Query**.

   Any phone number override rules that match your query are returned in the **Query results **section. You can choose rules from the section to edit or delete.

------
#### [ List phone number rule override (AWS CLI) ]

You can use the [list-protect-configuration-rule-set-number-overrides](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/list-protect-configuration-rule-set-number-overrides.html) AWS CLI command to list all phone number rule overrides in a protect configuration. 

```
$ aws pinpoint-sms-voice-v2 list-protect-configuration-rule-set-number-overrides --protect-configuration-id ProtectConfigurationID
```

In the preceding command, make the following changes:
+ Replace *ProtectConfigurationID* with the unique identifier of the protect configuration.

------

# Edit a phone number override rule in AWS End User Messaging SMS
<a name="protect-rule-override-rules-update"></a>

To edit a phone number override rule, you can use the AWS End User Messaging SMS console, the [PutProtectConfigurationRuleSetNumberOverride](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_PutProtectConfigurationRuleSetNumberOverride.html) action in the AWS End User Messaging SMS and voice v2 API, or the [put-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/put-protect-configuration-rule-set-number-override.html) command in the AWS CLI. This section shows how to create a phone number override rule using the AWS End User Messaging SMS console and the AWS CLI. You can choose multiple phone number override rules at a time to make bulk edits.

------
#### [ Edit a phone number rule override (Console) ]

To edit a phone number override rule using the AWS End User Messaging SMS console, follow these steps:

1. Open the AWS End User Messaging SMS console at [https://console.aws.amazon.com/sms-voice/](https://console.aws.amazon.com/sms-voice/).

1. In the navigation pane, under **Protect**, choose **Protect configuration** and then choose the protect configuration.

1. Choose the **Rule overrides** tab and in the **Rules override** section choose the phone number override rules to change. You can use [Query phone number override rules](protect-rule-override-rules-querying.md#protect-rule-override-rules-querying.title) to search for specific rules to edit. Choose **Edit**. 

1. The **Destination phone numbers** section you can view the details about all of you phone number override rule. 

    You can remove a phone number override rule from being edited by choosing **Remove** in the **Action** column.

1. For **Override type** choose either **Always allow** or **Always block**.

1. For **Expiration date – optional** choose a date for the rule expire or leave it blank for the rule to never expire.

1. Choose **Save changes**.

------
#### [ Edit a phone number rule override (AWS CLI) ]

You can use the [put-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/put-protect-configuration-rule-set-number-override.html) AWS CLI command to edit a new phone number rule override. 

**Note**  
Because `--expiration-timestamp` is not specified this rule will never expire.

```
$ aws pinpoint-sms-voice-v2 put-protect-configuration-rule-set-number-override --protect-configuration-id ProtectConfigurationID --destination-phone-number +12065550150 --action ACTION
```

In the preceding command, make the following changes:
+ Replace *ProtectConfigurationID* with the unique identifier of the protect configuration.
+ Replace *\$112065550150* with the phone number to create a rule for.
+ Replace *ACTION* with *ALLOW* to allow messages to be sent to the phone number or *BLOCK* to not allow messages to the phone number.

------

# Delete a phone number override rule in AWS End User Messaging SMS
<a name="protect-rule-override-rules-delete"></a>

To delete a phone number override rule, you can use the AWS End User Messaging SMS console, the [DeleteProtectConfigurationRuleSetNumberOverride](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_DeleteProtectConfigurationRuleSetNumberOverride.html) action in the AWS End User Messaging SMS and voice v2 API, or the [delete-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/delete-protect-configuration-rule-set-number-override.html) command in the AWS CLI. This section shows how to delete a phone number override rule using the AWS End User Messaging SMS console and the AWS CLI. 

------
#### [ Delete a phone number rule override (Console) ]

To delete a phone number override rule using the AWS End User Messaging SMS console, follow these steps:

1. Open the AWS End User Messaging SMS console at [https://console.aws.amazon.com/sms-voice/](https://console.aws.amazon.com/sms-voice/).

1. In the navigation pane, under **Protect**, choose **Protect configuration** and then choose the protect configuration.

1. Choose the **Rule overrides** tab and in the **Rules override** section choose the phone number override rules to delete. You can use [Query phone number override rules](protect-rule-override-rules-querying.md#protect-rule-override-rules-querying.title) to search for specific rules to edit. Choose **Delete**.

1. In the **Delete rule override** window, enter **confirm**, and the choose **Delete**

------
#### [ Delete a phone number rule override (AWS CLI) ]

You can use the [delete-protect-configuration-rule-set-number-override](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/delete-protect-configuration-rule-set-number-override.html) AWS CLI command to delete a phone number rule override. 

```
$ aws pinpoint-sms-voice-v2 delete-protect-configuration-rule-set-number-override --protect-configuration-id ProtectConfigurationID --destination-phone-number +12065550150
```

In the preceding command, make the following changes:
+ Replace *ProtectConfigurationID* with the unique identifier of the protect configuration.
+ Replace *\$112065550150* with the phone number to delete the rule for.

------