Menu

Expand
Rate this page:

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
sid<RL> Not PII

The unique string that we created to identify the Role resource.

account_sid
sid<AC> Not PII

The SID of the Account that created the Role resource.

service_sid
sid<IS> Not PII

The SID of the Service the Role resource is associated with.

friendly_name

The string that you assigned to describe the resource.

type
enum:role_type Not PII

The type of role. Can be: channel for Channel roles or deployment for Service roles.

permissions
string[] Not PII

An array of the permissions the role has been granted.

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in ISO 8601 format.

date_updated
date_time<iso8601> Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601 format.

url
url Not PII

The absolute URL of the Role resource.

Create a Role resource

post
https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
Parameters
Parameters in REST API format
service_sid
Path
post sid<IS> Not PII

The SID of the Service to create the Role resource under.

friendly_name
Required
post string PII MTL: 30 DAYS

A descriptive string that you create to describe the new resource. It can be up to 64 characters long.

type
Required
post enum:role_type Not PII

The type of role. Can be: channel for Channel roles or deployment for Service roles.

permission
Required
post string[] Not PII

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.

Example 1
Loading Code Sample...
        
        

        Create a Role resource

        Fetch a Role resource

        get
        https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
        Parameters
        Parameters in REST API format
        service_sid
        Path
        get sid<IS> Not PII

        The SID of the Service to fetch the Role resource from.

        sid
        Path
        get sid<RL> Not PII

        The SID of the Role resource to fetch.

        Example 1
        Loading Code Sample...
              
              

              Fetch a Role resource

              Read multiple Role resources

              get
              https://chat.twilio.com/v2/Services/{ServiceSid}/Roles
              Parameters
              Parameters in REST API format
              service_sid
              Path
              get sid<IS> Not PII

              The SID of the Service to read the Role resources from.

              Example 1
              Loading Code Sample...
                    
                    

                    Read multiple Role resources

                    Update a Role resource

                    post
                    https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
                    Parameters
                    Parameters in REST API format
                    service_sid
                    Path
                    post sid<IS> Not PII

                    The SID of the Service to update the Role resource in.

                    sid
                    Path
                    post sid<RL> Not PII

                    The SID of the Role resource to update.

                    permission
                    Required
                    post string[] Not PII

                    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.

                    Example 1
                    Loading Code Sample...
                          
                          

                          Update a Role resource

                          Delete a Role resource

                          delete
                          https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}
                          Parameters
                          Parameters in REST API format
                          service_sid
                          Path
                          delete sid<IS> Not PII

                          The SID of the Service to delete the Role resource from.

                          sid
                          Path
                          delete sid<RL> Not PII

                          The SID of the Role resource to delete.

                          Example 1
                          Loading Code Sample...
                                
                                

                                Delete a Role resource

                                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
                                Rate this page:

                                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.

                                Loading Code Sample...
                                      
                                      
                                      

                                      Thank you for your feedback!

                                      Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      thanks-feedback-gif