Skip to contentSkip to navigationSkip to topbar
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.

(error)

Danger

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.(link takes you to an external page)


API Base URL

api-base-url page anchor

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


_10
https://conversations.twilio.com/v1

Using the shortened base URL

using-the-shortened-base-url page anchor

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.


_10
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.


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


Each Role resource contains these properties.

Resource properties
sidtype: SID<RL>

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


account_sidtype: SID<AC>

The SID of the Account(link takes you to an external page) that created the Role resource.


chat_service_sidtype: SID<IS>

The SID of the Conversation Service(link takes you to an external page) the Role resource is associated with.


friendly_nametype: string
PII MTL: 30 days

The string that you assigned to describe the resource.


typetype: enum<STRING>

The type of role. Can be: conversation for Conversation(link takes you to an external page) roles or service for Conversation Service(link takes you to an external page) roles.

Possible values:
conversationservice

permissionstype: string[]

An array of the permissions the role has been granted.


date_createdtype: string<DATE TIME>

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


urltype: string<URI>

An absolute API resource URL for this user role.


POST https://conversations.twilio.com/v1/Roles

Parameters

create-parameters page anchor
Request body parameters
FriendlyNametype: stringRequired

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


Typetype: enum<STRING>Required

The type of role. Can be: conversation for Conversation(link takes you to an external page) roles or service for Conversation Service(link takes you to an external page) roles.

Possible values:
conversationservice

Permissiontype: string[]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 type.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = require('twilio')(accountSid, authToken);
_14
_14
client.conversations.v1.roles
_14
.create({
_14
type: 'conversation',
_14
permission: `["addParticipant"]`,
_14
friendlyName: 'friendly_name'
_14
})
_14
.then(role => console.log(role.sid));

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "Conversation Role",
_16
"type": "conversation",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveConversation",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://conversations.twilio.com/v1/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


GET https://conversations.twilio.com/v1/Roles/{Sid}

URI parameters
Sidtype: SID<RL>
Path Parameter

The SID of the Role resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.fetch()
_10
.then(role => console.log(role.friendlyName));

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "Conversation Role",
_16
"type": "conversation",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveConversation",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://conversations.twilio.com/v1/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


Read multiple Role resources

read-multiple-role-resources page anchor
GET https://conversations.twilio.com/v1/Roles

URI parameters
PageSizetype: integer
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integer
Query Parameter

The page index. This value is simply for client state.


PageTokentype: string
Query Parameter

The page token. This is provided by the API.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.roles
_10
.list({limit: 20})
_10
.then(roles => roles.forEach(r => console.log(r.sid)));

Output

_29
{
_29
"meta": {
_29
"page": 0,
_29
"page_size": 50,
_29
"first_page_url": "https://conversations.twilio.com/v1/Roles?PageSize=50&Page=0",
_29
"previous_page_url": "https://conversations.twilio.com/v1/Roles?PageSize=50&Page=0",
_29
"url": "https://conversations.twilio.com/v1/Roles?PageSize=50&Page=0",
_29
"next_page_url": "https://conversations.twilio.com/v1/Roles?PageSize=50&Page=1",
_29
"key": "roles"
_29
},
_29
"roles": [
_29
{
_29
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"friendly_name": "Conversation Role",
_29
"type": "conversation",
_29
"permissions": [
_29
"sendMessage",
_29
"leaveConversation",
_29
"editOwnMessage",
_29
"deleteOwnMessage"
_29
],
_29
"date_created": "2016-03-03T19:47:15Z",
_29
"date_updated": "2016-03-03T19:47:15Z",
_29
"url": "https://conversations.twilio.com/v1/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_29
}
_29
]
_29
}


POST https://conversations.twilio.com/v1/Roles/{Sid}

URI parameters
Sidtype: SID<RL>
Path Parameter

The SID of the Role resource to update.


Request body parameters
Permissiontype: string[]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 type.

Update a Conversation Role

update-a-conversation-role page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.roles('<New Chat Service SID, beginning with ISXX...>')
_10
.update({permission: ['permission']})
_10
.then(role => console.log(role.friendlyName));

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "Conversation Role",
_16
"type": "conversation",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveConversation",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://conversations.twilio.com/v1/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


DELETE https://conversations.twilio.com/v1/Roles/{Sid}

URI parameters
Sidtype: SID<RL>
Path Parameter

The SID of the Role resource to delete.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();


Service-scope permissions

service-scope-permissions page anchor

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

PermissionEnables User to:
addParticipantAdd other users as Participants of a Conversation
createConversationCreate new Conversations
deleteAnyMessageDelete any Message in the Service
deleteConversationDelete Conversations
editAnyMessageEdit any Message in the Service
editAnyMessageAttributesEdit any Message attributes in the Service
editAnyUserInfoEdit other User's User Info properties
editConversationAttributesUpdate the optional attributes metadata field on a Conversation
editConversationNameChange the name of a Conversation
editOwnMessageEdit their own Messages in the Service
editOwnMessageAttributesEdit the own Message attributes in the Service
editOwnUserInfoEdit their own User Info properties
joinConversationJoin Conversations
removeParticipantRemove Participants from a Conversation

Conversation-scope permissions

conversation-scope-permissions page anchor

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

PermissionEnables User to:
addParticipantAdd other users as Participants of a Conversation
deleteAnyMessageDelete any Message in the Service
deleteOwnMessageDelete their own Messages in the Service
deleteConversationDelete Conversations
editAnyMessageEdit any Message in the Service
editAnyMessageAttributesEdit any Message attributes in the Service
editAnyUserInfoEdit other User's User Info properties
editConversationAttributesUpdate the optional attributes metadata field on a Conversation
editConversationNameChange the name of a Conversation
editOwnMessageEdit their own Messages in the Service
editOwnMessageAttributesEdit the own Message attributes in the Service
editOwnUserInfoEdit their own User Info properties
leaveConversationLeave a Conversation
removeParticipantRemove Participants from a Conversation
sendMediaMessageSend media Messages to Conversations
sendMessageSend Messages to Conversations

Rate this Page: