Prompt
How do I send SMS from my app with an API?
Latest observation
Oct 14, 2026
OpenAI APIWeb search: off
To send SMS from your app using an API, you typically use an SMS gateway/provider such as Twilio, Vonage, AWS SNS, MessageBird, Plivo, or Telnyx.
Basic flow
- Create an account with an SMS provider.
- Get credentials like an API key, account SID, or access token.
- Buy/configure a sending number or short code if needed.
- Call the provider’s API from your backend to send a text message.
- Handle delivery status / errors using API responses or webhooks.
Important note
You should usually send SMS from your server, not directly from the mobile app or frontend, because API keys must be kept secret.
Example: Sending SMS with Twilio
cURL
curl -X POST https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json \
--data-urlencode "To=+15551234567" \
--data-urlencode "From=+15557654321" \
--data-urlencode "Body=Hello from my app!" \
-u YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN
Node.js
const twilio = require('twilio');
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
async function sendSMS() {
const message = await client.messages.create({
body: 'Hello from my app!',
from: '+15557654321',
to: '+15551234567'
});
console.log(message.sid);
}
sendSMS();
Python
from twilio.rest import Client
import os
client = Client(os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_AUTH_TOKEN"])
message = client.messages.create(
body="Hello from my app!",
from_="+15557654321",
to="+15551234567"
)
print(message.sid)
Things to watch out for
- Phone number format: Use international format, e.g.
+14155552671 - Opt-in/consent: Make sure recipients agreed to receive messages
- Rate limits: Providers and carriers may limit throughput
- Costs: SMS usually costs per message
- Delivery reports: Use webhooks if you need to know whether messages were delivered
- Compliance: Different countries have SMS regulations
If you want a quick setup
Twilio is one of the easiest options:
- Sign up
- Verify your account
- Get a phone number
- Use the API example above
- Test with your own phone
If you tell me your language/framework (JavaScript, Python, PHP, Java, mobile app, etc.) and which provider you want to use, I can give you a ready-to-run example.