The Short Code subresource of a Service instance represents the short codes you have associated to the Service.
When a shortcode has been added to the Messaging Service, Copilot will always attempt to prioritize message delivery with your shortcode when possible. If the shortcode cannot be used to reach your user, Copilot's Shortcode Reroute will select a phone number in your Service instead.
Inbound messages received on any of short codes associated to a Messaging Service are passed to the inbound request URL of the Service. Twilio will make HTTP requests with the following parameters and values to the application you have hosted in this URL.
Properties | Description |
---|---|
sid | The 34 character unique sid of the Short Code |
account_sid | The 34 character unique sid of the Account. |
service_sid | The 34 character unique sid of the Service. |
date_created | The date that this resource was created. |
date_updated | The date that this resource was last updated. |
short_code | The E.164 format of the short code. |
country_code | The 2 character ISO Country Code of the number. |
capabilities | Any array of values that indicate whether the number can receive calls or messages. Possible capabilities are SMS and MMS . |
url | The absolute URL for this resource. |
GET /Services/{Service SID}/ShortCodes
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes.list()
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
TwilioClient.Init(accountSid, authToken);
var shortCodes = ShortCodeResource.Read(pathServiceSid);
foreach (var shortCode in shortCodes)
{
Console.WriteLine(shortCode.Sid);
}
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCodes = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes->read();
foreach ($shortCodes as $shortCode) {
print($shortCode->shortCode);
}
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@short_codes = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes.list
@short_codes.each do |short_code|
puts short_code.url
end
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_codes = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes \
.list()
for short_code in short_codes:
print(short_code.sid)
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
ResourceSet<ShortCode> shortCodes = ShortCode.reader(pathServiceSid)
.read();
for (ShortCode shortCode : shortCodes) {
System.out.println(shortCode);
}
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"meta": {
"page": 0,
"page_size": 50,
"first_page_url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes?PageSize=50&Page=0",
"previous_page_url": null,
"next_page_url": null,
"key": "short_codes",
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes?PageSize=50&Page=0"
},
"short_codes": [
{
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
]
}
POST /Services/{Service SID}/ShortCodes
Properties | Description |
---|---|
ShortCodeSid | ShortCodeSid for the Shortcode being added to the Service. |
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes.create({shortCodeSid: 'SC3f94c94562ac88dccf16f8859a1a8b25'})
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var shortCode = ShortCodeResource.Create(pathServiceSid, shortCodeSid);
Console.WriteLine(shortCode.ShortCode);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCode = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes->create("SC3f94c94562ac88dccf16f8859a1a8b25");
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
client = Twilio::REST::Client.new(account_sid, auth_token)
short_code_sid = 'SC3f94c94562ac88dccf16f8859a1a8b25'
short_code = client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes
.create(short_code_sid: short_code_sid)
puts short_code.short_code
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_code = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes \
.create(short_code_sid="SC3f94c94562ac88dccf16f8859a1a8b25")
print(short_code.sid)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode shortCode = ShortCode.creator(pathServiceSid, shortCodeSid)
.create();
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes' -X POST \
--data-urlencode 'ShortCodeSid=SC3f94c94562ac88dccf16f8859a1a8b25' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
GET /Services/{Service SID}/ShortCodes/{Short Code Sid}
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
.fetch()
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var shortCode = ShortCodeResource.Fetch(pathServiceSid, shortCodeSid);
Console.WriteLine(shortCode.ShortCode);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCode = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes("SC3f94c94562ac88dccf16f8859a1a8b25")->fetch();
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@short_code = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes('SC3f94c94562ac88dccf16f8859a1a8b25')
.fetch
puts @short_code.url
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_codes = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
.fetch()
print(short_codes.country_code)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode shortCode = ShortCode.fetcher(pathServiceSid, shortCodeSid)
.fetch();
System.out.println(shortCode);
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
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.
DELETE /Services/{ServiceSid}/ShortCodes/{Short Code SID}
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service
.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
.remove()
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var deleted = ShortCodeResource.Delete(pathServiceSid, shortCodeSid);
Console.WriteLine(deleted);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCodes = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes("SC3f94c94562ac88dccf16f8859a1a8b25")->delete();
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@deleted = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes('SC3f94c94562ac88dccf16f8859a1a8b25')
.delete
puts @deleted
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
did_delete = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
.delete()
print(did_delete)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode.deleter(pathServiceSid, shortCodeSid).delete();
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25' -X DELETE \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{}
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes.list()
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
TwilioClient.Init(accountSid, authToken);
var shortCodes = ShortCodeResource.Read(pathServiceSid);
foreach (var shortCode in shortCodes)
{
Console.WriteLine(shortCode.Sid);
}
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCodes = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes->read();
foreach ($shortCodes as $shortCode) {
print($shortCode->shortCode);
}
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@short_codes = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes.list
@short_codes.each do |short_code|
puts short_code.url
end
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_codes = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes \
.list()
for short_code in short_codes:
print(short_code.sid)
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
ResourceSet<ShortCode> shortCodes = ShortCode.reader(pathServiceSid)
.read();
for (ShortCode shortCode : shortCodes) {
System.out.println(shortCode);
}
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"meta": {
"page": 0,
"page_size": 50,
"first_page_url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes?PageSize=50&Page=0",
"previous_page_url": null,
"next_page_url": null,
"key": "short_codes",
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes?PageSize=50&Page=0"
},
"short_codes": [
{
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
]
}
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes.create({shortCodeSid: 'SC3f94c94562ac88dccf16f8859a1a8b25'})
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var shortCode = ShortCodeResource.Create(pathServiceSid, shortCodeSid);
Console.WriteLine(shortCode.ShortCode);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCode = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes->create("SC3f94c94562ac88dccf16f8859a1a8b25");
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
client = Twilio::REST::Client.new(account_sid, auth_token)
short_code_sid = 'SC3f94c94562ac88dccf16f8859a1a8b25'
short_code = client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes
.create(short_code_sid: short_code_sid)
puts short_code.short_code
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_code = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes \
.create(short_code_sid="SC3f94c94562ac88dccf16f8859a1a8b25")
print(short_code.sid)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode shortCode = ShortCode.creator(pathServiceSid, shortCodeSid)
.create();
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes' -X POST \
--data-urlencode 'ShortCodeSid=SC3f94c94562ac88dccf16f8859a1a8b25' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
.fetch()
.then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var shortCode = ShortCodeResource.Fetch(pathServiceSid, shortCodeSid);
Console.WriteLine(shortCode.ShortCode);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCode = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes("SC3f94c94562ac88dccf16f8859a1a8b25")->fetch();
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@short_code = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes('SC3f94c94562ac88dccf16f8859a1a8b25')
.fetch
puts @short_code.url
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
short_codes = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
.fetch()
print(short_codes.country_code)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode shortCode = ShortCode.fetcher(pathServiceSid, shortCodeSid)
.fetch();
System.out.println(shortCode);
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
"sid": "SC3f94c94562ac88dccf16f8859a1a8b25",
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
"date_created": "2017-03-14T20:12:31Z",
"date_updated": "2017-03-14T20:12:33Z",
"short_code": "12345",
"country_code": "US",
"capabilities": ["sms", "mms"],
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25"
}
// Download the Node helper library from twilio.com/docs/libraries/node
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
service
.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
.remove()
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1.Service;
class Example
{
static void Main (string[] args)
{
// Find your Account SID and Auth Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
const string shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
TwilioClient.Init(accountSid, authToken);
var deleted = ShortCodeResource.Delete(pathServiceSid, shortCodeSid);
Console.WriteLine(deleted);
}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio = new Client($account_sid, $auth_token);
$shortCodes = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
->shortCodes("SC3f94c94562ac88dccf16f8859a1a8b25")->delete();
# Get twilio-ruby from twilio.com/docs/libraries/ruby
require 'twilio-ruby'
# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)
@deleted = @client.messaging.v1
.services('MG2172dd2db502e20dd981ef0d67850e1a')
.short_codes('SC3f94c94562ac88dccf16f8859a1a8b25')
.delete
puts @deleted
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
did_delete = client.messaging \
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
.delete()
print(did_delete)
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.service.ShortCode;
public class Example {
// Find your Account Sid and Token at twilio.com/console
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
// Initialize the client
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a";
String shortCodeSid = "SC3f94c94562ac88dccf16f8859a1a8b25";
ShortCode.deleter(pathServiceSid, shortCodeSid).delete();
}
}
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes/SC3f94c94562ac88dccf16f8859a1a8b25' -X DELETE \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{}