Roles

The Role resource of Programmable Chat represents what a user can do within a Chat Service instance. Roles are either Service scoped or Channel scoped.

Users are assigned a role at the Service scope, which determines what they are able to do within the Chat Service instance - e.g. create channels, destroy channels, and more.

Members are also assigned a role at the Channel scope, per channel. This determines what they are able to do within a particular channel - e.g. invite users to be members of the channel, post messages, kick members from the channel, and more.

Properties

Each role has these properties:

name description
sid A 34 character string that uniquely identifies this resource.
account_sid The unique id of the Account responsible for this role.
service_sid The unique id of the Service this role belongs to.
friendly_name The human-readable name of this role.
type What kind of role this is. Either channel for Channel roles or deployment for Service roles.
permissions A JSON array of the permissions this role has. See the table below for a list of all possible permissions.
date_created The date that this resource was created in ISO 8601 format.
date_updated The date that this resource was last updated in ISO 8601 format.
url An absolute URL for this role.

This is the complete list of possible permissions entries for deployment (Service) roles:

name description
createChannel Allows users to create new channels
joinChannel Allows users to join channels
destroyChannel Allows users to delete channels
inviteMember Allows users to invite other users to be members of a channel
removeMember Allows users to remove members from a channel
editChannelName Allows users to change the name of a channel
editChannelAttributes Allows users to update the optional attributes metadata field on a channel
addMember Allows users to add other users as members of a channel
editOwnMessage Allows users to edit their own messages in the Service
editAnyMessage Allows users to edit any message in the Service
editOwnMessageAttributes Allows users to edit the own message attributes in the Service
editAnyMessageAttributes Allows users to edit any message attributes in the Service
deleteAnyMessage Allows users to delete any message in the Service
editOwnUserInfo Allows users to edit their own User Info properties
editAnyUserInfo Allows users to edit other User's User Info properties

This is the complete list of possible permissions entries for channel roles:

name description
sendMessage Allows the user to send messages to channels
sendMediaMessage Allows the user to send media messages to channels
leaveChannel Allows users to leave a channel
destroyChannel Allows users to delete channels
inviteMember Allows users to invite other users to be members of a channel
removeMember Allows users to remove members from a channel
editChannelName Allows users to change the name of a channel
editChannelAttributes Allows users to update the optional attributes metadata field on a channel
addMember Allows users to add other users as members of a channel
editOwnMessage Allows users to edit their own messages in the Service
editAnyMessage Allows users to edit any message in the Service
editOwnMessageAttributes Allows users to edit the own message attributes in the Service
editAnyMessageAttributes Allows users to edit any message attributes in the Service
deleteOwnMessage Allows user to delete their own messages in the Service
deleteAnyMessage Allows users to delete any message in the Service
editOwnUserInfo Allows users to edit their own User Info properties
editAnyUserInfo Allows users to edit other User's User Info properties

List All Roles

GET /Services/{Instance SID}/Roles
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.list().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.list().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio.IpMessaging.Model;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve the list of roles
        var client = new IpMessagingClient(accountSid, authToken);
        RoleResult roles = client.ListRoles(serviceSid);
        Console.WriteLine(roles);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// List service
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$roles = $service->roles;
$all_roles = print_r($roles,true);
print $all_roles;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# List roles
roles = ip_messaging_client
        .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
        .roles.list
puts roles
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var roles = RoleResource.Read(serviceSid);

        foreach (var role in roles)
        {
            Console.WriteLine(role.FriendlyName);
        }
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

$roles = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles
    ->read();

// List roles
foreach ($roles as $role) {
    print $role->friendlyName . PHP_EOL;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# List the role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
for c in service.roles.list():
    print(c.sid)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# List roles
service.roles.each do |r|
  puts "Role #{r.sid} has permissions #{r.permissions.join(', ')}"
end
import com.twilio.sdk.resource.list.ipmessaging.RoleList;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        //List the roles
        RoleList list = service.getRoles();
        System.out.println(list);
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# List the roles
roles = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles.list()
for role in roles:
    print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    //List the roles
    ResourceSet<Role> roles = Role.reader(SERVICE_SID).read();

    for (Role role : roles) {
      System.out.println(role.getFriendlyName());
    }
  }
}
curl -G https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles \
    -u '{twilio account sid}:{twilio auth token}'
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Services/ISxxx/Roles?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles?PageSize=1000&Page=0",
    "next_page_url": null,
    "key": "roles"
  },
  "roles": [
    {
      "date_updated": "2015-10-30T08:34:21Z",
      "friendly_name": "service user",
      "account_sid": "ACxxx",
      "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
      "sid": "RLxxx",
      "date_created": "2015-10-30T08:34:21Z",
      "service_sid": "ISxxx",
      "type": "deployment",
      "permissions": [
        "createChannel",
        "joinChannel",
        "editOwnUserInfo"
      ]
    }
  ]
}
List all Roles

