Control Your Messaging Costs by Setting a Maximum Price
Time to read: 2 minutes
When customers expand internationally, we often hear the question “How do I avoid routes that may be much more expensive than the ones I’ve used in the past?” The reality is that not all messages cost the same amount to send, and sometimes businesses prefer not to send or receive messages when the cost surpasses a certain price.
To address this, we’ve added a new feature that will allow Twilio SMS users to better control high costs by setting a maximum price for messages. This added cost control will help you avoid high or unpredictable costs that can surface when sending messages in new areas.
How it Works
This new feature enables you to set a maximum price to apply to all messages. Once you set that limit, we will not send messages that exceed your set price.
When parameter MaxPrice is used, Twilio will check the price of the message against the amount set in this parameter. ( MaxPrice is the total price of the message —the price of longer messages that consist of several segments would be compared against this price).
If the limit you set is less than the cost of the message Twilio will return a Failed status for the message in the StatusCallback. The initial response will still be 200 with a status of Queued; however, after the price has been calculated the message will return as Failed (Error Code 30010) as part of the status callback if the price exceeds your limit.
For outbound messages, the final price of the message is returned as a POST to the Status Callback URL. This POST request is made as soon as the price is available and may be a separate webhook from Status parameter updates.
Adding MaxPrice is straightforward. Here’s an example of a price set at $0.50:
-d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
-d "To=%2B15558675309" \
-d "From=%2B14158141829" \
-d "MaxPrice = 0.50"
-d "MediaUrl=http://www.example.com/hearts.png" \
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.