REST API: Messaging Services

Public Beta
Twilio's Messaging Services API is currently available as a Public Beta product. Some features are not yet implemented and others may be changed before the product is declared as Generally Available.
Public Beta products are not covered by a Twilio SLA.
Code samples are written using the "Edge" (aka "alpha" branch) versions of the Twilio helper libraries.

When messages are sent using a Messaging Service, enabled Copilot features assist to improve performance of the message.

Developers can associate phone numbers, short codes, and alpha sender IDs to an instance of a Messaging Service. All inbound and outbound behaviors for the phone numbers and shortcodes are handled by the configuration of the Service.

Twilio Console

You can manage your Messaging Services through the Twilio Console when logged in.

Messaging Services Resource

The Services resource of Messaging represents a set of configurable behavior for sending and receiving Messages.

Subresources

The Services resource also has phone numbers, short codes, and alpha sender IDs subresources for managing the phone numbers, short codes, and alpha sender IDs associated to the Service.

Resource URI

All URLs in this documentation use the following base URL:

https://messaging.twilio.com/v1

Properties

Each service has the following properties:

Property Description
sid Unique 34 character ID of the Service.
account_sid Unique 34 character ID of the Account that created this Service.
date_created The date that this resource was created.
date_updated The date that this resource was last updated.
friendly_name A human readable descriptive text for this resource, up to 64 characters.
sticky_sender Configuration to enable or disable Sticky Sender on your Service instance. Possible values are true and false.
mms_converter Configuration to enable or disable MMS Converter for messages sent through your Service instance. Possible values are true and false.
smart_encoding Configuration to enable or disable Smart Encoding for messages sent through your Service instance. Possible values are true and false.
fallback_to_long_code Configuration to enable or disable Fallback to Long Code for messages sent through your Service instance. Possible values are true and false.
area_code_geomatch Configuration to enable or disable Area Code Geomatch on your Service Instance. Possible values are true and false.
validity_period The number of seconds all messages sent from your Service are valid for. Acceptable integers range from 1 to 14,400.
inbound_request_url The URL Twilio will make a webhook request to when a message is received by any phone number or short code in your Service. When this property is null receiving inbound messages is disabled. All messages sent to your Twilio phone number or short code will not be logged and received on your Account.
inbound_method The HTTP method Twilio will use when making requests to the Inbound Request URL. Possible values are GET or POST.
status_callback The URL Twilio will make a webhook request to when passing you status updates about the delivery of your messages.
fallback_url The URL that Twilio will request if an error occurs when retrieving or executing the TwiML from your Inbound Request URL.
fallback_method The HTTP method Twilio will use when making requests to the Fallback URL. Possible values include GET or POST.

List all Services

GET /Services
Loading Code Samples...
Language
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.messaging.v1.Service;

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);

        ResourceSet<Service> services = Service.reader().read();

        for (Service service : services) {
            System.out.println(service);
        }
    }
}
# 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)

services = client.messaging.services.list()

for service in services:
    print(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);

client.messaging.services.list()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 services = ServiceResource.Read();

      foreach (var service in services)
      {
        Console.WriteLine(service.Sid);
      }
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$twilio = new Client($sid, $token);

$services = $twilio->messaging->v1->services->read();

foreach ($services as $service) {
    print($service->sid);
}
# 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)

@services = @client.messaging.v1.services.list

@services.each do |service|
  puts service.friendly_name
end
{
    "meta": {
        "page": 0,
        "page_size": 50,
        "first_page_url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0",
        "previous_page_url": null,
        "next_page_url": null,
        "key": "services",
        "url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0"
    },
    "services": [
        {
            "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "friendly_name": "My Service!",
            "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
            "date_created": "2017-03-14T20:12:31Z",
            "date_updated": "2017-03-14T20:12:33Z",
            "sticky_sender": true,
            "mms_converter": true,
            "inbound_request_url": "https://www.example.com/",
            "inbound_method": "POST",
            "fallback_url": null,
            "fallback_method": "POST",
            "status_callback": "http://requestb.in/1234abcd",
            "links": {
            "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
            "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
            "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
            },
            "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
        }
    ]
}
List all Services

Create a Service

POST /Services
Loading Code Samples...
Language
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.creator("My First Service").create();
    }
}
# 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)

service = client.messaging \
                .services \
                .create(friendly_name="My First Service")

