Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Messaging Service ShortCode Resource


(warning)

Public Beta

The Service Resource is currently available as a Public Beta product. This means that some features for configuring your Messaging Service via the REST API are not yet implemented, and others may be changed before the product is declared Generally Available. Messaging Service Configuration through the Twilio Console(link takes you to an external page) is Generally Available.

Public Beta products are not covered by a Twilio SLA(link takes you to an external page).

The resources for sending Messages with a Messaging Service are Generally Available.

The ShortCode subresource of a Service Resource represents the short codes you have associated to the Service.

When a short code has been added to the Messaging Service, Twilio always prioritizes message delivery with your short code when possible. If the short code cannot be used to reach your user, Twilio performs a Short Code Reroute to sent the message from a long code in your Messaging Service instead.

Inbound messages received on any of short codes associated with a Messaging Service are passed to the inbound request URL of the Service with the TWiML parameters that describe the message.


ShortCode Properties

shortcode-properties page anchor
Resource properties
sidtype: SID<SC>Not PII

The unique string that we created to identify the ShortCode resource.


account_sidtype: SID<AC>Not PII

The SID of the Account(link takes you to an external page) that created the ShortCode resource.


service_sidtype: SID<MG>Not PII

The SID of the Service(link takes you to an external page) the resource is associated with.


date_createdtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


short_codetype: stringNot PII

The E.164(link takes you to an external page) format of the short code.


country_codetype: stringNot PII

capabilitiestype: string[]Not PII

An array of values that describe whether the number can receive calls or messages. Can be: SMS and MMS.


urltype: string<URI>Not PII

The absolute URL of the ShortCode resource.


Create a ShortCode resource

create-a-shortcode-resource page anchor
POST https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: SID<MG>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to create the resource under.


Request body parameters
ShortCodeSidtype: SID<SC>Not PII
Required

The SID of the ShortCode resource being added to the Service.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = require('twilio')(accountSid, authToken);
_13
_13
client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.shortCodes
_13
.create({
_13
shortCodeSid: 'SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_13
})
_13
.then(short_code => console.log(short_code.sid));

Output

_13
{
_13
"sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"date_created": "2015-07-30T20:12:31Z",
_13
"date_updated": "2015-07-30T20:12:33Z",
_13
"short_code": "12345",
_13
"country_code": "US",
_13
"capabilities": [
_13
"SMS"
_13
],
_13
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_13
}


Fetch a ShortCode resource

fetch-a-shortcode-resource page anchor
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes/{Sid}

URI parameters
ServiceSidtype: SID<MG>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to fetch the resource from.


Sidtype: stringNot PII
Path Parameter

The SID of the ShortCode resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.shortCodes('SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(short_code => console.log(short_code.sid));

Output

_13
{
_13
"sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"date_created": "2015-07-30T20:12:31Z",
_13
"date_updated": "2015-07-30T20:12:33Z",
_13
"short_code": "12345",
_13
"country_code": "US",
_13
"capabilities": [
_13
"SMS"
_13
],
_13
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_13
}


Read multiple ShortCode resources

read-multiple-shortcode-resources page anchor
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes

URI parameters
ServiceSidtype: SID<MG>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to read the resources from.


PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

List multiple ShortCodes

list-multiple-shortcodes page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.shortCodes
_11
.list({limit: 20})
_11
.then(shortCodes => shortCodes.forEach(s => console.log(s.sid)));

Output

_26
{
_26
"meta": {
_26
"page": 0,
_26
"page_size": 20,
_26
"first_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes?PageSize=20&Page=0",
_26
"previous_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes?PageSize=20&Page=0",
_26
"next_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes?PageSize=20&Page=1",
_26
"key": "short_codes",
_26
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes?PageSize=20&Page=0"
_26
},
_26
"short_codes": [
_26
{
_26
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_26
"service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_26
"sid": "SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_26
"date_created": "2015-07-30T20:12:31Z",
_26
"date_updated": "2015-07-30T20:12:33Z",
_26
"short_code": "12345",
_26
"country_code": "US",
_26
"capabilities": [
_26
"SMS"
_26
],
_26
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_26
}
_26
]
_26
}


Delete a ShortCode resource

delete-a-shortcode-resource page anchor
DELETE https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes/{Sid}

(warning)

Warning

Removing a short code from the Messaging Service does not release the short code from your account. You must cancel the short code from your Account in order to disassociate and delete the short code from your Messaging Service.

Returns a 204 NO CONTENT if the short code was successfully removed from the service.

URI parameters
ServiceSidtype: SID<MG>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to delete the resource from.


Sidtype: stringNot PII
Path Parameter

The SID of the ShortCode resource to delete.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.shortCodes('SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Rate this page: