Find an API

Search public APIs with auth details & Postman guides

← All APIs

Twilio API

Twilio · Company

Company Basic Auth SMS Voice Communications

Send SMS, make voice calls, and handle two-factor authentication via API. Free trial account includes credit to send real messages with no credit card required.

Authentication

Basic Auth Use HTTP Basic Auth with your Twilio Account SID as the username and your Auth Token as the password. Both are available in the Twilio console dashboard.

Sample Requests

POST Send an SMS

Sends an SMS from your Twilio number to any verified number (on trial accounts).

https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Content-Type application/x-www-form-urlencoded
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: Basic YOUR_BASE64_CREDENTIALS"
import requests
headers = {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Basic YOUR_BASE64_CREDENTIALS"
}
response = requests.post(
    "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json",
    headers=headers,
)
print(response.json())
const url = 'https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': 'Basic YOUR_BASE64_CREDENTIALS'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	targetURL := "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json"
	req, _ := http.NewRequest("POST", targetURL, nil)
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("Authorization", "Basic YOUR_BASE64_CREDENTIALS")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/x-www-form-urlencoded"
req["Authorization"] = "Basic YOUR_BASE64_CREDENTIALS"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json";
$opts = ["http" => [
    "method" => "POST",
    "header" => implode("\r\n", [
        "Content-Type: application/x-www-form-urlencoded",
        "Authorization: Basic YOUR_BASE64_CREDENTIALS"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET List sent messages

Returns a list of messages sent from your Twilio account.

https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json?PageSize=5

Hover any highlighted part to learn what it does

curl -X GET "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json?PageSize=5" \
  -H "Authorization: Basic YOUR_BASE64_CREDENTIALS"
import requests
params = {
    "PageSize": "5"
}
headers = {
    "Authorization": "Basic YOUR_BASE64_CREDENTIALS"
}
response = requests.get(
    "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json",
    params=params,
    headers=headers,
)
print(response.json())
const url = new URL('https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json');
url.searchParams.set('PageSize', '5');

const response = await fetch(url, {
  headers: {
    'Authorization': 'Basic YOUR_BASE64_CREDENTIALS'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	baseURL, _ := url.Parse("https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json")
	q := baseURL.Query()
	q.Set("PageSize", "5")
	baseURL.RawQuery = q.Encode()
	targetURL := baseURL.String()
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("Authorization", "Basic YOUR_BASE64_CREDENTIALS")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json")
uri.query = URI.encode_www_form({
  "PageSize" => "5"
})

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Basic YOUR_BASE64_CREDENTIALS"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json?" . http_build_query([
    "PageSize" => "5"
]);
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "Authorization: Basic YOUR_BASE64_CREDENTIALS"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Sign up at twilio.com — free trial includes credit, no credit card required
  2. From the Twilio Console Dashboard, copy your Account SID and Auth Token
  3. In Postman, go to the Authorization tab and select Basic Auth
  4. Set Username = Account SID, Password = Auth Token
  5. Replace YOUR_ACCOUNT_SID in the URL path with your actual Account SID
  6. For the send SMS request, set Body as x-www-form-urlencoded with To, From, and Body fields
  7. Tip: on trial accounts you can only send to verified phone numbers — verify yours in the console first

What can you build with Twilio API?

Twilio API is a Company API. Developers commonly use company APIs for:

  • enriching CRM records with company firmographics
  • building lead-generation and prospecting tools
  • verifying business identity and registration details
  • monitoring competitors and market intelligence
  • powering B2B data enrichment pipelines

Basic authentication. Send your username and password (Base64-encoded) in the Authorization header. Always use HTTPS — Basic auth over plain HTTP exposes your credentials.

New to APIs? Read our beginner's guide · Learn about API keys · What is REST?

Open documentation ↗