Create a Role

POST /Services/{Instance SID}/Roles

Parameters

name description
FriendlyName The human-readable name of this role.
Type What kind of role this is. Either channel for Channel roles or deployment for Service roles.
Permission (multiple) A permission this role should have. Consult the table above for the list of possible permissions.
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.create({
    friendlyName: 'role_name',
    type: 'deployment',
    permission: 'createChannel',
    permission: 'joinChannel'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);
const service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles
  .create({
    friendlyName: 'My role name',
    type: 'deployment',
    permission: ['createChannel', 'joinChannel'],
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string type = "deployment";
        const string friendlyName = "roleName"

        // Create a role
        List<string> permissions = new List<string>();
        permissions.Add("createChannel");
        permissions.Add("joinChannel");

        var client = new TwilioIpMessagingClient(accountSid, authToken);
        Role role = client.CreateRole(serviceSid, friendlyName, type, permissions);
        Console.WriteLine(role);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Create the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->create(array(
    'FriendlyName' => 'ROLE_NAME',
    'Type' => 'deployment',
    'Permission' => 'createChannel',
    'Permission' => 'joinChannel'
));

print $role;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

#create role
service = ip_messaging_client.services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
options = {:FriendlyName => 'friendlyName', :Type => 'deployment', :Permission => 'createChannel', :Permission => 'joinChannel'}
role = service.roles.create(options)
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "roleName";

        TwilioClient.Init(accountSid, authToken);

        // Create a role
        var permissions = new List<string>
        {
            "createChannel",
            "joinChannel"
        };

        var role = RoleResource.Create(serviceSid,
                                       friendlyName,
                                       RoleResource.RoleTypeEnum.Deployment,
                                       permissions);

        Console.WriteLine(role.Sid);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Create the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles
    ->create(
        'ROLE_NAME',
        'deployment',
        array('createChannel', 'joinChannel')
    );

echo $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Create role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.create(
    friendly_name="new_role",
    role_type="deployment",
    permission=["createChannel", "joinChannel"]
)
print(role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Create role
role = service.roles.create(
    friendly_name: 'friendlyName',
    type: 'deployment',
    permission: ['createChannel', 'joinChannel'])

puts "Created role #{role.sid}."
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Create a role
        final List<NameValuePair> roleParams = new ArrayList<NameValuePair>();
        roleParams.add(new BasicNameValuePair("FriendlyName", "RoleName"));
        roleParams.add(new BasicNameValuePair("Type", "deployment"));
        roleParams.add(new BasicNameValuePair("Permission", "createChannel"));
        roleParams.add(new BasicNameValuePair("Permission", "joinChannel"));

        final Map<String, String> roleparams = new HashMap<String, String>();
        roleparams.put("FriendlyName", "RoleName");
        Role role = service.createRole(roleparams);
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Create role
role = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles.create(
    friendly_name="new_role",
    type="deployment",
    permission=["createChannel", "joinChannel"]
)

print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import java.util.Arrays;
import java.util.List;

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    List<String> permissions = Arrays.asList("createChannel", "joinChannel");

    // Create a role
    Role role = Role
        .creator(SERVICE_SID, "RoleName", Role.RoleType.DEPLOYMENT, permissions)
        .create();

    System.out.println(role.getSid());
  }
}
curl -XPOST https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles \
    -d "FriendlyName=my role" \
    -d "Type=channel" \
    -d "Permission=sendMessage" \
    -d "Permission=leaveChannel" \
    -u '{twilio account sid}:{twilio auth token}'
  {
    "date_updated": "2015-10-30T08:34:21Z",
    "friendly_name": "my role",
    "account_sid": "ACxxx",
    "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
    "sid": "RLxxx",
    "date_created": "2015-10-30T08:34:21Z",
    "service_sid": "ISxxx",
    "type": "channel",
    "permissions": [
      "leaveChannel",
      "sendMesssage"
    ]
  }
Create a Role

Retrieve a Role

GET /Services/{Instance SID}/Roles/{Role SID}
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').get().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio.IpMessaging.Model;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve the role
        var client = new IpMessagingClient(accountSid, authToken);
        Role role = client.GetRole(serviceSid,roleSid);
        Console.WriteLine(role);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->get("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $role;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# Retrieve role
role = ip_messaging_client
       .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var role = RoleResource.Fetch(serviceSid, roleSid);

        Console.WriteLine(role.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Retrieve the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

echo $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Retrieve role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print(role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Retrieve role
role = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts role
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Retrieve the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Retrieve role
role = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the role
    Role role = Role.fetcher(SERVICE_SID, ROLE_SID).fetch();

    System.out.println(role.getFriendlyName());
  }
}
curl -G https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -u '{twilio account sid}:{twilio auth token}'
{
  "date_updated": "2015-10-30T08:34:21Z",
  "friendly_name": "service user",
  "account_sid": "ACxxx",
  "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
  "sid": "RLxxx",
  "date_created": "2015-10-30T08:34:21Z",
  "service_sid": "ISxxx",
  "type": "deployment",
  "permissions": [
    "createChannel",
    "joinChannel",
    "editOwnUserInfo"
  ]
}
Retrieve a Role

Update a Role

POST /Services/{Instance SID}/Roles/{Role SID}

Parameters

name description
Permission (multiple) A permission this role should have. Consult the table above for the list of possible permissions.
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').post({
    permission: 'sendMessage',
    permission: 'leaveChannel'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);
const service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service
  .roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then(role => {
    const newPermissions = ['sendMediaMessage'].concat(role.permissions || []);
    return role.update({permission: newPermissions});
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string friendlyName = "friendlyName";

        // Update the role
        List<string> permissions = new List<string>();
        permissions.Add("sendMessage");
        permissions.Add("leaveChannel");

        var client = new TwilioIpMessagingClient(accountSid, authToken);
        Role role = client.UpdateRole(serviceSid, roleSid, friendlyName, permissions);
        Console.WriteLine(role);
    }
}
<?php
// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Update the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->get("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$response = $role->update(
    array(
        "Permission" => "sendMessage",
        "Permission" => "leaveChannel"
    )
);

print $response;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Update a role
service = ip_messaging_client.services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
role = service.roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
options = {:Permission => 'sendMessage', :Permission => 'leaveChannel'}
role = role.update(options)
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Update the role
        var empty_list = new List<string>();
        var newPermissions = new List<string> { "sendMessage" };

        var role = RoleResource.Fetch(serviceSid, roleSid);
        newPermissions.AddRange(role.Permissions ?? empty_list);

        role = RoleResource.Update(serviceSid, roleSid, newPermissions);

        foreach (var permission in role.Permissions)
        {
            Console.WriteLine(permission);
        }
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Update the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

$new_permissions = array_merge(['sendMediaMessage'], $role->permissions || []);
$role->update($new_permissions);

print $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Update role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
updated_role = role.update(permission=["sendMessage", "leaveChannel"])
print(updated_role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
client = Twilio::REST::Client.new(account_sid, auth_token)
service = client.chat.v2.services(service_sid)

# Update a role
role = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
new_permissions = role.permissions | ['sendMediaMessage']
role = role.update(permission: new_permissions)
puts "Role #{role.sid} now has permissions #{role.permissions.join(', ')}"
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Get the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        // Update the role
        final List<NameValuePair> roleParams = new ArrayList<NameValuePair>();
        roleParams.add(new BasicNameValuePair("Permission", "sendMessage"));
        roleParams.add(new BasicNameValuePair("Permission", "leaveChannel"));
        role.update(roleParams);
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Update role
role = client.chat \
    .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .fetch()

new_permissions = ['sendMediaMessage'] + (role.permissions or [])
role.update(permission=new_permissions)

print(role.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install
import java.util.*;

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Role role = Role.fetcher(SERVICE_SID, ROLE_SID).fetch();
    List<String> newPermissions = new ArrayList<>(Arrays.asList("sendMediaMessage"));
    newPermissions.addAll(role.getPermissions());

    // Update the role
    role = Role.updater(SERVICE_SID, ROLE_SID, newPermissions).update();
  }
}
curl -XPOST https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -d "Permission=sendMessage" \
    -d "Permission=leaveChannel" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "date_updated": "2015-10-30T08:34:21Z",
  "friendly_name": "service user",
  "account_sid": "ACxxx",
  "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
  "sid": "RLxxx",
  "date_created": "2015-10-30T08:34:21Z",
  "service_sid": "ISxxx",
  "type": "deployment",
  "permissions": [
    "leaveChannel",
    "sendMessage"
  ]
}
Update a Role

