Send SMS via Twilio from API request
API toolWorkatoRecipe ToolsDeveloper ToolMarketingAPI Integration
What it does
When someone posts to the /sms endpoint with a phone number and message body, this automation validates the input and sends the SMS through Twilio. It returns the message status and ID so the caller knows the result.
Who it's for
Engineering teams who need to send SMS messages programmatically without managing Twilio credentials directly.
How teams use this
Send transactional SMS from web app
A web application posts to /sms to notify users of order confirmations or password resets. The API returns the message ID so the app can track delivery.
Route SMS through different senders
Extend the endpoint to accept a smsSource parameter that selects which sender number to use for different message types. Only the from field changes based on the source.
Track SMS delivery in database
Add a step after Twilio responds to log the message ID, status, and recipient in a database. The team can then query delivery reports without calling Twilio.
Alert on SMS failures
Retarget this automation to send alerts to an ops channel when Twilio returns an error. The validation and request call stay the same, only the error handling changes.
How it works
- Receive SMS request. Accept a POST request to the /sms endpoint with a phone number, message body, and optional sender number and callback link.
- Validate phone numbers. Check that the recipient and sender phone numbers start with a plus sign. Return a 400 error if either is invalid.
- Send SMS via Twilio. Post the message to Twilio with the phone numbers, body text, and callback link. Twilio returns the message ID and status.
- Reply with result. Return the Twilio response including message ID, status, and account details to the caller. Log any errors for debugging.