Skip to contentSkip to navigationSkip to topbar
Rate this Page:

Role Resource


(error)

Danger

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

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

role-properties page anchor

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.


service_sidtype: SID<IS>

The SID of the 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: channel for Channel(link takes you to an external page) roles or deployment for Service(link takes you to an external page) roles.

Possible values:
channeldeployment

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>

The absolute URL of the Role resource.


POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: SID<IS>
Path Parameter

The SID of the Service(link takes you to an external page) to create the Role resource under.


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: channel for Channel(link takes you to an external page) roles or deployment for Service(link takes you to an external page) roles.

Possible values:
channeldeployment

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

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

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "channel user",
_16
"type": "channel",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveChannel",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}

URI parameters
ServiceSidtype: SID<IS>
Path Parameter

The SID of the Service(link takes you to an external page) to fetch the Role resource from.


Sidtype: SID<RL>
Path Parameter

The SID of the Role resource to fetch.

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

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

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "channel user",
_16
"type": "channel",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveChannel",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


Read multiple Role resources

read-multiple-role-resources page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Roles

URI parameters
ServiceSidtype: SID<IS>
Path Parameter

The SID of the Service(link takes you to an external page) to read the Role resources from.


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.

Read multiple Role resources

read-multiple-role-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.roles
_11
.list({limit: 20})
_11
.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://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29
"previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=0",
_29
"next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles?PageSize=50&Page=1",
_29
"key": "roles"
_29
},
_29
"roles": [
_29
{
_29
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"friendly_name": "channel user",
_29
"type": "channel",
_29
"permissions": [
_29
"sendMessage",
_29
"leaveChannel",
_29
"editOwnMessage",
_29
"deleteOwnMessage"
_29
],
_29
"date_created": "2016-03-03T19:47:15Z",
_29
"date_updated": "2016-03-03T19:47:15Z",
_29
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_29
}
_29
]
_29
}


POST https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}

URI parameters
ServiceSidtype: SID<IS>
Path Parameter

The SID of the Service(link takes you to an external page) to update the Role resource in.


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.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.update({permission: ['permission']})
_11
.then(role => console.log(role.friendlyName));

Output

_16
{
_16
"sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"friendly_name": "channel user",
_16
"type": "channel",
_16
"permissions": [
_16
"sendMessage",
_16
"leaveChannel",
_16
"editOwnMessage",
_16
"deleteOwnMessage"
_16
],
_16
"date_created": "2016-03-03T19:47:15Z",
_16
"date_updated": "2016-03-03T19:47:15Z",
_16
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Roles/RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Roles/{Sid}

URI parameters
ServiceSidtype: SID<IS>
Path Parameter

The SID of the Service(link takes you to an external page) to delete the Role resource from.


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.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.roles('RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Service scope permissions

service-scope-permissions page anchor

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

PermissionEnables the user to:
addMemberAdd other users as members of a channel
createChannelCreate new channels
deleteAnyMessageDelete any message in the Service
destroyChannelDelete channels
editAnyMessageEdit any message in the Service
editAnyMessageAttributesEdit any message attributes in the Service
editAnyUserInfoEdit other User's User Info properties
editChannelAttributesUpdate the optional attributes metadata field on a channel
editChannelNameChange the name of a channel
editOwnMessageEdit their own messages in the Service
editOwnMessageAttributesEdit the own message attributes in the Service
editOwnUserInfoEdit their own User Info properties
inviteMemberInvite other users to be members of a channel
joinChannelJoin channels
removeMemberRemove members from a channel

Channel scope permissions

channel-scope-permissions page anchor

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

PermissionEnables the user to:
addMemberAdd other users as members of a channel
deleteAnyMessageDelete any message in the channel
deleteOwnMessageDelete their own messages in the channel
destroyChannelDelete channels
editAnyMessageEdit any message in the channel
editAnyMessageAttributesEdit any message attributes in the channel
editChannelAttributesUpdate the optional attributes metadata field on a channel
editChannelNameChange the name of a channel
editOwnMessageEdit their own messages in the channel
editOwnMessageAttributesEdit the own message attributes in the channel
editOwnUserInfoEdit their own User Info properties
inviteMemberInvite other users to be members of a channel
leaveChannelLeave a channel
removeMemberRemove members from a channel
sendMediaMessageSend media messages to channels
sendMessageSend messages to channels

Rate this Page: