0 Tk

Programmable SMS

Sending and Receiving SMS with Twilio

Twilio’s Programmable SMS API allows you to send and receive text messages globally.

Sending an SMS

Endpoint: POST /2010-04-01/Accounts/{AccountSid}/Messages.json

Required Parameters:

  • To: The recipient’s phone number in E.164 format
  • From: Your Twilio phone number or Messaging Service SID
  • Body: The content of your message (max 1600 characters)

Example request:

curl -X POST https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json \
--data-urlencode "To=+1XXXXXXXXXX" \
--data-urlencode "From=+1YYYYYYYYYY" \
--data-urlencode "Body=Your appointment is coming up on July 21 at 3PM" \
-u YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN

Example response:

{
  "sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "Thu, 30 Jul 2020 20:12:31 +0000",
  "date_updated": "Thu, 30 Jul 2020 20:12:33 +0000",
  "date_sent": null,
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "to": "+1XXXXXXXXXX",
  "from": "+1YYYYYYYYYY",
  "messaging_service_sid": null,
  "body": "Your appointment is coming up on July 21 at 3PM",
  "status": "queued","num_segments": "1",
  "num_media": "0",
  "direction": "outbound-api",
  "api_version": "2010-04-01",
  "price": null,
  "price_unit": "USD",
  "error_code": null,
  "error_message": null,
  "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}