Role Resource
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.
Role properties
Each Role resource contains these properties.
Resource Properties in REST API format | |
---|---|
sid
|
The unique string that we created to identify the Role resource. |
account_sid
|
The SID of the Account that created the Role resource. |
service_sid
|
The SID of the Service the Role resource is associated with. |
friendly_name
|
The string that you assigned to describe the resource. |
type
|
The type of role. Can be: |
permissions
|
An array of the permissions the role has been granted. |
date_created
|
The date and time in GMT when the resource was created specified in ISO 8601 format. |
date_updated
|
The date and time in GMT when the resource was last updated specified in ISO 8601 format. |
url
|
The absolute URL of the Role resource. |
Create a Role resource
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to create the Role resource under. |
friendly_name
Required
|
A descriptive string that you create to describe the new resource. It can be up to 64 characters long. |
type
Required
|
The type of role. Can be: |
permission
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 |
Example 1
Fetch a Role resource
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to fetch the Role resource from. |
sid
Path
|
The SID of the Role resource to fetch. |
Example 1
Read multiple Role resources
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to read the Role resources from. |
Example 1
Update a Role resource
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to update the Role resource in. |
sid
Path
|
The SID of the Role resource to update. |
permission
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 |
Example 1
Delete a Role resource
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to delete the Role resource from. |
sid
Path
|
The SID of the Role resource to delete. |
Example 1
Service scope permissions
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 |
Channel scope permissions
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 |
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 by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.