Twilio

Twilio API

Send SMS, MMS and WhatsApp, place voice calls with TwiML, send and check Verify codes and look up phone numbers.

CommunicationGuided#sms#whatsapp#voice#otp#verify#lookup

Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.

Overview

Twilio is a cloud communications platform. This guided collection covers the four products most apps start with: Programmable Messaging (SMS, MMS and WhatsApp through the Messages resource), Programmable Voice (outbound calls driven by TwiML), Verify v2 (one-time codes over SMS, voice, email or WhatsApp) and Lookup v2 (phone number validation and line type).

Get credentials

  1. Sign up at https://www.twilio.com/try-twilio and verify your own phone number. A trial account gets a small credit.
  2. Open the Console home at https://console.twilio.com and copy the Account SID (starts with AC) and the Auth Token. For production, create an API key instead (Console > Account > API keys & tokens) and use its SID and secret as the username and password.
  3. Buy or claim a phone number with SMS and voice capability (Console > Phone Numbers > Manage > Buy a number) and put it in fromNumber.
  4. For WhatsApp testing, join the WhatsApp Sandbox (Console > Messaging > Try it out > Send a WhatsApp message) and copy the sandbox sender into whatsappFrom with the whatsapp: prefix.

Trial accounts can only send to numbers you have verified in the Console (Verified Caller IDs), and every trial message carries a trial prefix.

Authentication

HTTP Basic auth on every request: username = Account SID (or API key SID), password = Auth Token (or API key secret). Request bodies are form-urlencoded (To, From, Body and so on, with capitalised names), not JSON. Responses are JSON with snake_case fields.

Base URLs

ProductBase URL
Messaging, Voice, accounthttps://api.twilio.com/2010-04-01 (paths end in .json)
Verifyhttps://verify.twilio.com/v2
Lookuphttps://lookups.twilio.com/v2

There is no separate sandbox host: test credentials (Console > API keys & tokens > Test credentials) exist for a few resources, but most testing is done on a trial account with real numbers.

Variables and run order

Fill accountSid, authToken, fromNumber and toNumber (your verified phone, E.164 like +15555550100). Run 1. Start here to confirm the credentials, then 2. Messaging (the send requests save messageSid), 3. Voice (saves callSid), 4. Verify (create a service first; it saves verifyServiceSid) and 5. Lookup.

Limits and pricing

Messaging and voice are billed per segment or per minute, by country; Verify is billed per successful verification and Lookup data packages are billed per request (basic validation is free). Throughput depends on the sender type (long code, toll-free, short code, Messaging Service). See https://www.twilio.com/en-us/pricing and https://www.twilio.com/docs/usage/api/api-rate-limits. US A2P 10DLC registration is required before sending application traffic from US long codes.

Common errors

CodeMeaningWhat to do
20003 (401)Authentication failedCheck the Account SID / Auth Token pair, or the API key SID and secret.
20404 (404)Resource not foundThe SID is wrong or belongs to another account.
21211Invalid To numberSend E.164 (+ and country code).
21608Trial account, unverified recipientVerify the number in the Console or upgrade.
21610Recipient replied STOPDo not message them until they opt back in.
63016WhatsApp freeform outside the 24-hour windowSend an approved template (ContentSid).
60202 (429)Verify: maximum of five check attempts reachedWait for the verification to expire (10 minutes), then start a new one.
429Too many requestsBack off and retry with jitter.

Links

  • API reference: https://www.twilio.com/docs/usage/api
  • Messages resource: https://www.twilio.com/docs/messaging/api/message-resource
  • Calls resource: https://www.twilio.com/docs/voice/api/call-resource
  • Verify API: https://www.twilio.com/docs/verify/api
  • Lookup v2: https://www.twilio.com/docs/lookup/v2-api
  • Error dictionary: https://www.twilio.com/docs/api/errors

Endpoints 24

