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.
Property nameTypePIIDescription
The unique string that we created to identify the Role resource.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Role resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Role resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The string that you assigned to describe the resource.
The type of role. Can be: channel
for Channel roles or deployment
for Service roles.
Possible values: channel
deployment
An array of the permissions the role has been granted.
date_createdstring<date-time>
date_updatedstring<date-time>
The absolute URL of the Role resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to create the Role resource under.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringrequired A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
The type of role. Can be: channel
for Channel roles or deployment
for Service roles.
Possible values: channel
deployment
Permissionarray[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
.
_22// Download the helper library from https://www.twilio.com/docs/node/install
_22const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_22// Find your Account SID and Auth Token at twilio.com/console
_22// and set the environment variables. See http://twil.io/secure
_22const accountSid = process.env.TWILIO_ACCOUNT_SID;
_22const authToken = process.env.TWILIO_AUTH_TOKEN;
_22const client = twilio(accountSid, authToken);
_22async function createRole() {
_22 const role = await client.chat.v2
_22 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_22 friendlyName: "FriendlyName",
_22 permission: ["Permission"],
_22 console.log(role.sid);
_16 "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "friendly_name": "FriendlyName",
_16 "type": "deployment",
_16 "date_created": "2016-03-03T19:47:15Z",
_16 "date_updated": "2016-03-03T19:47:15Z",
_16 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to fetch the Role resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to fetch.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function fetchRole() {
_19 const role = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 console.log(role.sid);
_16 "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to read the Role resources from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function listRole() {
_18 const roles = await client.chat.v2
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .roles.list({ limit: 20 });
_18 roles.forEach((r) => console.log(r.sid));
_29 "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0",
_29 "previous_page_url": null,
_29 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0",
_29 "next_page_url": null,
_29 "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to update the Role resource in.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to update.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
Permissionarray[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
.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function updateRole() {
_19 const role = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .update({ permission: ["Permission"] });
_19 console.log(role.sid);
_16 "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to delete the Role resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to delete.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_17// Download the helper library from https://www.twilio.com/docs/node/install
_17const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17// Find your Account SID and Auth Token at twilio.com/console
_17// and set the environment variables. See http://twil.io/secure
_17const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17const authToken = process.env.TWILIO_AUTH_TOKEN;
_17const client = twilio(accountSid, authToken);
_17async function deleteRole() {
_17 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17 .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
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 |