print(service.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 opts = {
  friendlyName: 'My First Service',
  statusCallback: 'http://requestb.in/1234abcd'
};

client.messaging.services.create(opts)
    .then(function(response) {
      console.log(response);
    }).catch(function(error) {
      console.log(error);
    });
curl 'https://messaging.twilio.com/v1/Services' -X POST \
    --data-urlencode 'FriendlyName=My First Service' \
    --data-urlencode 'StatusCallback=http://requestb.in/1234abcd' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 serviceFriendlyName = "My First Service";

      TwilioClient.Init(accountSid, authToken);

      var service = ServiceResource.Create(serviceFriendlyName);

      Console.WriteLine(service.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
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);

$service = $twilio->messaging->v1->services->create("My First Service",
                                                    array('statusCallback' => "http://requestb.in/1234abcd")
                                                   );
# 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)

@service = @client.messaging.v1
  .services
  .create(
    friendly_name: 'My First Service',
    status_callback: 'http://requestb.in/1234abcd')

puts @service.sid
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": null,
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "http://requestb.in/1234abcd",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
Create a Service

Required Parameters

Parameter Description
FriendlyName A human readable descriptive text for this resource, up to 64 characters.

Optional Parameters

Parameter Description
MmsConverter Configuration to enable or disable MMS Converter on your Service Instance. Possible values are true and false. Default value is true.
StickySender Configuration to enable or disable Sticky Sender on your Service Instance. Possible values are true and false. Default value is true.
SmartEncoding Configuration to enable or disable Smart Encoding. Possible values are true and false. Default value is true.
FallbackToLongCode Configuration to enable or disable Fallback to Long Code. Possible values are true and false. Default value is false.
AreaCodeGeomatch Configuration to enable or disable Area Code Geomatch. Possible values are true and false. Default value is false.
ValidityPeriod Configuration to set the validity period of all messages sent from your Service, in seconds. Acceptable integers range from 1 to 14,400. Default value is 14,400.
InboundRequestUrl A webhook request is made to the Inbound Request URL when a message is received by any phone number or shortcode associated to your Messaging Service. Set to null to disable inbound messaging.
InboundMethod The HTTP method used when making requests to the Inbound Request URL. Either GET or POST. Default value is POST.
FallbackUrl A request is made to the Fallback URL if an error occurs with retrieving or executing the TwiML from you Inbound Request URL.
FallbackMethod The HTTP method used when requesting the Fallback URL. Either GET or POST. Default value is POST.
StatusCallback A webhook request is made to the Status Callback to pass status updates about your messages. These status updates let you know if your accepted message were successfully sent and delivered or if a delivery related error may have occurred.

View a Service

GET /Services/{Service Sid}
Loading Code Samples...
Language
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.fetcher("MG2172dd2db502e20dd981ef0d67850e1a")
                                 .fetch();

        System.out.println(service);
    }
}
# 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)

service = client.messaging \
                .services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
                .fetch()

print(service.friendly_name)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .fetch()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 service = ServiceResource.Fetch(pathServiceSid);

      Console.WriteLine(service.FriendlyName);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '[AuthToken]';
$twilio = new Client($account_sid, $auth_token);

$services = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")->fetch();

print($services->sid);
# 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)

@service = @client.messaging.v1
  .services('MG2172dd2db502e20dd981ef0d67850e1a')
  .fetch

puts @service.friendly_name
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "friendly_name": "My Service!",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": "https://www.example.com/",
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "http://requestb.in/1234abcd",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
View a Service

Update a Service Instance

POST /Services/{Service Sid}

You may specify one or more of the optional parameters above to update the Service's respective properties. Parameters not specified in your request are not updated.

Loading Code Samples...
Language
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.updater("MG2172dd2db502e20dd981ef0d67850e1a")
                .setInboundRequestUrl("http://www.example.com")
                .update();
    }
}
# 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)

service = client.messaging \
                .services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
                .update(inbound_request_url="http://www.example.com")

print(service.inbound_request_url)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .update({inboundRequestUrl: 'http://www.example.com'})
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' -X POST \
    --data-urlencode 'InboundRequestUrl=https://www.example.com' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 service = ServiceResource.Update(pathServiceSid,
        inboundRequestUrl : new Uri("http://www.example.com"));

    Console.WriteLine(service.FriendlyName);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
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);

$service = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
                                                       ->update( array( "inboundRequestUrl" => "http://www.example.com" )
                                                        );
# 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)

@service = @client.messaging.v1
  .services('MG2172dd2db502e20dd981ef0d67850e1a')
  .update(inbound_request_url: 'http://www.example.com')

puts @service.inbound_request_url
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "friendly_name": "My Service!",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": "https://www.example.com/",
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "https://www.example.com",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
Update a Service

Delete a Service Instance

DELETE /Services/{Service Sid}

When a Service is deleted, all phone numbers and short codes in the Service are returned to your Account.

Loading Code Samples...
Language
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service.deleter("MG2172dd2db502e20dd981ef0d67850e1a").delete();
    }
}
# 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") \
                   .delete()

print(did_delete)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .remove()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' -X DELETE \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 deleted = ServiceResource.Delete(pathServiceSid);

      Console.WriteLine(deleted);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '[AuthToken]';
$twilio = new Client($account_sid, $auth_token);

$services = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")->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')
  .delete

puts @deleted
{}
Delete a Service

Need some help?

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.

1 / 1
Loading Code Samples...
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.messaging.v1.Service;

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);

        ResourceSet<Service> services = Service.reader().read();

        for (Service service : services) {
            System.out.println(service);
        }
    }
}
# 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)

services = client.messaging.services.list()

for service in services:
    print(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);

client.messaging.services.list()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 services = ServiceResource.Read();

      foreach (var service in services)
      {
        Console.WriteLine(service.Sid);
      }
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$twilio = new Client($sid, $token);

$services = $twilio->messaging->v1->services->read();

foreach ($services as $service) {
    print($service->sid);
}
# 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)

