Role Resource
The Role resource of Programmable Chat represents what a user can do within a Chat Service instance. Roles are scoped to either a Service or a
Channel .
Users are assigned a role at the Service scope, which determines what they are
can do within the Chat Service instance, such as create and destroy channels.
Members are assigned a role at the Channel scope. This determines what they are able to do within a particular channel, such as invite users to be members of the channel, post messages, and remove members from the channel.
See Permission values for information about the permissions that can be assigned in each scope.
Each Role resource contains these properties.
Resource properties The unique string that we created to identify the Role resource.
The string that you assigned to describe the resource.
Possible values:
channel
deployment
An array of the permissions the role has been granted.
date_created
type: string<DATE TIME> Not PIIdate_updated
type: string<DATE TIME> Not PIIThe absolute URL of the Role resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
URI parameters Request body parameters Required
A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
Required
Possible values:
channel
deployment
Required
A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's type
.
_15 // Download the helper library from https://www.twilio.com/docs/node/install
_15 // Find your Account SID and Auth Token at twilio.com/console
_15 // and set the environment variables. See http://twil.io/secure
_15 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15 const authToken = process.env.TWILIO_AUTH_TOKEN;
_15 const client = require('twilio')(accountSid, authToken);
_15 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_15 friendlyName: 'friendly_name',
_15 permission: ['permission']
_15 .then(role => console.log(role.sid));
_16 "sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "friendly_name": "channel user",
_16 "date_created": "2016-03-03T19:47:15Z",
_16 "date_updated": "2016-03-03T19:47:15Z",
_16 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
URI parameters Path Parameter
The SID of the Role resource to fetch.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(role => console.log(role.friendlyName));
_16 "sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "friendly_name": "channel user",
_16 "date_created": "2016-03-03T19:47:15Z",
_16 "date_updated": "2016-03-03T19:47:15Z",
_16 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
URI parameters Query Parameter
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Query Parameter
The page index. This value is simply for client state.
Query Parameter
The page token. This is provided by the API.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(roles => roles.forEach(r => console.log(r.sid)));
_29 "first_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29 "previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29 "next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=1",
_29 "sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29 "friendly_name": "channel user",
_29 "date_created": "2016-03-03T19:47:15Z",
_29 "date_updated": "2016-03-03T19:47:15Z",
_29 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
URI parameters Path Parameter
The SID of the Role resource to update.
Request body parameters Required
A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's type
.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .update({permission: ['permission']})
_11 .then(role => console.log(role.friendlyName));
_16 "sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16 "friendly_name": "channel user",
_16 "date_created": "2016-03-03T19:47:15Z",
_16 "date_updated": "2016-03-03T19:47:15Z",
_16 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
URI parameters Path Parameter
The SID of the Role resource to delete.
_10 // Download the helper library from https://www.twilio.com/docs/node/install
_10 // Find your Account SID and Auth Token at twilio.com/console
_10 // and set the environment variables. See http://twil.io/secure
_10 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10 const authToken = process.env.TWILIO_AUTH_TOKEN;
_10 const client = require('twilio')(accountSid, authToken);
_10 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
These are the available permissions
entries for roles where type
= deployment .
Permission Enables the user to: addMember
Add other users as members of a channel createChannel
Create new channels deleteAnyMessage
Delete any message in the Service destroyChannel
Delete channels editAnyMessage
Edit any message in the Service editAnyMessageAttributes
Edit any message attributes in the Service editAnyUserInfo
Edit other User's User Info properties editChannelAttributes
Update the optional attributes
metadata field on a channel editChannelName
Change the name of a channel editOwnMessage
Edit their own messages in the Service editOwnMessageAttributes
Edit the own message attributes in the Service editOwnUserInfo
Edit their own User Info properties inviteMember
Invite other users to be members of a channel joinChannel
Join channels removeMember
Remove members from a channel
These are the available permissions
entries for roles where type
= channel .
Permission Enables the user to: addMember
Add other users as members of a channel deleteAnyMessage
Delete any message in the channel deleteOwnMessage
Delete their own messages in the channel destroyChannel
Delete channels editAnyMessage
Edit any message in the channel editAnyMessageAttributes
Edit any message attributes in the channel editChannelAttributes
Update the optional attributes
metadata field on a channel editChannelName
Change the name of a channel editOwnMessage
Edit their own messages in the channel editOwnMessageAttributes
Edit the own message attributes in the channel editOwnUserInfo
Edit their own User Info properties inviteMember
Invite other users to be members of a channel leaveChannel
Leave a channel removeMember
Remove members from a channel sendMediaMessage
Send media messages to channels sendMessage
Send messages to channels