[metadata]
article:modified_time: 2026-07-24T11:58:39.000Z
dcterms.modified: 2026-07-24T11:58:39.000Z
description: Explore the basics of HTTP requests. Learn how to authorize your account, create or update API resources, and understand Twilio's responses.
og:updated_time: 2026-07-24T11:58:39.000Z
viewport: width=device-width
x-twilio-docs-origin: otk
x-twilio-docs-source: primary

[canonical-links]
https://www.twilio.com/docs/usage/requests-to-twilio

[document-links]
/Accounts/{SID}/Keys: /docs/iam/api-keys/key-resource-v2010
/Accounts: /docs/iam/api-keys/keys-in-console
/docs
/v1/Keys: /docs/iam/api-keys/key-resource-v1
A Beginner's Guide to the Command Line: /docs/usage/tutorials/a-beginners-guide-to-the-command-line
API Key Management: /docs/iam/api-keys
API best practices: /docs/usage/rest-api-best-practices
API mutation and conflict resolution: /docs/usage/mutation-and-conflict-resolution
API requests: /docs/usage/requests-to-twilio
API responses: /docs/usage/twilios-response
Addresses: /docs/usage/api/address
Alarms: /docs/usage/troubleshooting/alarms
Alerts: /docs/usage/monitor-alert
All docs...: /docs
Analyze: /docs/usage/fraud-response-guide/analyze
Anti-Fraud Developer's Guide: /docs/usage/anti-fraud-developer-guide
Applications: /docs/usage/api/applications
Availability and Reliability: /docs/usage/security/availability-reliability
Billing Groups: /docs/usage/billing/billing-group
Browse all of Twilio's APIs: /docs
Build with AI: /docs/ai
C# / ASP.NET Core: /docs/usage/tutorials/how-to-secure-your-csharp-aspnet-core-app-by-validating-incoming-twilio-requests
C# / ASP.NET WEB API: /docs/usage/tutorials/how-to-secure-your-csharp-aspnet-web-api-app-by-validating-incoming-twilio-requests
C# / ASP.NET: /docs/usage/tutorials/how-to-secure-your-csharp-aspnet-app-by-validating-incoming-twilio-requests
Changelog: https://www.twilio.com/en-us/changelog/upcoming-security-changes--http-voice-recording-media-endpoint-c
Contain: /docs/usage/fraud-response-guide/contain
Conversations: /docs/conversations
Days resource: /docs/usage/bulkexport/day
Debug events webhooks: /docs/usage/troubleshooting/debugging-event-webhooks
Developer Hub: https://www.twilio.com/en-us/developers
Diagnose: /docs/usage/fraud-response-guide/diagnose
Edge Locations: /docs/global-infrastructure/understanding-edge-locations#inbound-connectivity
Engage: /docs/usage/fraud-response-guide/engage
Events: /docs/usage/monitor-events
Example: RCA Summary Request Form: /docs/usage/fraud-response-guide/example-rca-summary-request-form
Exports Configuration resource: /docs/usage/bulkexport/exportconfiguration
Exports Jobs: custom jobs: /docs/usage/bulkexport/export-custom-job
FAQ: /docs/usage/webhooks/webhooks-faq
Flex: /docs/flex
General Usage: /docs/usage
Get started with your Twilio trial account: /docs/usage/tutorials/how-to-use-your-free-trial-account
Getting Started: /docs/usage/webhooks/getting-started-twilio-webhooks
Global Infrastructure: /docs/global-infrastructure
Global Safe List API: /docs/usage/global-safe-list
Go / Gin: /docs/usage/tutorials/how-to-secure-your-gin-project-by-validating-incoming-twilio-requests
HTTP Basic authentication: https://en.wikipedia.org/wiki/Basic_access_authentication
Help Center: https://help.twilio.com
ISO/IEC Certification: /docs/usage/security/iso-iec-certification
Introduction: /docs/usage/webhooks
Java / Servlets: /docs/usage/tutorials/how-to-secure-your-servlet-app-by-validating-incoming-twilio-requests
Jobs resource: /docs/usage/bulkexport/job
Key: /docs/iam/api-keys/key-resource-v1
Log in: https://www.twilio.com/login
Manage Regional API credentials: /docs/global-infrastructure/manage-regional-api-credentials
Manage unused resources: /docs/usage/manage-unused-resources
Messaging: /docs/messaging
Node.js / Express: /docs/usage/tutorials/how-to-secure-your-express-app-by-validating-incoming-twilio-requests
Overview: /docs/iam/api/account
Overview: /docs/usage/api
Overview: /docs/usage/billing
Overview: /docs/usage/bulkexport
Overview: /docs/usage/fraud-response-guide
Overview: /docs/usage/trials
Overview: /docs/usage/webhooks/webhooks-overview
PHP / Lumen: /docs/usage/tutorials/how-to-secure-your-lumen-app-by-validating-incoming-twilio-requests
Postman: https://www.postman.com/
Privacy Policy: /en-us/legal/privacy
Programmable Messaging: /docs/messaging
Programmable Voice: /docs/voice
Python / Django: /docs/usage/tutorials/how-to-secure-your-django-project-by-validating-incoming-twilio-requests
Python / Flask: /docs/usage/tutorials/how-to-secure-your-flask-app-by-validating-incoming-twilio-requests
REST API requests in PowerShell: /docs/usage/tutorials/how-to-make-http-basic-request-twilio-powershell
Reporting security vulnerabilities: /docs/usage/security/reporting-vulnerabilities
Restricted API keys: /docs/iam/api-keys/restricted-api-keys
Ruby / Sinatra: /blog/secure-your-sinatra-app-validating-incoming-twilio-requests
SDKs: /docs/libraries
Security: /docs/usage/security
Security: /docs/usage/webhooks/webhooks-security
Set up your local development environment: /docs/usage/local-environment
Sign up: https://www.twilio.com/try-twilio
Store Your Twilio Credentials Securely: /docs/usage/secure-credentials
Studio: /docs/studio
Subaccounts: /docs/iam/api/subaccounts
Terms of service: /en-us/legal/tos
Try out Email: /docs/usage/trials/try-out-email
Try out SMS Messaging: /docs/usage/trials/try-out-sms
Try out Voice: /docs/usage/trials/try-out-voice
Try out WhatsApp: /docs/usage/trials/try-out-whatsapp
Twilio CLI: /docs/twilio-cli/general-usage
Twilio Console Assistant AI Nutrition Facts: /docs/usage/twilio-console-assistant-ai-facts
Twilio Console Assistant: /docs/usage/twilio-console-assistant
Twilio Console: https://www.twilio.com/console
Twilio Debugger: /docs/usage/troubleshooting/debugging-your-application
Twilio Docs: /docs
Twilio Regions: /docs/global-infrastructure/understanding-twilio-regions
Twilio SDK: /docs/libraries
Twilio SDKs: /docs/libraries
Twilio Workbench: /docs/usage/workbench
Twilio tag: https://stackoverflow.com/questions/tagged/twilio
Usage records: /docs/usage/api/usage-record
Usage triggers: /docs/usage/api/usage-trigger
Validate: /docs/usage/fraud-response-guide/validate
Verify API: /docs/verify/api
Video: /docs/video
View as Markdown: /docs/usage/requests-to-twilio.md
Voice: /docs/voice
Webhook Security: /docs/usage/security
Webhooks Connection Overrides: /docs/usage/webhooks/webhooks-connection-overrides
Webhooks: /docs/glossary/what-is-a-webhook
Welcome to the new Twilio console: /docs/usage/new-twilio-console
got in NodeJS: https://www.npmjs.com/package/got
how Twilio handles authentication: /docs/usage/security
in the Twilio Console: /docs/iam/api-keys/keys-in-console
server-side SDK: /docs/libraries
setting environment variables: https://www.twilio.com/blog/how-to-set-environment-variables.html
support team: https://help.twilio.com
using the API: /docs/iam/api-keys/key-resource-v1

