Messaging Service ShortCode Resource
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.
Property nameTypePIIDescription
The unique string that we created to identify the ShortCode resource.
Pattern: ^SC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the ShortCode resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the resource is associated with.
Pattern: ^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
date_createdstring<date-time>
date_updatedstring<date-time>
The E.164 format of the short code.
capabilitiesarray[string] An array of values that describe whether the number can receive calls or messages. Can be: SMS
and MMS
.
The absolute URL of the ShortCode resource.
POST https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes
Property nameTypeRequiredPIIDescription
ServiceSidSID<MG>required The SID of the Service to create the resource under.
Pattern: ^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
ShortCodeSidSID<SC>required The SID of the ShortCode resource being added to the Service.
Pattern: ^SC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_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
_13const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13const authToken = process.env.TWILIO_AUTH_TOKEN;
_13const client = require('twilio')(accountSid, authToken);
_13client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13 shortCodeSid: 'SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_13 .then(short_code => console.log(short_code.sid));
_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 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes/{Sid}
Property nameTypeRequiredPIIDescription
ServiceSidSID<MG>required The SID of the Service to fetch the resource from.
Pattern: ^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the ShortCode resource to fetch.
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .shortCodes('SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(short_code => console.log(short_code.sid));
_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 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes
Property nameTypeRequiredPIIDescription
ServiceSidSID<MG>required The SID of the Service to read the resources from.
Pattern: ^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(shortCodes => shortCodes.forEach(s => console.log(s.sid)));
_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 "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 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes/SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DELETE https://messaging.twilio.com/v1/Services/{ServiceSid}/ShortCodes/{Sid}
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<MG>required The SID of the Service to delete the resource from.
Pattern: ^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the ShortCode resource to delete.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .shortCodes('SCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')