Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

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.

Role properties

Each Role resource contains these properties.

Names in PHP format
sid
sid<RL> Not PII

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

accountSid
sid<AC> Not PII

The SID of the Account that created the Role resource.

serviceSid
sid<IS> Not PII

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

friendlyName

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.

dateCreated
date_time<iso8601> Not PII

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

dateUpdated
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
Names in None format
service_sid
Required
post sid<IS> Not PII

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

friendly_name
Required
post string PII MTL: 120 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
        
        
        
        

        Fetch a Role resource

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

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

        sid
        Required
        get sid<RL> Not PII

        The SID of the Role resource to fetch.

        Example 1
              
              
              
              

              Read multiple Role resources

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

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

              Example 1
                    
                    
                    
                    

                    Update a Role resource

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

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

                    sid
                    Required
                    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
                          
                          
                          
                          

                          Delete a Role resource

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

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

                          sid
                          Required
                          delete sid<RL> Not PII

                          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 Service
                                deleteOwnMessage Delete their own messages 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
                                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 browsing the Twilio tag on Stack Overflow.