1. Start here

  • GETFetch your account/Accounts/{{accountSid}}.jsonReads the account the credentials belong to. Run it first: a 200 proves Basic auth works, and status tells you whether the account is active, suspended or…
  • GETList your phone numbers/Accounts/{{accountSid}}/IncomingPhoneNumbers.jsonLists the phone numbers you own (incoming phone numbers) with their capabilities (sms, mms, voice). Pick one as fromNumber. Use PageSize to control page…

2. Messaging (SMS, MMS, WhatsApp)

  • POSTSend an SMS/Accounts/{{accountSid}}/Messages.jsonSends one SMS. To is the recipient in E.164 form, From one of your Twilio numbers (or use MessagingServiceSid instead), Body the text (long text is split into…
  • POSTSend an MMS with an image/Accounts/{{accountSid}}/Messages.jsonSends a picture message by adding MediaUrl, a public HTTPS URL Twilio downloads and attaches. MMS works on US and Canadian numbers; elsewhere Twilio may…
  • POSTSend through a Messaging Service/Accounts/{{accountSid}}/Messages.jsonUses a Messaging Service (MG... SID) as the sender instead of a single number. The service picks a sender from its pool and enables features like link…
  • POSTSchedule a message/Accounts/{{accountSid}}/Messages.jsonQueues a message to go out later. Scheduling requires MessagingServiceSid plus ScheduleType=fixed and SendAt as an ISO 8601 UTC time between 15 minutes and 35…
  • POSTSend a WhatsApp message/Accounts/{{accountSid}}/Messages.jsonSends WhatsApp by prefixing both addresses with whatsapp:. Free-form text only works inside the 24-hour customer service window (the user messaged you in the…
  • POSTSend a WhatsApp template (Content API)/Accounts/{{accountSid}}/Messages.jsonSends an approved template created in the Content Template Builder. Set ContentSid (starts with HX) and ContentVariables, a JSON object mapping placeholder…
  • GETFetch a message/Accounts/{{accountSid}}/Messages/{{messageSid}}.jsonReads one message by SID to check delivery. Look at status (queued, sent, delivered, undelivered, failed, read for WhatsApp), error_code when it failed, and…
  • GETList messages/Accounts/{{accountSid}}/Messages.jsonLists messages on the account, newest first. Filter with To, From, DateSent (YYYY-MM-DD) or the range forms DateSent< and DateSent>; PageSize up to 1000. The…
  • POSTCancel a scheduled message/Accounts/{{accountSid}}/Messages/{{scheduledMessageSid}}.jsonCancels a message that is still scheduled by posting Status=canceled to it. Only scheduled messages can be canceled; anything already queued or sent returns…
  • POSTRedact a message body/Accounts/{{accountSid}}/Messages/{{messageSid}}.jsonRemoves the text of a sent message from Twilio's records while keeping its metadata, by posting an empty Body. Useful for data minimisation after delivery.…
  • DELETEDelete a message/Accounts/{{accountSid}}/Messages/{{messageSid}}.jsonPermanently deletes the message from your logs together with its Media and feedback sub-resources. Returns 204 with no body. Twilio says bodies may remain in…

3. Voice calls

  • POSTMake a call (TwiML URL)/Accounts/{{accountSid}}/Calls.jsonStarts an outbound call. Twilio dials To from From and, when it is answered, fetches TwiML from Url to decide what happens (say text, play audio, gather…
  • POSTMake a call (inline TwiML)/Accounts/{{accountSid}}/Calls.jsonStarts a call with the TwiML in the request instead of a URL, handy for simple announcements. Twiml holds the XML document as a string. Change the <Say> text…
  • GETFetch a call/Accounts/{{accountSid}}/Calls/{{callSid}}.jsonReads a call by SID. status moves through queued, ringing, in-progress and ends as completed, busy, failed, no-answer or canceled; duration and price fill in…
  • GETList calls/Accounts/{{accountSid}}/Calls.jsonLists calls newest first. Filter by To, From, Status or StartTime (with StartTime> / StartTime< for ranges) and set PageSize (max 1000). Results are in calls…
  • POSTHang up a call/Accounts/{{accountSid}}/Calls/{{callSid}}.jsonEnds a live call by posting Status=completed (use canceled for a call that is still queued or ringing). You can also redirect a live call by posting a new Url…

4. Verify (one-time codes)

  • POSTCreate a Verify service{{verifyUrl}}/ServicesCreates a Verify Service, the container for your verification settings. FriendlyName (short: letters, digits, spaces, dashes and underscores; no personal…
  • POSTSend a code (start verification){{verifyUrl}}/Services/{{verifyServiceSid}}/VerificationsSends a one-time code to To over Channel: sms, call (not voice), whatsapp, email or auto. Twilio generates the code; you never see it. Returns the…
  • POSTCheck a code{{verifyUrl}}/Services/{{verifyServiceSid}}/VerificationCheckChecks the code the user typed. Send To (or VerificationSid) and Code. When it matches, status becomes approved and valid is true; otherwise valid stays…
  • GETFetch a verification{{verifyUrl}}/Services/{{verifyServiceSid}}/Verifications/{{verificationSid}}Reads a verification by its VE SID while it is still alive, for example to show which channel was used or how many send attempts were made. Uses…

5. Lookup v2

  • GETValidate and format a number{{lookupsUrl}}/PhoneNumbers/%2B15555550100Basic Lookup: free formatting and validation. Returns valid, the number in E.164 (phone_number) and national format, country_code, and validation_errors such…
  • GETGet line type intelligence{{lookupsUrl}}/PhoneNumbers/%2B15555550100Adds the paid line_type_intelligence data package with Fields, returning the carrier name and line type (mobile, landline, fixedVoip, nonFixedVoip, tollFree,…

API details

Base URL
https://api.twilio.com/2010-04-01
https://verify.twilio.com/v2
https://lookups.twilio.com/v2
Authentication
HTTP Basic authentication (username and password)
Operations
24 operations on 24 pathsPOST 14GET 9DELETE 1
Main resources
1. Start here 22. Messaging (SMS, MMS, WhatsApp) 113. Voice calls 54. Verify (one-time codes) 45. Lookup v2 2
Description format
Swastik Codes guided collection, API version checked against the docs on 2026-11-18

How to test the Twilio API in Swastik Codes

  1. Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
  2. Fork it into your workspaceChoose a workspace. You get your own copy of the Twilio API collection, without the publisher's secrets.
  3. Add your credentialsThis API uses HTTP Basic authentication (username and password). Add yours in the collection's variables or an environment; the requests already reference it.
  4. Send a requestPick an endpoint, for example “Fetch your account” (GET /Accounts/{{accountSid}}.json), and press Send. Check the response, add tests and run the whole collection with the runner.

Frequently asked questions

What is the Twilio API?

Send SMS, MMS and WhatsApp, place voice calls with TwiML, send and check Verify codes and look up phone numbers. It is listed under Communication and has 24 endpoints.

Who publishes the Twilio API?

It is listed from Twilio's public API description (an OpenAPI document), not published by Twilio on Swastik Codes. Anyone who controls twilio.com can claim the profile by adding a DNS TXT record.

What is the base URL of the Twilio API?

Its description lists 3 base URLs: https://api.twilio.com/2010-04-01, https://verify.twilio.com/v2, https://lookups.twilio.com/v2. The first is the usual one; the others are typically sandbox or regional servers.

How do I authenticate with the Twilio API?

With HTTP Basic authentication (username and password).

How many endpoints does the Twilio API have?

24 operations on 24 paths (14 POST, 9 GET, 1 DELETE). The largest groups are 1. Start here, 2. Messaging (SMS, MMS, WhatsApp), 3. Voice calls, 4. Verify (one-time codes).

Is forking the Twilio API free?

Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.

Suggest an API

Tell us which public API is missing. We check it, then add it here with its endpoints when it has an OpenAPI (Swagger) description.