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
sid
type: SID<RL>
The unique string that we created to identify the Role resource.
friendly_name
type: string
The string that you assigned to describe the resource.
type
type: enum<string>
Possible values:
channel
deployment
permissions
type: array[string]
An array of the permissions the role has been granted.
date_created
type: string<date-time>
date_updated
type: string<date-time>
url
type: string<uri>
The absolute URL of the Role resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
URI parameters
Request body parameters
FriendlyName
type: stringRequired
A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
Type
type: enum<string>Required
Possible values:
channel
deployment
Permission
type: array[string]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
_15const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15const authToken = process.env.TWILIO_AUTH_TOKEN;
_15const client = require('twilio')(accountSid, authToken);
_15client.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
Sid
type: SID<RL>
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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.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
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_11// Download the helper library from https://www.twilio.com/docs/node/install
_11// Find your Account SID and Auth Token at twilio.com/console
_11// and set the environment variables. See http://twil.io/secure
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.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
Sid
type: SID<RL>
The SID of the Role resource to update.
Request body parameters
Permission
type: array[string]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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.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
Sid
type: SID<RL>
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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.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 |