Skip to contentSkip to navigationSkip to topbar
On this page

API


An Application Programming Interface (API) is provided by a service owner so that others may use the features and functions enabled by the service. APIs describe how a consumer will make requests of the service, and what they will receive in return.

An API defines the means by which the consumer or user of a service invokes service functions and receives data in return from the provider of the API. There are many different kinds of APIs, from the Swift(link takes you to an external page) APIs provided by iOS to provide mobile apps with access to the many facilities provided by the operating system, to REST APIs provided by Twilio that allow developers to send SMS and do tons of other things.

Incoming SMS Diagram.

Twilio, as an API company, provides many different APIs to our customers to help them build applications that communicate. Check out the API reference for a full listing of the APIs Twilio provides for developers to use. Primarily, Twilio provides REST APIs and software APIs for developers to use in order to do fun things like answer phone calls, make video calls, or instantly synchronize data between two clients.


REST APIs

rest-apis page anchor

A REST API allows systems to communicate with one another and invoke functions over the Internet.


In a typical software program, you will use a combination of a programming language's built-in features, its syntax, and APIs provided either by the language's standard library or libraries created and published by third-parties. Twilio provides libraries for many popular programming languages that allow developers on those platforms to consume our services.

Here's an example of using Twilio's helper libraries to send an SMS message using different languages.

Sending an SMS in different languagesLink to code sample: Sending an SMS in different languages
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 and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.messages.create({
12
body: "This is the ship that made the Kessel Run in fourteen parsecs?",
13
from: "+15017122661",
14
to: "+15558675310",
15
});
16
17
console.log(message.body);
18
}
19
20
createMessage();

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"api_version": "2010-04-01",
4
"body": "This is the ship that made the Kessel Run in fourteen parsecs?",
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": "+15017122661",
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
"tags": {
23
"campaign_name": "Spring Sale 2022",
24
"message_type": "cart_abandoned"
25
},
26
"to": "+15558675310",
27
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
28
}

Don't know an API from an IPA(link takes you to an external page)? Talk to an expert(link takes you to an external page), or get some help from our support team(link takes you to an external page).

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.