Menu

Expand
Rate this page:

Role Resource

In Twilio Conversations, the Role Resource represents what a User can do within the Service and individual Conversations. Roles are scoped to either a Service or a Conversation.

Users are assigned a Role at the Service level. This determines what they can do within the chat Service instance, such as create and destroy Conversations within the Service.

Participants are assigned a Role at the Conversation level. This determines what they are able to do within a particular Conversation, such as invite Participants to be members of the Conversation, post Messages, and remove other Participants from the Conversation.

See Permission Values for information about the permissions that can be assigned in each scope.

Do not use Personally Identifiable Information (PII) for the friendlyName field.

Avoid using a person's name, home address, email, phone number, or other PII in the friendlyName field. Use some form of pseudonymized identifier, instead.

You can learn more about how we process your data in our privacy policy.

API Base URL

All URLs in the reference documentation use the following base URL:

https://conversations.twilio.com/v1

Using the shortened base URL

Using the REST API, you can interact with Role resources in the default Conversation Service instance via a "shortened" URL that does not include the Conversation Service instance SID ("ISXXX..."). If you are only using one Conversation Service (the default), you do not need to include the Conversation Service SID in your URL, e.g.

GET /v1/Roles/

For Conversations applications that build on more than one Conversation Service instance, you will need to specify the Conversation Service SID in the REST API call.

GET /v1/Services/<Service SID, ISXXX...>/Roles/

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.

chat_service_sid
sid<IS> Not PII

The SID of the Conversation 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: conversation for Conversation roles or service for Conversation 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

An absolute API resource URL for this user role.

Create a Role resource

post
https://conversations.twilio.com/v1/Roles
Parameters
Parameters in REST API format
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 ienum:role_type Not PII

The type of role. Can be: conversation for Conversation roles or service for Conversation 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

        Fetch a Role resource

        get
        https://conversations.twilio.com/v1/Roles/{Sid}
        Parameters
        Parameters in REST API format
        sid
        Path
        get sid<RL> Not PII

        The SID of the Role resource to fetch.

        Example 1
        Loading Code Sample...
              
              

              Fetch Role

              Read multiple Role resources

              get
              https://conversations.twilio.com/v1/Roles
              Example 1
              Loading Code Sample...
                    
                    

                    Read Role

                    Update a Role resource

                    post
                    https://conversations.twilio.com/v1/Roles/{Sid}
                    Parameters
                    Parameters in REST API format
                    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 Conversation Role

                          Delete a Role resource

                          delete
                          https://conversations.twilio.com/v1/Roles/{Sid}
                          Parameters
                          Parameters in REST API format
                          sid
                          Path
                          delete sid<RL> Not PII

                          The SID of the Role resource to delete.

                          Example 1
                          Loading Code Sample...
                                
                                

                                Delete Role

                                Permission Values

                                Service-scope permissions

                                These are the available permissions entries for roles where type = service.

                                Permission Enables User to:
                                addParticipant Add other users as Participants of a Conversation
                                createConversation Create new Conversations
                                deleteAnyMessage Delete any Message in the Service
                                deleteConversation Delete Conversations
                                editAnyMessage Edit any Message in the Service
                                editAnyMessageAttributes Edit any Message attributes in the Service
                                editAnyUserInfo Edit other User's User Info properties
                                editConversationAttributes Update the optional attributes metadata field on a Conversation
                                editConversationName Change the name of a Conversation
                                editOwnMessage Edit their own Messages in the Service
                                editOwnMessageAttributes Edit the own Message attributes in the Service
                                editOwnUserInfo Edit their own User Info properties
                                joinConversation Join Conversations
                                removeParticipant Remove Participants from a Conversation

                                Conversation-scope permissions

                                These are the available permissions entries for roles where type = conversation.

                                Permission Enables User to:
                                addParticipant Add other users as Particpants of a Conversation
                                deleteAnyMessage Delete any Message in the Service
                                deleteOwnMessage Delete their own Messages in the Service
                                deleteConversation Delete Conversations
                                editAnyMessage Edit any Message in the Service
                                editAnyMessageAttributes Edit any Message attributes in the Service
                                editAnyUserInfo Edit other User's User Info properties
                                editConversationAttributes Update the optional attributes metadata field on a Conversation
                                editConversationName Change the name of a Conversation
                                editOwnMessage Edit their own Messages in the Service
                                editOwnMessageAttributes Edit the own Message attributes in the Service
                                editOwnUserInfo Edit their own User Info properties
                                leaveConversation Leave a Conversation
                                removeParticipant Remove Participants from a Conversation
                                sendMediaMessage Send media Messages to Conversations
                                sendMessage Send Messages to Conversations
                                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