Setting SMS messaging preferences in Amazon SNS
Use Amazon SNS to specify preferences for SMS messaging. For example, you can specify whether to optimize deliveries for cost or reliability, your monthly spending limit, how deliveries are logged, and whether to subscribe to daily SMS usage reports.
These preferences take effect for every SMS message that you send from your account, but you can override some of them when you send an individual message. For more information, see Publishing SMS messages to a mobile phone using Amazon SNS.
Topics
Setting SMS messaging preferences using the AWS Management Console
Sign in to the Amazon SNS console
. -
Choose a region that supports SMS messaging.
-
On the navigation panel, choose Mobile and then Text messaging (SMS).
-
On the Mobile text messaging (SMS) page, in the Text messaging preferences section, choose Edit.
-
On the Edit text messaging preferences page, in the Details section, do the following:
-
For Default message type, choose one of the following:
-
Promotional – Non-critical messages (for example, marketing). Amazon SNS optimizes message delivery to incur the lowest cost.
-
Transactional (default) – Critical messages that support customer transactions, such as one-time passcodes for multi-factor authentication. Amazon SNS optimizes message delivery to achieve the highest reliability.
For pricing information for promotional and transactional messages, see Global SMS Pricing
. -
-
(Optional) For Account spend limit, enter the amount (in USD) that you want to spend on SMS messages each calendar month.
Important
-
By default, the spend quota is set to 1.00 USD. If you want to raise the service quota, submit a request
. -
If the amount set in the console exceeds your service quota, Amazon SNS stops publishing SMS messages.
-
Because Amazon SNS is a distributed system, it stops sending SMS messages within minutes of the spend quota being exceeded. During this interval, if you continue to send SMS messages, you might incur costs that exceed your quota.
-
-
-
(Optional) For Default sender ID, enter a custom ID, such as your business brand, which is displayed as the sender of the receiving device.
Note
Support for sender IDs varies by country.
-
(Optional) Enter the name of the Amazon S3 bucket name for usage reports.
Note
The Amazon S3 bucket policy must grant write access to Amazon SNS.
-
Choose Save changes.
Setting preferences (AWS SDKs)
To set your SMS preferences using one of the AWS SDKs, use the action in that SDK
that corresponds to the SetSMSAttributes
request in the Amazon SNS API. With
this request, you assign values to the different SMS attributes, such as your monthly
spend quota and your default SMS type (promotional or transactional). For all SMS
attributes, see SetSMSAttributes in the Amazon Simple Notification Service API Reference.
The following code examples show how to use SetSMSAttributes
.
Setting SMS messaging preferences for country-specific delivery
You can manage and control your SMS traffic by sending messages only to specific destination countries. This ensures that your messages are sent only to approved countries, avoiding unwanted SMS charges. The following instructions use Amazon Pinpoint's Protect configuration to specify the countries you want to allow or block.
Open the AWS SMS console at https://console.aws.amazon.com/sms-voice/
. -
In the navigation pane, under Overview, in the Quick start section, choose Create a protect configuration.
-
Under Protect configuration details, enter a business-friendly name for your protect configuration (for example, Allow-Only-AU).
-
Under SMS country rules, select the Region/Country checkbox to block sending messages to all supported countries.
-
Deselect the checkboxes for the countries where you want to send messages. For example, to allow messages only to Australia, deselect the checkbox for Australia.
-
In the Protect configuration associations section, under Association type, select Account default. This will ensure that the AWS End User Messaging SMS Protect configuration affects all messages sent through Amazon SNS, Amazon Cognito, and the Amazon Pinpoint
SendMessages
API call. -
Choose Create protect configuration to save your settings.
The following confirmation message is displayed:
Success Protect configuration protect-abc0123456789 has been created.
Sign in to the Amazon SNS console
. -
Publish a message to one of the blocked countries, such as India.
The message will not be delivered. You can verify this in the delivery failure logs using CloudWatch. Search for log group sns/region/AccountID/DirectPublishToPhoneNumber/Failure for a response similar to the following example:
{ "notification": { "messageId": "bd59a509-XXXX-XXXX-82f8-fbdb8cb68217", "timestamp": "YYYY-MM-DD XX:XX:XX.XXXX“ }, "delivery": { "destination": "+91XXXXXXXXXX", "smsType": "Transactional", "providerResponse": "Cannot deliver message to the specified destination country", "dwellTimeMs": 85 }, "status": "FAILURE" }