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 api_version
type: string
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>
date_updated
type: string<date-time-rfc-2822>
friendly_name
type: string
A string that you assigned to describe this resource. By default, the FriendlyName
is the short code.
short_code
type: string
The short code. e.g., 894546.
sid
type: SID<SC>
The unique string that that we created to identify this ShortCode resource.
sms_fallback_method
type: enum<http-method>
The HTTP method we use to call the sms_fallback_url
. Can be: GET
or POST
.
sms_fallback_url
type: string<uri>
The URL that we call if an error occurs while retrieving or executing the TwiML from sms_url
.
sms_method
type: enum<http-method>
The HTTP method we use to call the sms_url
. Can be: GET
or POST
.
sms_url
type: string<uri>
The URL we call when receiving an incoming SMS message to this short code.
uri
type: string
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 Sid
type: SID<SC>
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 FriendlyName
type: string
The string that identifies the ShortCode resources to read.
ShortCode
type: string
Only show the ShortCode resources that match this pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
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 Sid
type: SID<SC>
The Twilio-provided string that uniquely identifies the ShortCode resource to update
Request body parameters FriendlyName
type: string
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.
ApiVersion
type: string
The API version to use to start a new TwiML session. Can be: 2010-04-01
or 2008-08-01
.
SmsUrl
type: string<uri>
The URL we should call when receiving an incoming SMS message to this short code.
SmsMethod
type: enum<http-method>
The HTTP method we should use when calling the sms_url
. Can be: GET
or POST
.
SmsFallbackUrl
type: string<uri>
The URL that we should call if an error occurs while retrieving or executing the TwiML from sms_url
.
SmsFallbackMethod
type: enum<http-method>
The 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"