Potential Support Response Time Delays Due to Surge in Toll-Free Queries: We’re experiencing a surge in inquiries due to the November 8, 2023 Toll-Free Restricted Traffic Shutdown Deadline. We’re committed to helping you; please bear with us as there might be some delays. For more details, see Toll-Free Message Verification for US/Canada.

Getting started with SMS notification

In this guide you will learn the fundamentals to build your first SMS notification app.

This guide covers:

Getting a free trial number from Twilio

To send or receive SMS, you will need a phone number from Twilio. On your trial account, you can get one free USA or Canada phone number.

  1. To get your trial number, access the account dashboard, and then select Get a trial phone number.
    Step1.png
  2. Click Choose this Number.
    Step_1-2_500px.png
  3. Click Done.
    Step_1-3_500px.png

To buy more numbers, or get local phone numbers outside of the USA or Canada, you may need to upgrade your account.

Sending your first SMS

Next, copy and execute the following code in your command line/command prompt/terminal to send an SMS to yourself. You can expect to receive your SMS within 3 minutes. On a trial account, if you are sending an SMS to someone else, add their number to the verified caller ID first.

PC - Powershell (Older than Windows 10 version 1803)

Install Powershell if needed, and then open the Windows PowerShell.

# Twilio account info and phone numbers.
$sid = "ACCOUNT_SID"
$token = "AUTH_TOKEN"
$phone_number = "PHONE_NUMBER"
$verified_number = "VERIFIED_NUMBER",

# Twilio API endpoint and POST params
$url = "https://api.twilio.com/2010-04-01/Accounts/$sid/Messages.json"
$params = @{ To = $verified_number ; From = $phone_number ; Body = "Hello from Twilio" }

# Create a credential object for HTTP basic auth
$p = $token | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($sid, $p)

# Make API request, selecting JSON properties from response
Invoke-WebRequest $url -Method Post -Credential $credential -Body $params -UseBasicParsing | ConvertFrom-Json | Select sid, body
  • Replace $VERIFIED_NUMBER with the verified phone number you used to sign up with, formatted with a '+' and country code, e.g. +16175551212 (E.164 format).
  • Replace $PHONE_NUMBER with the phone number you just purchased, formatted with a '+' and country code, e.g. +14087419548 (E.164 format).
  • Replace $ACCOUNT_SID and $AUTH_TOKEN with the credentials here on the account dashboard.

PC - cURL (Windows 10 version 1803 or newer)

Open the Command Prompt.

curl -X POST https://api.twilio.com/2010-04-01/Accounts/%ACCOUNT_SID%/Messages.json ^
--data-urlencode "Body=Hi there from Twilio" ^
--data-urlencode "From=%PHONE_NUMBER%" ^
--data-urlencode "To=%VERIFIED_NUMBER%" ^
-u %ACCOUNT_SID%:%AUTH_TOKEN%
  • Replace $VERIFIED_NUMBER with the verified phone number you used to sign up with, formatted with a '+' and country code, e.g. +16175551212 (E.164 format).
  • Replace $PHONE_NUMBER with the phone number you just purchased, formatted with a '+' and country code, e.g. +14087419548 (E.164 format).
  • Replace $ACCOUNT_SID and $AUTH_TOKEN with the credentials here on the account dashboard.

Unix or MacOS

Open the Terminal app.

curl -X POST https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Messages.json \
--data-urlencode "Body=Hi there from Twilio" \
--data-urlencode "From=$TWILIO_NUMBER" \
--data-urlencode "To=$VERIFIED_NUMBER" \
-u $ACCOUNT_SID:$AUTH_TOKEN
  • Replace $VERIFIED_NUMBER with the verified phone number you used to sign up with, formatted with a '+' and country code, e.g. +16175551212 (E.164 format).
  • Replace $PHONE_NUMBER with the phone number you just purchased, formatted with a '+' and country code, e.g. +14087419548 (E.164 format).
  • Replace $ACCOUNT_SID and $AUTH_TOKEN with the credentials here on the account dashboard.
    Step2.png

 

Additional Resources

A step-by-step tutorial on sending SMS notifications

Explore a functional SMS notification app sample here. This app allows you to broadcast sms messages to a list of verified phone numbers on your trial account.

Follow our tutorial and learn line-by-line how to send SMS messages.

How to send SMS and MMS messages

Additional documentation

Best practices on scaling

Congratulations, you learned how to build your first SMS notification app! Before you upgrade your account to remove the trial restrictions, we recommend you read through some of the materials below to make sure you get the most out of your Twilio experience.

Note: To buy a local phone number outside of the USA or Canada, you may be required to meet regulatory compliance.

Scaling best practices

Account and pricing

Regulations and policies

When you are ready to upgrade, simply go to the account dashboard and select the “Upgrade Project” button.

Have more questions? Submit a request
Powered by Zendesk