@services = @client.messaging.v1.services.list

@services.each do |service|
  puts service.friendly_name
end
{
    "meta": {
        "page": 0,
        "page_size": 50,
        "first_page_url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0",
        "previous_page_url": null,
        "next_page_url": null,
        "key": "services",
        "url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0"
    },
    "services": [
        {
            "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "friendly_name": "My Service!",
            "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
            "date_created": "2017-03-14T20:12:31Z",
            "date_updated": "2017-03-14T20:12:33Z",
            "sticky_sender": true,
            "mms_converter": true,
            "inbound_request_url": "https://www.example.com/",
            "inbound_method": "POST",
            "fallback_url": null,
            "fallback_method": "POST",
            "status_callback": "http://requestb.in/1234abcd",
            "links": {
            "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
            "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
            "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
            },
            "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
        }
    ]
}
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.creator("My First Service").create();
    }
}
# 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)

service = client.messaging \
                .services \
                .create(friendly_name="My First Service")

print(service.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 opts = {
  friendlyName: 'My First Service',
  statusCallback: 'http://requestb.in/1234abcd'
};

client.messaging.services.create(opts)
    .then(function(response) {
      console.log(response);
    }).catch(function(error) {
      console.log(error);
    });
curl 'https://messaging.twilio.com/v1/Services' -X POST \
    --data-urlencode 'FriendlyName=My First Service' \
    --data-urlencode 'StatusCallback=http://requestb.in/1234abcd' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 serviceFriendlyName = "My First Service";

      TwilioClient.Init(accountSid, authToken);

      var service = ServiceResource.Create(serviceFriendlyName);

      Console.WriteLine(service.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
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);

$service = $twilio->messaging->v1->services->create("My First Service",
                                                    array('statusCallback' => "http://requestb.in/1234abcd")
                                                   );
# 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)

@service = @client.messaging.v1
  .services
  .create(
    friendly_name: 'My First Service',
    status_callback: 'http://requestb.in/1234abcd')

puts @service.sid
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": null,
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "http://requestb.in/1234abcd",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.fetcher("MG2172dd2db502e20dd981ef0d67850e1a")
                                 .fetch();

        System.out.println(service);
    }
}
# 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)

service = client.messaging \
                .services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
                .fetch()

print(service.friendly_name)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .fetch()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 service = ServiceResource.Fetch(pathServiceSid);

      Console.WriteLine(service.FriendlyName);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '[AuthToken]';
$twilio = new Client($account_sid, $auth_token);

$services = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")->fetch();

print($services->sid);
# 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)

@service = @client.messaging.v1
  .services('MG2172dd2db502e20dd981ef0d67850e1a')
  .fetch

puts @service.friendly_name
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "friendly_name": "My Service!",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": "https://www.example.com/",
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "http://requestb.in/1234abcd",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service service = Service.updater("MG2172dd2db502e20dd981ef0d67850e1a")
                .setInboundRequestUrl("http://www.example.com")
                .update();
    }
}
# 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)

service = client.messaging \
                .services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
                .update(inbound_request_url="http://www.example.com")

print(service.inbound_request_url)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .update({inboundRequestUrl: 'http://www.example.com'})
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' -X POST \
    --data-urlencode 'InboundRequestUrl=https://www.example.com' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 service = ServiceResource.Update(pathServiceSid,
        inboundRequestUrl : new Uri("http://www.example.com"));

    Console.WriteLine(service.FriendlyName);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
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);

$service = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
                                                       ->update( array( "inboundRequestUrl" => "http://www.example.com" )
                                                        );
# 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)

@service = @client.messaging.v1
  .services('MG2172dd2db502e20dd981ef0d67850e1a')
  .update(inbound_request_url: 'http://www.example.com')

puts @service.inbound_request_url
{
     "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
     "friendly_name": "My Service!",
     "sid": "MG2172dd2db502e20dd981ef0d67850e1a",
     "date_created": "2017-03-14T20:12:31Z",
     "date_updated": "2017-03-14T20:12:33Z",
     "friendly_name": "My First Service!",
     "inbound_request_url": "https://www.example.com/",
     "inbound_method": "POST",
     "fallback_url": null,
     "fallback_method": "POST",
     "status_callback": "https://www.example.com",
     "sticky_sender": true,
     "mms_converter": true,
     "links": {
     "phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
     "short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
     "alpha_senders": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/AlphaSenders"
                    },
     "url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a"
}
Format:
  • JSON
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;

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);

        Service.deleter("MG2172dd2db502e20dd981ef0d67850e1a").delete();
    }
}
# 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") \
                   .delete()

print(did_delete)
// 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);

client.messaging
      .services('MG2172dd2db502e20dd981ef0d67850e1a')
      .remove()
      .then(function(response) {
        console.log(response);
      }).catch(function(error) {
        console.log(error);
      });
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a' -X DELETE \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Messaging.V1;


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 deleted = ServiceResource.Delete(pathServiceSid);

      Console.WriteLine(deleted);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '[AuthToken]';
$twilio = new Client($account_sid, $auth_token);

$services = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")->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')
  .delete

puts @deleted
{}