# 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](/docs/conversations/api/conversation-resource).

[Users](/docs/conversations/api/user-resource) 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](/docs/conversations/api/conversation-participant-resource) 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](#permission-values) for information about the permissions that can be assigned in each scope.

> \[!CAUTION]
>
> 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.](https://www.twilio.com/en-us/legal/privacy)

## API Base URL

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

```bash
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.

```python
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.

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

```

## Role Properties

Each Role resource contains these properties.

```json
{"type":"object","refName":"conversations.v1.role","modelName":"conversations_v1_role","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Role resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the Role resource."},"chat_service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Conversation Service](/docs/conversations/api/service-resource) the Role resource is associated with."},"friendly_name":{"type":"string","nullable":true,"description":"The string that you assigned to describe the resource.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"type":{"type":"string","enum":["conversation","service"],"description":"The type of role. Can be: `conversation` for [Conversation](/docs/conversations/api/conversation-resource) roles or `service` for [Conversation Service](/docs/conversations/api/service-resource) roles.","refName":"role_enum_role_type","modelName":"role_enum_role_type"},"permissions":{"type":"array","nullable":true,"description":"An array of the permissions the role has been granted.","items":{"type":"string"}},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"An absolute API resource URL for this user role."}}}
```

## Create a Role resource

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

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateRoleRequest","required":["FriendlyName","Type","Permission"],"properties":{"FriendlyName":{"type":"string","description":"A descriptive string that you create to describe the new resource. It can be up to 64 characters long.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"Type":{"type":"string","enum":["conversation","service"],"description":"The type of role. Can be: `conversation` for [Conversation](/docs/conversations/api/conversation-resource) roles or `service` for [Conversation Service](/docs/conversations/api/service-resource) roles.","refName":"role_enum_role_type","modelName":"role_enum_role_type"},"Permission":{"type":"array","description":"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`.","items":{"type":"string"}}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"FriendlyName\": \"Conversation Role\",\n  \"Type\": \"conversation\",\n  \"Permission\": \"sendMessage\"\n}","meta":"","code":"{\n  \"FriendlyName\": \"Conversation Role\",\n  \"Type\": \"conversation\",\n  \"Permission\": \"sendMessage\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"Conversation Role\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Type\"","#7EE787"],[":","#C9D1D9"]," ",["\"conversation\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Permission\"","#7EE787"],[":","#C9D1D9"]," ",["\"sendMessage\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a Role

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createRole() {
  const role = await client.conversations.v1.roles.create({
    friendlyName: "FriendlyName",
    permission: ["addParticipant"],
    type: "conversation",
  });

  console.log(role.sid);
}

createRole();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

role = client.conversations.v1.roles.create(
    permission=["addParticipant"],
    type="conversation",
    friendly_name="FriendlyName",
)

print(role.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var role = await RoleResource.CreateAsync(
            permission: new List<string> { "addParticipant" },
            type: RoleResource.RoleTypeEnum.Conversation,
            friendlyName: "FriendlyName");

        Console.WriteLine(role.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.Role;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Role role = Role.creator("FriendlyName", Role.RoleType.CONVERSATION, Arrays.asList("addParticipant")).create();

        System.out.println(role.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	conversations "github.com/twilio/twilio-go/rest/conversations/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &conversations.CreateRoleParams{}
	params.SetPermission([]string{
		"addParticipant",
	})
	params.SetType("conversation")
	params.SetFriendlyName("FriendlyName")

	resp, err := client.ConversationsV1.CreateRole(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$role = $twilio->conversations->v1->roles->create(
    "FriendlyName", // FriendlyName
    "conversation", // Type
    ["addParticipant"] // Permission
);

print $role->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

role = @client
       .conversations
       .v1
       .roles
       .create(
         permission: [
           'addParticipant'
         ],
         type: 'conversation',
         friendly_name: 'FriendlyName'
       )

puts role.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:roles:create \
   --permission addParticipant \
   --type conversation \
   --friendly-name FriendlyName
```

```bash
curl -X POST "https://conversations.twilio.com/v1/Roles" \
--data-urlencode "Permission=addParticipant" \
--data-urlencode "Type=conversation" \
--data-urlencode "FriendlyName=FriendlyName" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "FriendlyName",
  "type": "conversation",
  "permissions": [
    "sendMessage",
    "leaveConversation",
    "editOwnMessage",
    "deleteOwnMessage"
  ],
  "date_created": "2016-03-03T19:47:15Z",
  "date_updated": "2016-03-03T19:47:15Z",
  "url": "https://conversations.twilio.com/v1/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch a Role resource

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

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the Role resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch a Role

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchRole() {
  const role = await client.conversations.v1
    .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(role.sid);
}

fetchRole();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

role = client.conversations.v1.roles(
    "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).fetch()

print(role.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var role = await RoleResource.FetchAsync(pathSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(role.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.Role;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Role role = Role.fetcher("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

        System.out.println(role.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.ConversationsV1.FetchRole("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$role = $twilio->conversations->v1
    ->roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $role->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

role = @client
       .conversations
       .v1
       .roles('RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
       .fetch

puts role.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:roles:fetch \
   --sid RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://conversations.twilio.com/v1/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

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

## Read multiple Role resources

`GET https://conversations.twilio.com/v1/Roles`

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 50.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":50}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

List multiple Roles

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listRole() {
  const roles = await client.conversations.v1.roles.list({ limit: 20 });

  roles.forEach((r) => console.log(r.sid));
}

listRole();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

roles = client.conversations.v1.roles.list(limit=20)

for record in roles:
    print(record.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var roles = await RoleResource.ReadAsync(limit: 20);

        foreach (var record in roles) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.Role;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Role> roles = Role.reader().limit(20).read();

        for (Role record : roles) {
            System.out.println(record.getSid());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	conversations "github.com/twilio/twilio-go/rest/conversations/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &conversations.ListRoleParams{}
	params.SetLimit(20)

	resp, err := client.ConversationsV1.ListRole(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Sid != nil {
				fmt.Println(*resp[record].Sid)
			} else {
				fmt.Println(resp[record].Sid)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$roles = $twilio->conversations->v1->roles->read(20);

foreach ($roles as $record) {
    print $record->sid;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

roles = @client
        .conversations
        .v1
        .roles
        .list(limit: 20)

roles.each do |record|
   puts record.sid
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:roles:list
```

```bash
curl -X GET "https://conversations.twilio.com/v1/Roles?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

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

## Update a Role resource

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

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the Role resource to update.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateRoleRequest","required":["Permission"],"properties":{"Permission":{"type":"array","description":"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`.","items":{"type":"string"}}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Permission\": \"sendMessage\"\n}","meta":"","code":"{\n  \"Permission\": \"sendMessage\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Permission\"","#7EE787"],[":","#C9D1D9"]," ",["\"sendMessage\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a Conversation Role

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateRole() {
  const role = await client.conversations.v1
    .roles("New_Chat_Service_SID")
    .update({ permission: ["Permission"] });

  console.log(role.sid);
}

updateRole();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

role = client.conversations.v1.roles("New_Chat_Service_SID").update(
    permission=["Permission"]
)

print(role.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var role = await RoleResource.UpdateAsync(
            permission: new List<string> { "Permission" }, pathSid: "New_Chat_Service_SID");

        Console.WriteLine(role.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.Role;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Role role = Role.updater("New_Chat_Service_SID", Arrays.asList("Permission")

                                     )
                        .update();

        System.out.println(role.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	conversations "github.com/twilio/twilio-go/rest/conversations/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &conversations.UpdateRoleParams{}
	params.SetPermission([]string{
		"Permission",
	})

	resp, err := client.ConversationsV1.UpdateRole("New_Chat_Service_SID",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$role = $twilio->conversations->v1->roles("New_Chat_Service_SID")->update(
    ["Permission"] // Permission
);

print $role->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

role = @client
       .conversations
       .v1
       .roles('New_Chat_Service_SID')
       .update(permission: [
           'Permission'
         ])

puts role.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:roles:update \
   --sid New_Chat_Service_SID \
   --permission Permission
```

```bash
curl -X POST "https://conversations.twilio.com/v1/Roles/New_Chat_Service_SID" \
--data-urlencode "Permission=Permission" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "New_Chat_Service_SID",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "Conversation Role",
  "type": "conversation",
  "permissions": [
    "sendMessage",
    "leaveConversation",
    "editOwnMessage",
    "deleteOwnMessage"
  ],
  "date_created": "2016-03-03T19:47:15Z",
  "date_updated": "2016-03-03T19:47:15Z",
  "url": "https://conversations.twilio.com/v1/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete a Role resource

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

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the Role resource to delete.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$"},"required":true}]
```

Delete a Role

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function deleteRole() {
  await client.conversations.v1
    .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .remove();
}

deleteRole();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

client.conversations.v1.roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete()
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        await RoleResource.DeleteAsync(pathSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.Role;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Role.deleter("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete();
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	err := client.ConversationsV1.DeleteRole("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$twilio->conversations->v1
    ->roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->delete();
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client
  .conversations
  .v1
  .roles('RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:roles:remove \
   --sid RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://conversations.twilio.com/v1/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## 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 Participants 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                                    |
