Skip to contentSkip to navigationSkip to topbar
On this page

The Programmable Wireless API


The Programmable Wireless REST API enables you to programmatically manage global fleets of cellularly connected IoT devices.

Using this REST API, you can:


The Programmable Wireless API base URL

the-programmable-wireless-api-base-url page anchor

All URLs in the reference documentation use the following base URL:

https://wireless.twilio.com/v1

The Programmable Wireless REST API is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported. All responses are provided in JSON format.

(information)

Info

You don't need to use the .json file extension in API request URIs.


The following lists the resources exposed by the Wireless REST API.

(information)

Info

To avoid ambiguity, Sim (initial cap) refers to the Sim API resource. SIM (all caps) refers to the physical Subscriber Identity Module (that is, a SIM card) associated with a Sim resource.

ResourceDescription
Account Usage RecordThis resource is used to query the combined usage for all of the SIMs in your account. You can query multiple dimensions by providing query filters.
CommandThis resource represents an M2M SMS message.
SIM Data SessionsThis resources returns data session information for a SIM over a period of 30 days or under, presented as an aggregated list.
RatePlanThis resource describes the capabilities and restrictions that will apply to any SIMs that are associated with the specified Rate Plan.
SimA Sim resource (note the case) represents a physical SIM card that is capable of connecting to a wireless network.
Sim Usage RecordThis resource is used to query the usage of a SIM. You can query multiple dimensions by providing query filters.

When you create or update resources, you indicate the data that is being added or changed by specifying the appropriate resource property. All resource properties are case-sensitive and written in UpperCamelCase(link takes you to an external page). For example, if you want to change a new Sim's status from ready to active and receive an asynchronous notification of the change, you call:

1
curl https://wireless.twilio.com/v1/Sims/{Sim SID} \
2
-d 'Status=active' \
3
-d 'CallbackUrl={Your notification URI}'
4
-u '{Account_Sid}:{Auth_Token}'

This contrasts with responses from the API, in which properties are referenced using lower_snake_case(link takes you to an external page). For example, getting that same Sim's details will return:

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"unique_name": "unique_name",
4
"commands_callback_method": "POST",
5
"commands_callback_url": "{Your notification URI}",
6
"date_created": "2021-04-01T20:00:00Z",
7
"date_updated": "2021-04-01T20:00:00Z",
8
"friendly_name": "friendly_name",
9
"links": {
10
"data_sessions": "https://wireless.twilio.com/v1/Sims/DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/DataSessions",
11
"rate_plan": "https://wireless.twilio.com/v1/RatePlans/WPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
12
"usage_records": "https://wireless.twilio.com/v1/Sims/DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/UsageRecords"
13
},
14
"rate_plan_sid": "WPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
15
"sid": "DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
16
"iccid": "iccid",
17
"e_id": "e_id",
18
"status": "active",
19
"reset_status": null,
20
"url": "https://wireless.twilio.com/v1/Sims/DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
21
"ip_address": "192.168.1.1"
22
}

The API documentation presents the appropriate parameter formatting for the language or tool that you select in the code column.

(information)

Info

If you use one of Twilio's Helper Libraries or SDKs, properties' cases may be different from those outlined above for the base API. The API documentation always shows the correct case for a given library


HTTP requests made to the REST API are protected with HTTP Basic authentication(link takes you to an external page). To learn more about how Twilio handles authentication, please see our security documentation. You use your Twilio Account SID as the username and your Auth Token as the password for HTTP Basic authentication.

1
curl -G https://wireless.twilio.com/v1/Sims \
2
-u '{Account Sid}:{Auth Token}'

You can find your Account SID and Auth Token in the Console(link takes you to an external page).

(information)

Info

To learn more about authentication and interaction with the Twilio REST API, see our documentation for requests to the API and Twilio's response .


Errors are signaled by 4xx and 5xx HTTP response status codes and a JSON response body. The error data is a standard Twilio structure. For example:

1
{
2
"code": 20003,
3
"detail": "Your AccountSid or AuthToken was incorrect.",
4
"message": "Authentication Error - No credentials provided",
5
"more_info": "https://www.twilio.com/docs/errors/20003",
6
"status": 401
7
}

As you can see, the JSON gives you a human- and machine-readable indication of the nature (the detail key) and cause (message) of the error, and a reference to a more detailed description of the error in Twilio's documentation. The value of code is a Twilio error code, and is referenced again in the more_info URL.

Many errors are generic to platform — the one shown above, for example. However, Programmable Wireless-specific error codes are in the range 33000-33999.

You can see a list of all such codes in the error code documentation and as a JSON file.


Certain operations in the Programmable Wireless REST API, such as changing the status of a Sim resource, can take some time to complete: anywhere from a few seconds to a minute or more. These operations will return an intermediate synchronous HTTP response — 202 Accepted— while the action completes in the background.

Requests that will be processed asynchronously allow you to specify a callback URL for Twilio to notify when the request has completed. A callback is sent to your server as either an HTTP POST or GET request, depending on your preference. Form parameters or query string parameters sent with the callback request describe the asynchronous outcome. Callback request formats are documented with each of the relevant REST API resources.

If your initial request completes synchronously, a 200 OK, 201 Created, or 204 No Content response will be returned and you should not expect an asynchronous callback, even if a callback URL was specified.

An event will be posted to your account's Debugger(link takes you to an external page) in the Console with error details if Twilio does not receive a success response from your callback URL.


Twilio server-side SDKs (Helper Libraries)

twilio-server-side-sdks-helper-libraries page anchor

You can learn how to use the Twilio server-side SDKs, also known as Helper Libraries, with Programmable Wireless in a variety of popular server-side programming languages on the SDKs section of the Twilio Docs.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.