To send an SMS with Twilio, sign up, get an SMS-capable number, copy your Account SID and create an API key, then call the Messages API with To, From (or a Messaging Service) and Body. During a trial, the From must be your assigned trial number and the To a verified recipient. Bodies can be up to 1,600 characters.
What the trial lets you do
Start here, because it's the reason most first messages fail. In Twilio's quickstart sample code, a trial account sends from its assigned trial number to a verified recipient. Try to text a number you haven't verified and it won't work the same way. Verify your own mobile first and use it for everything until you've moved off the trial.
The quickstart sends and receives text messages programmatically with the Programmable Messaging REST API, the Twilio SDKs and the Twilio Virtual Phone. If you'd rather not write code at all, Twilio documents a no-code route through Twilio Studio.
From sign-up to a sent message
1. Sign up
Sign up for Twilio and choose Continue with trial. The trial gives you an assigned number to send from, and that's the one you'll use for now.
2. Open SMS in the Console
In the Console, open Messaging, find SMS under Popular channels and click Try out SMS. Verify a recipient number while you're there. On the legacy Console route, you get a phone number with SMS capabilities from the Account Dashboard, or via Phone Numbers > Manage > Buy a number.
3. Get your credentials
Copy your Account SID from the Console and create an API key, then copy its SID and Secret. Twilio shows the secret only once, so store it somewhere safe straight away.
4. Install an SDK
Install the Twilio SDK for your language, or call the REST API directly. The quickstart SDKs cover Python, Node.js, PHP, C#, Java, Go and Ruby, and the SDK handles authentication, so you won't have to build that yourself.
5. Create the message
Call the Messages create method with To, From and Body. The table below shows what each one needs.
6. Check the result
Look at the message status and the segment count in the response. The message resource reports how many SMS segments delivery took.
The three parameters that matter
| Parameter | What goes in it |
|---|---|
| To | The recipient, in E.164 format |
| From | A Twilio phone number, an alphanumeric sender ID and others, or use a Messaging Service SID instead |
| Body | Your message, up to 1,600 characters |
The To number must be in E.164 format, so check how numbers are stored before you send, especially if they come from a form or spreadsheet.
Long bodies become several segments
Twilio Docs point out the second limit worth knowing. Messages over 160 GSM-7 characters, or 70 UCS-2 characters, are segmented, so a single 1,600-character body can mean many segments. An emoji or curly quote pushes a message into UCS-2. Keep first messages short and plain, and check the segment count in the response so you'll know what you're sending.
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
Receiving replies
Sending's only half the job. To receive messages while you're building, the quickstart uses ngrok to expose your local server so Twilio can reach it. Once that works, you can reply to incoming texts from your own code.
Before you go live
- Use environment variables and API keys, not hardcoded credentials, as Twilio advises for production.
- Move off the trial number to your own SMS-capable number.
- Keep messages under 160 GSM-7 characters where you can.
- Log the segment count for each message so long texts don't surprise you.
Other SMS APIs
Vonage has an SMS API for sending and receiving text messages, and Telnyx documents a Send Your First Message guide for its messaging API. For a wider comparison, see my Twilio alternatives. If WhatsApp is on your list too, my piece on whether the WhatsApp Business API through Twilio is worth it covers that route.
My advice for your first Twilio SMS
Verify your own mobile, send from the trial number to it, and get one plain, short message through before you build anything bigger. Store the API secret the moment you see it, write numbers in E.164, and read the segment count in every response. Then move to environment variables and your own number before a single customer gets a text.
Want your tool on this list? Featured spots and reviews here are paid partnerships. Here's how to partner with me.
Frequently asked questions
Can I send SMS from Twilio without code?
Yes. Twilio documents a no-code quickstart with Twilio Studio.
What format must the phone number be in?
E.164 for the To number.
How long can a Twilio SMS be?
The Body can be up to 1,600 characters; over 160 GSM-7 or 70 UCS-2 characters, it's segmented.
Why can't I text any number on a trial?
The quickstart sends from the assigned trial number to a verified recipient.
Which languages have SDKs?
The quickstart covers Python, Node.js, PHP, C#, Java, Go and Ruby.


