Skip to contentSkip to navigationSkip to topbar
Rate this page:
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 more easily 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 languages

sending-an-sms-in-different-languages page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function createMessage() {
_20
const message = await client.messages.create({
_20
body: "This is the ship that made the Kessel Run in fourteen parsecs?",
_20
from: "+15017122661",
_20
to: "+15558675310",
_20
});
_20
_20
console.log(message.body);
_20
}
_20
_20
createMessage();

Output

_28
{
_28
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_28
"api_version": "2010-04-01",
_28
"body": "This is the ship that made the Kessel Run in fourteen parsecs?",
_28
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"direction": "outbound-api",
_28
"error_code": null,
_28
"error_message": null,
_28
"from": "+15017122661",
_28
"num_media": "0",
_28
"num_segments": "1",
_28
"price": null,
_28
"price_unit": null,
_28
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"status": "queued",
_28
"subresource_uris": {
_28
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
_28
},
_28
"tags": {
_28
"campaign_name": "Spring Sale 2022",
_28
"message_type": "cart_abandoned"
_28
},
_28
"to": "+15558675310",
_28
"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).


Rate this page: