ShortCode Resource
A short code is a 5 or 6-digit number that can send and receive messages with mobile phones. These high-throughput numbers are perfect for apps that need to send messages to lots of users or need to send time-sensitive messages. You can buy shortcodes from Twilio(link takes you to an external page) or port existing short codes to Twilio(link takes you to an external page) .
To send messages from your short code, see the Sending Messages documentation.
Resource properties The API version used to start a new TwiML session when an SMS message is sent to this short code.
date_created
type: string<DATE TIME RFC 2822> Not PIIdate_updated
type: string<DATE TIME RFC 2822> Not PIIA string that you assigned to describe this resource. By default, the FriendlyName
is the short code.
The short code. e.g., 894546.
The unique string that that we created to identify this ShortCode resource.
sms_fallback_method
type: enum<HTTP METHOD> Not PIIThe HTTP method we use to call the sms_fallback_url
. Can be: GET
or POST
.
sms_fallback_url
type: string<URI> Not PIIThe URL that we call if an error occurs while retrieving or executing the TwiML from sms_url
.
sms_method
type: enum<HTTP METHOD> Not PIIThe HTTP method we use to call the sms_url
. Can be: GET
or POST
.
The URL we call when receiving an incoming SMS message to this short code.
The URI of this resource, relative to https://api.twilio.com
.
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/SMS/ShortCodes/{Sid}.json
URI parameters Path Parameter
The Twilio-provided string that uniquely identifies the ShortCode resource to fetch
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.shortCodes('SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .then(short_code => console.log(short_code.friendlyName));
_14 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14 "api_version": "2010-04-01",
_14 "date_created": null,
_14 "date_updated": null,
_14 "friendly_name": "API_CLUSTER_TEST_SHORT_CODE",
_14 "short_code": "99990",
_14 "sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14 "sms_fallback_method": "POST",
_14 "sms_fallback_url": null,
_14 "sms_method": "POST",
_14 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/SMS/ShortCodes.json
Returns a list of ShortCode resources, each representing a short code within your account. This list includes paging information .
The following query string parameters allow you to limit the list returned.
URI parameters Query Parameter
The string that identifies the ShortCode resources to read.
Query Parameter
Only show the ShortCode resources that match this pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
Query Parameter
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Query Parameter
The page index. This value is simply for client state.
Query Parameter
The page token. This is provided by the API.
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.shortCodes.list({limit: 20})
_10 .then(shortCodes => shortCodes.forEach(s => console.log(s.sid)));
_29 "first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "last_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "next_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=50",
_29 "previous_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "api_version": "2010-04-01",
_29 "date_created": null,
_29 "date_updated": null,
_29 "friendly_name": "API_CLUSTER_TEST_SHORT_CODE",
_29 "short_code": "99990",
_29 "sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "sms_fallback_method": "POST",
_29 "sms_fallback_url": null,
_29 "sms_method": "POST",
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json"
Return the set of short codes that match '67898'
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.shortCodes.list({shortCode: '67898', limit: 20})
_10 .then(shortCodes => shortCodes.forEach(s => console.log(s.sid)));
_29 "first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "last_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "next_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=50",
_29 "previous_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "api_version": "2010-04-01",
_29 "date_created": null,
_29 "date_updated": null,
_29 "friendly_name": "API_CLUSTER_TEST_SHORT_CODE",
_29 "short_code": "99990",
_29 "sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "sms_fallback_method": "POST",
_29 "sms_fallback_url": null,
_29 "sms_method": "POST",
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json"
Return the set of all phone numbers containing the digits '898'
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.shortCodes.list({shortCode: '898', limit: 20})
_10 .then(shortCodes => shortCodes.forEach(s => console.log(s.sid)));
_29 "first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "last_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "next_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=50",
_29 "previous_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json?Page=0&PageSize=50",
_29 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "api_version": "2010-04-01",
_29 "date_created": null,
_29 "date_updated": null,
_29 "friendly_name": "API_CLUSTER_TEST_SHORT_CODE",
_29 "short_code": "99990",
_29 "sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "sms_fallback_method": "POST",
_29 "sms_fallback_url": null,
_29 "sms_method": "POST",
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
_29 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes.json"
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/SMS/ShortCodes/{Sid}.json
Tries to update the shortcode's properties. This API call returns the updated resource representation if it is successful. The returned response is identical to that returned when making a GET
request.
URI parameters Path Parameter
The Twilio-provided string that uniquely identifies the ShortCode resource to update
Request body parameters A descriptive string that you created to describe this resource. It can be up to 64 characters long. By default, the FriendlyName
is the short code.
The API version to use to start a new TwiML session. Can be: 2010-04-01
or 2008-08-01
.
The URL we should call when receiving an incoming SMS message to this short code.
SmsMethod
type: enum<HTTP METHOD> Not PIIThe HTTP method we should use when calling the sms_url
. Can be: GET
or POST
.
SmsFallbackUrl
type: string<URI> Not PIIThe URL that we should call if an error occurs while retrieving or executing the TwiML from sms_url
.
SmsFallbackMethod
type: enum<HTTP METHOD> Not PIIThe HTTP method that we should use to call the sms_fallback_url
. Can be: GET
or POST
.
Set the SMS Url on a short code to 'http://demo.twilio.com/docs/sms.xml'
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.shortCodes('SC6b20cb705c1e8f00210049b20b70fce3')
_10 .update({smsUrl: 'http://demo.twilio.com/docs/sms.xml'})
_10 .then(short_code => console.log(short_code.friendlyName));
_14 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14 "api_version": "2010-04-01",
_14 "date_created": null,
_14 "date_updated": null,
_14 "friendly_name": "API_CLUSTER_TEST_SHORT_CODE",
_14 "short_code": "99990",
_14 "sid": "SC6b20cb705c1e8f00210049b20b70fce3",
_14 "sms_fallback_method": "POST",
_14 "sms_fallback_url": null,
_14 "sms_method": "POST",
_14 "sms_url": "http://demo.twilio.com/docs/sms.xml",
_14 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"