Delete a Role

DELETE /Services/{Instance SID}/Roles/{Role SID}
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string type = "deployment";

        // Delete a role
        var client = new TwilioIpMessagingClient(accountSid, authToken);
        DeleteStatus status = client.DeleteStatus(serviceSid, roleSid);
        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Delete the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$response = $service->roles->delete("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $response;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# Delete a role
response = ip_messaging_client
           .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .delete
puts response
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var status = RoleResource.Delete(serviceSid, roleSid);

        Console.WriteLine(status);
    }
}
<?php

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Delete the role
$client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Delete role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
response = role.delete()
print(response)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Delete a particular role
result = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete
puts result # should be true
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Get the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        // Delete the role
        boolean didDelete = role.delete();
        System.out.println(didDelete);
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Delete role
response = client.chat \
                  .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
                  .roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
                  .delete()
print(response)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Delete the role
    boolean didDelete = Role.deleter(SERVICE_SID, ROLE_SID).delete();
    System.out.println(didDelete);
  }
}
curl -XDELETE https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -u '{twilio account sid}:{twilio auth token}'
HTTP/1.1 204 NO CONTENT
Delete a Role

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...
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.list().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.list().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio.IpMessaging.Model;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve the list of roles
        var client = new IpMessagingClient(accountSid, authToken);
        RoleResult roles = client.ListRoles(serviceSid);
        Console.WriteLine(roles);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// List service
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$roles = $service->roles;
$all_roles = print_r($roles,true);
print $all_roles;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# List roles
roles = ip_messaging_client
        .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
        .roles.list
