Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How to Send an SMS With Twilio: Trial to First Message

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

ParameterWhat goes in it
ToThe recipient, in E.164 format
FromA Twilio phone number, an alphanumeric sender ID and others, or use a Messaging Service SID instead
BodyYour 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.

Work with me

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.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.