[structured-data]
{"@context":"https://schema.org","@id":"https://www.twilio.com/docs/usage/requests-to-twilio#article","@type":"TechArticle","author":{"@type":"Organization","name":"Twilio Developer Education Team"},"dateModified":"2026-07-24T11:58:39.000Z","description":"Explore the basics of HTTP requests. Learn how to authorize your account, create or update API resources, and understand Twilio's responses.","headline":"Twilio API requests","inLanguage":"en","publisher":{"@type":"Organization","name":"Twilio"},"url":"https://www.twilio.com/docs/usage/requests-to-twilio"}

[content]
Twilio API requests | Twilio
Skip to content
Skip to navigation
Skip to topbar
Twilio Docs
General Usage
Get started
Get started with your Twilio trial account
Welcome to the new Twilio console
A Beginner's Guide to the Command Line
Set up your local development environment
Twilio Console Assistant
Twilio Console Assistant AI Nutrition Facts
Trials
Overview
Try out SMS Messaging
Try out Voice
Try out Email
Try out WhatsApp
Twilio APIs
Overview
API requests
API responses
API mutation and conflict resolution
API best practices
REST API requests in PowerShell
Accounts
Overview
Subaccounts
Addresses
Applications
BulkExport API
Overview
Exports Configuration resource
Exports Jobs: custom jobs
Jobs resource
Days resource
Key
Usage records
Usage triggers
Monitor REST API
Alerts
Events
Browse all of Twilio's APIs
Webhooks
Introduction
Overview
Getting Started
Webhooks Connection Overrides
FAQ
Security
Preventing Fraud
Anti-Fraud Developer's Guide
Fraud & Abuse Response Guide
Overview
Validate
Engage
Contain
Analyze
Diagnose
Example: RCA Summary Request Form
Global Safe List API
Troubleshooting and Security
Twilio Debugger
Debug events webhooks
Alarms
Availability and Reliability
Security
ISO/IEC Certification
Reporting security vulnerabilities
Store Your Twilio Credentials Securely
Secure your app by validating incoming Twilio requests
C# / ASP.NET
C# / ASP.NET Core
C# / ASP.NET WEB API
Java / Servlets
Node.js / Express
PHP / Lumen
Python / Django
Python / Flask
Ruby / Sinatra
Go / Gin
Billing
Overview
Billing Groups
Maintenance
Manage unused resources
Twilio products: API docs, quickstarts, and tutorials
Programmable Messaging
Programmable Voice
Verify API
Twilio Workbench
Twilio Docs
Search
Search
Messaging
Voice
Video
Conversations
Flex
Studio
All docs...
Build with AI
SDKs
Help Center
Search
Log in
Sign up
Page tools
View as Markdown
Copy as Markdown
On this page
Ways to make requests to the Twilio APIs
Authentication
Using API keys (recommended)
Using your Account SID and Auth Token
Twilio SDKs
HTTP methods for API interactions
Content type requirements
Global Edge Locations and network entry
Vanity URLs and security requirements
How the Twilio APIs handle webhooks
Next steps
Looking for more inspiration?
Visit the
Developer Hub
On this page
Ways to make requests to the Twilio APIs
Authentication
Using API keys (recommended)
Using your Account SID and Auth Token
Twilio SDKs
HTTP methods for API interactions
Content type requirements
Global Edge Locations and network entry
Vanity URLs and security requirements
How the Twilio APIs handle webhooks
Next steps
Page Tools
View as Markdown
Copy as Markdown
Twilio API requests
Learn how to authenticate your requests, what content type to use for API requests, and how the Twilio APIs handle webhooks. You'll also see examples of how to make requests to the Twilio APIs.
Ways to make requests to the Twilio APIs
You can make an HTTP request to the Twilio API in the following ways:
Make a raw HTTP request either in your code (for example, by using a module like
got in NodeJS
) or with a tool like
Postman
.
Use a
Twilio SDK
for your preferred programming language.
Use the
Twilio CLI
if you prefer working in the terminal.
Authentication
(information)
Environment variables
Always store your credentials in environment variables before sharing any code or deploying to production. Learn more about
setting environment variables
.
To authenticate requests to the Twilio APIs, Twilio supports
HTTP Basic authentication
. You can use the following credentials:
Username
Password
Best practice
API Key
API Key Secret
This is the recommended way to authenticate with the Twilio APIs. When a key is compromised or no longer used, revoke it to prevent unauthorized access.
Account SID
AuthToken
Limit your use to local testing.
(information)
Regional API credentials
Twilio API credentials are region-specific resources. If your account uses
Twilio Regions
, see
Manage Regional API credentials
.
Using API keys (recommended)
An API key is a unique identifier that allows a client to access your Twilio account and create, read, update, or delete resources through the Twilio APIs. You can create multiple API keys for different purposes, such as for different developers or subsystems within your application. If a key is compromised or no longer used, you can revoke it to prevent unauthorized access.
Twilio recommends using only API keys for production applications. If a bad actor gains access to your Account SID and Auth Token, then your Twilio Account is compromised.
You can create an API key either
in the Twilio Console
or
using the API
.
The API key types are
Main
,
Standard
, and
Restricted
(Key resource v1 only). The following table describes each type:
Key type
Access permissions
Create in Console
Create with REST API
Main
Full access to all Twilio API resources. Equivalent to using your Account SID and Auth Token for API requests.
Yes
No
Standard
Access to all Twilio API resources, except for Accounts (
/Accounts
) or Keys (
/Accounts/{SID}/Keys
,
/v1/Keys
) resources.
Yes
Yes
Restricted
Customized, fine-grained access to specific Twilio API resources. Learn more about
Restricted API keys
.
Yes
Yes (
v1 only
)
When making an API request, use your API key as the username and your API key secret as the password.
Note
: In the following example, you must use a
Main
API key.
List accounts
.css-1raivgc{box-sizing:border-box;background-color:inherit;color:inherit;font-family:inherit;line-height:1.75rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.25rem;}
curl
Report code block
Copy code block
1
curl
-X
GET "https://api.twilio.com/2010-04-01/Accounts.json?PageSize=20"
\
2
-u $TWILIO_API_KEY
:
$TWILIO_API_SECRET
The user remains logged in for the duration of the request. Learn more about
how Twilio handles authentication
.
Using your Account SID and Auth Token
For local testing, you can use your Account SID as the username and your Auth token as the password. You can find your Account SID and Auth Token in the
Twilio Console
, under the
Account Dashboard
.
List accounts
curl
Report code block
Copy code block
1
curl
-X
GET "https://api.twilio.com/2010-04-01/Accounts.json?PageSize=20"
\
2
-u $TWILIO_ACCOUNT_SID
:
$TWILIO_AUTH_TOKEN
Twilio SDKs
A Twilio SDK is a
server-side SDK
that helps you use Twilio's REST APIs, generate TwiML, and perform other common server-side programming tasks.
Twilio SDKs can handle credential management and simplify the authentication process. All Twilio SDKs come with a
Utilities
class that validates requests by passing your credentials to the library.
HTTP methods for API interactions
Twilio APIs use standard RESTful HTTP methods to perform actions on resources. The following examples demonstrate the most common methods:
POST
: Create or update a resource.
GET
: Retrieve a resource.
DELETE
: Delete a resource.
POST
GET: List messages
GET: Retrieve a message
DELETE
POST a new SMS message
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
Report code block
Copy code block
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const
twilio
=
require
(
"twilio"
);
// Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID at twilio.com/console
5
// Provision API Keys at twilio.com/console/runtime/api-keys
6
// and set the environment variables. See http://twil.io/secure
7
// For local testing, you can use your Account SID and Auth token
8
const
accountSid
=
process.env.
TWILIO_ACCOUNT_SID
;
9
const
apiKey
=
process.env.
TWILIO_API_KEY
;
10
const
apiSecret
=
process.env.
TWILIO_API_SECRET
;
11
const
client
=
twilio
(apiKey, apiSecret, { accountSid: accountSid });
12
13
async function
createMessage
() {
14
const
message
= await
client.messages.
create
({
15
body:
"Hello"
,
16
from:
"+14155552344"
,
17
to:
"+15558675310"
,
18
});
19
20
console.
log
(message.body);
21
}
22
23
createMessage
();
Response
Copy response
1
{
2
"account_sid"
:
"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
,
3
"api_version"
:
"2010-04-01"
,
4
"body"
:
"Hello"
,
5
"date_created"
:
"Thu, 24 Aug 2023 05:01:45 +0000"
,
6
"date_sent"
:
"Thu, 24 Aug 2023 05:01:45 +0000"
,
7
"date_updated"
:
"Thu, 24 Aug 2023 05:01:45 +0000"
,
8
"direction"
:
"outbound-api"
,
9
"error_code"
:
null
,
10
"error_message"
:
null
,
11
"from"
:
"+14155552344"
,
12
"num_media"
:
"0"
,
13
"num_segments"
:
"1"
,
14
"price"
:
null
,
15
"price_unit"
:
null
,
16
"messaging_service_sid"
:
"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
17
"sid"
:
"SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
18
"status"
:
"queued"
,
19
"subresource_uris"
: {
20
"media"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
21
},
22
"to"
:
"+15558675310"
,
23
"uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
24
}
GET a list of messages
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
Report code block
Copy code block
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const
twilio
=
require
(
"twilio"
);
// Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID at twilio.com/console
5
// Provision API Keys at twilio.com/console/runtime/api-keys
6
// and set the environment variables. See http://twil.io/secure
7
// For local testing, you can use your Account SID and Auth token
8
const
accountSid
=
process.env.
TWILIO_ACCOUNT_SID
;
9
const
apiKey
=
process.env.
TWILIO_API_KEY
;
10
const
apiSecret
=
process.env.
TWILIO_API_SECRET
;
11
const
client
=
twilio
(apiKey, apiSecret, { accountSid: accountSid });
12
13
async function
listMessage
() {
14
const
messages
= await
client.messages.
list
({ limit:
20
});
15
16
messages.
forEach
((
m
)
=>
console.
log
(m.end));
17
}
18
19
listMessage
();
Response
Copy response
1
{
2
"end"
:
1
,
3
"first_page_uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=0"
,
4
"next_page_uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=1&PageToken=PAMMc26223853f8c46b4ab7dfaa6abba0a26"
,
5
"page"
:
0
,
6
"page_size"
:
2
,
7
"previous_page_uri"
:
null
,
8
"messages"
: [
9
{
10
"account_sid"
:
"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
11
"api_version"
:
"2010-04-01"
,
12
"body"
:
"testing"
,
13
"date_created"
:
"Fri, 24 May 2019 17:44:46 +0000"
,
14
"date_sent"
:
"Fri, 24 May 2019 17:44:50 +0000"
,
15
"date_updated"
:
"Fri, 24 May 2019 17:44:50 +0000"
,
16
"direction"
:
"outbound-api"
,
17
"error_code"
:
null
,
18
"error_message"
:
null
,
19
"from"
:
"+12019235161"
,
20
"messaging_service_sid"
:
"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
21
"num_media"
:
"0"
,
22
"num_segments"
:
"1"
,
23
"price"
:
"-0.00750"
,
24
"price_unit"
:
"USD"
,
25
"sid"
:
"SMded05904ccb347238880ca9264e8fe1c"
,
26
"status"
:
"sent"
,
27
"subresource_uris"
: {
28
"media"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c/Media.json"
,
29
"feedback"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c/Feedback.json"
30
},
31
"to"
:
"+18182008801"
,
32
"uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c.json"
33
},
34
{
35
"account_sid"
:
"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
36
"api_version"
:
"2010-04-01"
,
37
"body"
:
"look mom I have media!"
,
38
"date_created"
:
"Fri, 24 May 2019 17:44:46 +0000"
,
39
"date_sent"
:
"Fri, 24 May 2019 17:44:49 +0000"
,
40
"date_updated"
:
"Fri, 24 May 2019 17:44:49 +0000"
,
41
"direction"
:
"inbound"
,
42
"error_code"
:
30004
,
43
"error_message"
:
"Message blocked"
,
44
"from"
:
"+12019235161"
,
45
"messaging_service_sid"
:
"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
46
"num_media"
:
"3"
,
47
"num_segments"
:
"1"
,
48
"price"
:
"-0.00750"
,
49
"price_unit"
:
"USD"
,
50
"sid"
:
"MMc26223853f8c46b4ab7dfaa6abba0a26"
,
51
"status"
:
"received"
,
52
"subresource_uris"
: {
53
"media"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26/Media.json"
,
54
"feedback"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26/Feedback.json"
55
},
56
"to"
:
"+18182008801"
,
57
"uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26.json"
58
}
59
],
60
"start"
:
0
,
61
"uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=0"
62
}
GET a specific message
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
Report code block
Copy code block
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const
twilio
=
require
(
"twilio"
);
// Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID at twilio.com/console
5
// Provision API Keys at twilio.com/console/runtime/api-keys
6
// and set the environment variables. See http://twil.io/secure
7
// For local testing, you can use your Account SID and Auth token
8
const
accountSid
=
process.env.
TWILIO_ACCOUNT_SID
;
9
const
apiKey
=
process.env.
TWILIO_API_KEY
;
10
const
apiSecret
=
process.env.
TWILIO_API_SECRET
;
11
const
client
=
twilio
(apiKey, apiSecret, { accountSid: accountSid });
12
13
async function
fetchMessage
() {
14
const
message
= await
client
15
.
messages
(
"SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
16
.
fetch
();
17
18
console.
log
(message.body);
19
}
20
21
fetchMessage
();
Response
Copy response
1
{
2
"account_sid"
:
"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
,
3
"api_version"
:
"2010-04-01"
,
4
"body"
:
"testing"
,
5
"date_created"
:
"Fri, 24 May 2019 17:18:27 +0000"
,
6
"date_sent"
:
"Fri, 24 May 2019 17:18:28 +0000"
,
7
"date_updated"
:
"Fri, 24 May 2019 17:18:28 +0000"
,
8
"direction"
:
"outbound-api"
,
9
"error_code"
:
30007
,
10
"error_message"
:
"Carrier violation"
,
11
"from"
:
"+12019235161"
,
12
"messaging_service_sid"
:
"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
13
"num_media"
:
"0"
,
14
"num_segments"
:
"1"
,
15
"price"
:
"-0.00750"
,
16
"price_unit"
:
"USD"
,
17
"sid"
:
"SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
18
"status"
:
"sent"
,
19
"subresource_uris"
: {
20
"media"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json"
,
21
"feedback"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json"
22
},
23
"to"
:
"+18182008801"
,
24
"uri"
:
"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json"
25
}
DELETE a message
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
Report code block
Copy code block
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const
twilio
=
require
(
"twilio"
);
// Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID at twilio.com/console
5
// Provision API Keys at twilio.com/console/runtime/api-keys
6
// and set the environment variables. See http://twil.io/secure
7
// For local testing, you can use your Account SID and Auth token
8
const
accountSid
=
process.env.
TWILIO_ACCOUNT_SID
;
9
const
apiKey
=
process.env.
TWILIO_API_KEY
;
10
const
apiSecret
=
process.env.
TWILIO_API_SECRET
;
11
const
client
=
twilio
(apiKey, apiSecret, { accountSid: accountSid });
12
13
async function
deleteMessage
() {
14
await
client.
messages
(
"SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).
remove
();
15
}
16
17
deleteMessage
();
Content type requirements
Twilio APIs expect the API request content type to be
application/x-www-form-urlencoded
or
multipart/form-data
. Using an unsupported content type might cause unexpected behavior or errors.
Global Edge Locations and network entry
Twilio global infrastructure allows you to optimize request routing for better performance. You can specify which Twilio network edge your API request uses to ingress Twilio network, and the processing region for your request. Learn more about
Edge Locations
.
Vanity URLs and security requirements
Twilio has specific security requirements for accessing voice recording media files. Twilio doesn't support unauthenticated access to HTTP Voice recording media URLs using Canonical Name (CNAME) records. Use HTTPS endpoints and Transport-Layer-Security (TLS) protocols when accessing voice recordings media files from your account. For more information, see the
Changelog
.
How the Twilio APIs handle webhooks
Webhooks
are user-defined HTTP callbacks triggered by an event in a web application. Twilio uses webhooks to let your application know when events happen, like getting an incoming call or receiving an SMS message. Webhooks are triggered asynchronously.
When a webhook event occurs, Twilio makes an HTTP request, such as
POST
or
GET
, to the URL you configured for your webhook. Twilio's request to your application includes details of the event like the body of an incoming message or an incoming phone number. Your application can then process the event and reply to Twilio with a response containing the instructions you'd like Twilio to perform.
To handle a webhook when you use Twilio, you need to build a web application that can accept HTTP requests. Check out the
Twilio SDKs
to get up and running quickly.
Next steps
Explore these resources to keep building with the Twilio APIs:
Twilio SDKs
: Get started with server-side libraries.
API Key Management
: Learn about creating and managing API keys.
Twilio CLI
: Work with Twilio from your terminal.
Webhook Security
: Secure your webhook endpoints.
Global Infrastructure
: Optimize performance with Edge Locations.
Need some help?
We all do sometimes; code is hard. Get help now from our
support team
, or lean on the wisdom of the crowd by browsing the
Twilio tag
on Stack Overflow.
Terms of service
Privacy Policy
Copyright © 2026 Twilio Inc.
