Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
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.
The unique string that we created to identify the Role resource.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Role resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Role resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The type of role. Can be: channel
for Channel roles or deployment
for Service roles.
channel
deployment
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The absolute URL of the Role resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
application/x-www-form-urlencoded
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.
channel
deployment
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
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createRole() {11const role = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.roles.create({14friendlyName: "FriendlyName",15permission: ["Permission"],16type: "channel",17});1819console.log(role.sid);20}2122createRole();
1{2"sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "FriendlyName",6"type": "channel",7"permissions": [8"sendMessage",9"leaveChannel",10"editOwnMessage",11"deleteOwnMessage"12],13"date_created": "2016-03-03T19:47:15Z",14"date_updated": "2016-03-03T19:47:15Z",15"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
The SID of the Service to fetch the Role resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to fetch.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchRole() {11const role = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.fetch();1516console.log(role.sid);17}1819fetchRole();
1{2"sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "channel user",6"type": "channel",7"permissions": [8"sendMessage",9"leaveChannel",10"editOwnMessage",11"deleteOwnMessage"12],13"date_created": "2016-03-03T19:47:15Z",14"date_updated": "2016-03-03T19:47:15Z",15"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listRole() {11const roles = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.roles.list({ limit: 20 });1415roles.forEach((r) => console.log(r.sid));16}1718listRole();
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0",6"previous_page_url": null,7"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0",8"next_page_url": null,9"key": "roles"10},11"roles": [12{13"sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"friendly_name": "channel user",17"type": "channel",18"permissions": [19"sendMessage",20"leaveChannel",21"editOwnMessage",22"deleteOwnMessage"23],24"date_created": "2016-03-03T19:47:15Z",25"date_updated": "2016-03-03T19:47:15Z",26"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"27}28]29}
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
The SID of the Service to update the Role resource in.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to update.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
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
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateRole() {11const role = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.update({ permission: ["Permission"] });1516console.log(role.sid);17}1819updateRole();
1{2"sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "channel user",6"type": "channel",7"permissions": [8"sendMessage",9"leaveChannel",10"editOwnMessage",11"deleteOwnMessage"12],13"date_created": "2016-03-03T19:47:15Z",14"date_updated": "2016-03-03T19:47:15Z",15"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
The SID of the Service to delete the Role resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Role resource to delete.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteRole() {11await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.remove();15}1617deleteRole();
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 |