puts roles
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var roles = RoleResource.Read(serviceSid);

        foreach (var role in roles)
        {
            Console.WriteLine(role.FriendlyName);
        }
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

$roles = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles
    ->read();

// List roles
foreach ($roles as $role) {
    print $role->friendlyName . PHP_EOL;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# List the role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
for c in service.roles.list():
    print(c.sid)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# List roles
service.roles.each do |r|
  puts "Role #{r.sid} has permissions #{r.permissions.join(', ')}"
end
import com.twilio.sdk.resource.list.ipmessaging.RoleList;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        //List the roles
        RoleList list = service.getRoles();
        System.out.println(list);
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# List the roles
roles = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles.list()
for role in roles:
    print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    //List the roles
    ResourceSet<Role> roles = Role.reader(SERVICE_SID).read();

    for (Role role : roles) {
      System.out.println(role.getFriendlyName());
    }
  }
}
curl -G https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles \
    -u '{twilio account sid}:{twilio auth token}'
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Services/ISxxx/Roles?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles?PageSize=1000&Page=0",
    "next_page_url": null,
    "key": "roles"
  },
  "roles": [
    {
      "date_updated": "2015-10-30T08:34:21Z",
      "friendly_name": "service user",
      "account_sid": "ACxxx",
      "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
      "sid": "RLxxx",
      "date_created": "2015-10-30T08:34:21Z",
      "service_sid": "ISxxx",
      "type": "deployment",
      "permissions": [
        "createChannel",
        "joinChannel",
        "editOwnUserInfo"
      ]
    }
  ]
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles.create({
    friendlyName: 'role_name',
    type: 'deployment',
    permission: 'createChannel',
    permission: 'joinChannel'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);
const service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles
  .create({
    friendlyName: 'My role name',
    type: 'deployment',
    permission: ['createChannel', 'joinChannel'],
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string type = "deployment";
        const string friendlyName = "roleName"

        // Create a role
        List<string> permissions = new List<string>();
        permissions.Add("createChannel");
        permissions.Add("joinChannel");

        var client = new TwilioIpMessagingClient(accountSid, authToken);
        Role role = client.CreateRole(serviceSid, friendlyName, type, permissions);
        Console.WriteLine(role);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Create the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->create(array(
    'FriendlyName' => 'ROLE_NAME',
    'Type' => 'deployment',
    'Permission' => 'createChannel',
    'Permission' => 'joinChannel'
));

print $role;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

#create role
service = ip_messaging_client.services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
options = {:FriendlyName => 'friendlyName', :Type => 'deployment', :Permission => 'createChannel', :Permission => 'joinChannel'}
role = service.roles.create(options)
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "roleName";

        TwilioClient.Init(accountSid, authToken);

        // Create a role
        var permissions = new List<string>
        {
            "createChannel",
            "joinChannel"
        };

        var role = RoleResource.Create(serviceSid,
                                       friendlyName,
                                       RoleResource.RoleTypeEnum.Deployment,
                                       permissions);

        Console.WriteLine(role.Sid);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Create the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles
    ->create(
        'ROLE_NAME',
        'deployment',
        array('createChannel', 'joinChannel')
    );

echo $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Create role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.create(
    friendly_name="new_role",
    role_type="deployment",
    permission=["createChannel", "joinChannel"]
)
print(role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Create role
role = service.roles.create(
    friendly_name: 'friendlyName',
    type: 'deployment',
    permission: ['createChannel', 'joinChannel'])

puts "Created role #{role.sid}."
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Create a role
        final List<NameValuePair> roleParams = new ArrayList<NameValuePair>();
        roleParams.add(new BasicNameValuePair("FriendlyName", "RoleName"));
        roleParams.add(new BasicNameValuePair("Type", "deployment"));
        roleParams.add(new BasicNameValuePair("Permission", "createChannel"));
        roleParams.add(new BasicNameValuePair("Permission", "joinChannel"));

        final Map<String, String> roleparams = new HashMap<String, String>();
        roleparams.put("FriendlyName", "RoleName");
        Role role = service.createRole(roleparams);
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Create role
role = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles.create(
    friendly_name="new_role",
    type="deployment",
    permission=["createChannel", "joinChannel"]
)

print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import java.util.Arrays;
import java.util.List;

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    List<String> permissions = Arrays.asList("createChannel", "joinChannel");

    // Create a role
    Role role = Role
        .creator(SERVICE_SID, "RoleName", Role.RoleType.DEPLOYMENT, permissions)
        .create();

    System.out.println(role.getSid());
  }
}
curl -XPOST https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles \
    -d "FriendlyName=my role" \
    -d "Type=channel" \
    -d "Permission=sendMessage" \
    -d "Permission=leaveChannel" \
    -u '{twilio account sid}:{twilio auth token}'
  {
    "date_updated": "2015-10-30T08:34:21Z",
    "friendly_name": "my role",
    "account_sid": "ACxxx",
    "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
    "sid": "RLxxx",
    "date_created": "2015-10-30T08:34:21Z",
    "service_sid": "ISxxx",
    "type": "channel",
    "permissions": [
      "leaveChannel",
      "sendMesssage"
    ]
  }
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').get().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio.IpMessaging.Model;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve the role
        var client = new IpMessagingClient(accountSid, authToken);
        Role role = client.GetRole(serviceSid,roleSid);
        Console.WriteLine(role);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->get("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $role;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# Retrieve role
role = ip_messaging_client
       .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var role = RoleResource.Fetch(serviceSid, roleSid);

        Console.WriteLine(role.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Retrieve the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

echo $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Retrieve role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print(role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Retrieve role
role = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts role
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Retrieve the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Retrieve role
role = client.chat.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(role.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the role
    Role role = Role.fetcher(SERVICE_SID, ROLE_SID).fetch();

    System.out.println(role.getFriendlyName());
  }
}
curl -G https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -u '{twilio account sid}:{twilio auth token}'
{
  "date_updated": "2015-10-30T08:34:21Z",
  "friendly_name": "service user",
  "account_sid": "ACxxx",
  "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
  "sid": "RLxxx",
  "date_created": "2015-10-30T08:34:21Z",
  "service_sid": "ISxxx",
  "type": "deployment",
  "permissions": [
    "createChannel",
    "joinChannel",
    "editOwnUserInfo"
  ]
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').post({
    permission: 'sendMessage',
    permission: 'leaveChannel'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);
const service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service
  .roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then(role => {
    const newPermissions = ['sendMediaMessage'].concat(role.permissions || []);
    return role.update({permission: newPermissions});
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string friendlyName = "friendlyName";

        // Update the role
        List<string> permissions = new List<string>();
        permissions.Add("sendMessage");
        permissions.Add("leaveChannel");

        var client = new TwilioIpMessagingClient(accountSid, authToken);
        Role role = client.UpdateRole(serviceSid, roleSid, friendlyName, permissions);
        Console.WriteLine(role);
    }
}
<?php
// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Update the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$role = $service->roles->get("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$response = $role->update(
    array(
        "Permission" => "sendMessage",
        "Permission" => "leaveChannel"
    )
);

print $response;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Update a role
service = ip_messaging_client.services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
role = service.roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
options = {:Permission => 'sendMessage', :Permission => 'leaveChannel'}
role = role.update(options)
puts role
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Update the role
        var empty_list = new List<string>();
        var newPermissions = new List<string> { "sendMessage" };

        var role = RoleResource.Fetch(serviceSid, roleSid);
        newPermissions.AddRange(role.Permissions ?? empty_list);

        role = RoleResource.Update(serviceSid, roleSid, newPermissions);

        foreach (var permission in role.Permissions)
        {
            Console.WriteLine(permission);
        }
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Update the role
$role = $client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

$new_permissions = array_merge(['sendMediaMessage'], $role->permissions || []);
$role->update($new_permissions);

print $role->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Update role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
updated_role = role.update(permission=["sendMessage", "leaveChannel"])
print(updated_role)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
client = Twilio::REST::Client.new(account_sid, auth_token)
service = client.chat.v2.services(service_sid)

# Update a role
role = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
new_permissions = role.permissions | ['sendMediaMessage']
role = role.update(permission: new_permissions)
puts "Role #{role.sid} now has permissions #{role.permissions.join(', ')}"
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Get the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        // Update the role
        final List<NameValuePair> roleParams = new ArrayList<NameValuePair>();
        roleParams.add(new BasicNameValuePair("Permission", "sendMessage"));
        roleParams.add(new BasicNameValuePair("Permission", "leaveChannel"));
        role.update(roleParams);
        System.out.println(role.toString());
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Update role
role = client.chat \
    .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .fetch()

new_permissions = ['sendMediaMessage'] + (role.permissions or [])
role.update(permission=new_permissions)

print(role.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install
import java.util.*;

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Role role = Role.fetcher(SERVICE_SID, ROLE_SID).fetch();
    List<String> newPermissions = new ArrayList<>(Arrays.asList("sendMediaMessage"));
    newPermissions.addAll(role.getPermissions());

    // Update the role
    role = Role.updater(SERVICE_SID, ROLE_SID, newPermissions).update();
  }
}
curl -XPOST https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -d "Permission=sendMessage" \
    -d "Permission=leaveChannel" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "date_updated": "2015-10-30T08:34:21Z",
  "friendly_name": "service user",
  "account_sid": "ACxxx",
  "url": "https://chat.twilio.com/v2/Services/ISxxx/Roles/RLxxx",
  "sid": "RLxxx",
  "date_created": "2015-10-30T08:34:21Z",
  "service_sid": "ISxxx",
  "type": "deployment",
  "permissions": [
    "leaveChannel",
    "sendMessage"
  ]
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string authToken = "your_auth_token";
        string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string type = "deployment";

        // Delete a role
        var client = new TwilioIpMessagingClient(accountSid, authToken);
        DeleteStatus status = client.DeleteStatus(serviceSid, roleSid);
        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Delete the role
$service = $client->services->get("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
$response = $service->roles->delete("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $response;
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new account_sid,
                                                          auth_token

# Delete a role
response = ip_messaging_client
           .services.get('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .roles.get('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .delete
puts response
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2.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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var status = RoleResource.Delete(serviceSid, roleSid);

        Console.WriteLine(status);
    }
}
<?php

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Delete the role
$client->chat
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Initialize the Client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

# Delete role
service = client.services.get(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
role = service.roles.get(sid="RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
response = role.delete()
print(response)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@client = Twilio::REST::Client.new(account_sid, auth_token)
service = @client.chat.v2.services(service_sid)

# Delete a particular role
result = service.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete
puts result # should be true
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Role;
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Service;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);
        Service service = client.getService(SERVICE_SID);

        // Get the role
        Role role = service.getRole("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        // Delete the role
        boolean didDelete = role.delete();
        System.out.println(didDelete);
    }
}
# 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/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Delete role
response = client.chat \
                  .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
                  .roles("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
                  .delete()
print(response)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Role;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ROLE_SID = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Delete the role
    boolean didDelete = Role.deleter(SERVICE_SID, ROLE_SID).delete();
    System.out.println(didDelete);
  }
}
curl -XDELETE https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    -u '{twilio account sid}:{twilio auth token}'
HTTP/1.1 204 NO CONTENT