# Chat User Resource

> \[!CAUTION]
>
> 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](https://www.twilio.com/en-us/changelog/programmable-chat-end-of-life-notice).
>
> If you're starting a new project, please visit the [Conversations Docs](/docs/conversations) to begin. If you've already built on Programmable Chat, please visit our [Migration Guide](/docs/conversations/migrating-chat-conversations) to learn about how to switch.

The User resource of Programmable Chat represents a single user who is identified by an
`identity` value that you provide when the User resource is created. The User resource's `identity` must be unique within its Service instance.

> \[!WARNING]
>
> Within Twilio Programmable Chat, the user `identity` is a case-sensitive value.

*We recommend following the standard URI specification and avoid the following reserved characters* `! * ' ( ) ; : @ & = + $ , / ? % # [ ]` *for values such as identity and friendly name.*

User resources are used to assign permissions, which determine what the user can and cannot do within the service.

Users can be created within a Service instance by using the client capability token or the User resource's Create action.

When Programmable Chat encounters a new Identity in a Service instance, a new User instance is created for that identity. When an Identity exists, its corresponding User record will be used the session/request for endpoints, Access Tokens, and when the REST API is used to create a Member resource.

## User Properties

The User resource contains these properties.

```json
{"type":"object","refName":"chat.v2.service.user","modelName":"chat_v2_service_user","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^US[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the User 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 User resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Service](/docs/chat/rest/service-resource) the User resource is associated with."},"attributes":{"type":"string","nullable":true,"description":"The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":30}}},"friendly_name":{"type":"string","nullable":true,"description":"The string that you assigned to describe the resource.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"role_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Role](/docs/chat/rest/role-resource) assigned to the user."},"identity":{"type":"string","nullable":true,"description":"The application-defined string that uniquely identifies the resource's User within the [Service](/docs/chat/rest/service-resource). This value is often a username or an email address, and is case-sensitive. See [access tokens](/docs/chat/create-tokens) for more info.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"is_online":{"type":"boolean","nullable":true,"description":"Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, if the User has never been online for the Service instance, even if the Service's `reachability_enabled` is `true`."},"is_notifiable":{"type":"boolean","nullable":true,"description":"Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, `true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service's `reachability_enabled` is `true`."},"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."},"joined_channels_count":{"type":"integer","default":0,"description":"The number of Channels the User is a Member of."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"The absolute URLs of the [Channel](/docs/chat/channels) and [Binding](/docs/chat/rest/binding-resource) resources related to the user."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the User resource."}}}
```

## Create a User resource

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

### Headers

```json
[{"name":"X-Twilio-Webhook-Enabled","in":"header","description":"The X-Twilio-Webhook-Enabled HTTP request header","schema":{"type":"string","enum":["true","false"],"refName":"user_enum_webhook_enabled_type","modelName":"user_enum_webhook_enabled_type"}}]
```

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to create the User resource under.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateUserRequest","required":["Identity"],"properties":{"Identity":{"type":"string","description":"The `identity` value that uniquely identifies the new resource's [User](/docs/chat/rest/user-resource) within the [Service](/docs/chat/rest/service-resource). This value is often a username or email address. See the Identity documentation for more info.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"RoleSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$","description":"The SID of the [Role](/docs/chat/rest/role-resource) to assign to the new User."},"Attributes":{"type":"string","description":"A valid JSON string that contains application-specific data.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":30}}},"FriendlyName":{"type":"string","description":"A descriptive string that you create to describe the new resource. This value is often used for display purposes.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Identity\": \"jing\",\n  \"RoleSid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Attributes\": \"{\\\"test\\\":\\\"test\\\"}\",\n  \"FriendlyName\": \"friendly_name\"\n}","meta":"","code":"{\n  \"Identity\": \"jing\",\n  \"RoleSid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Attributes\": \"{\\\"test\\\":\\\"test\\\"}\",\n  \"FriendlyName\": \"friendly_name\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"jing\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"RoleSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Attributes\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["test","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"],["\\\"","#79C0FF"],["test","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly_name\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a User resource

```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 createUser() {
  const user = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users.create({ identity: "Identity" });

  console.log(user.sid);
}

createUser();
```

```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)

user = client.chat.v2.services(
    "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).users.create(identity="Identity")

print(user.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service;
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 user = await UserResource.CreateAsync(
            identity: "Identity", pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.User;

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);
        User user = User.creator("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity").create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	chat "github.com/twilio/twilio-go/rest/chat/v2"
	"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 := &chat.CreateUserParams{}
	params.SetIdentity("Identity")

	resp, err := client.ChatV2.CreateUser("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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);

$user = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users->create(
        "Identity" // Identity
    );

print $user->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)

user = @client
       .chat
       .v2
       .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
       .users
       .create(identity: 'Identity')

puts user.sid
```

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

twilio api:chat:v2:services:users:create \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity
```

```bash
curl -X POST "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" \
--data-urlencode "Identity=Identity" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "Identity",
  "attributes": null,
  "is_online": true,
  "is_notifiable": null,
  "friendly_name": null,
  "joined_channels_count": 0,
  "date_created": "2016-03-24T21:05:19Z",
  "date_updated": "2016-03-24T21:05:19Z",
  "links": {
    "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
    "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
  },
  "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch a User resource

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

The `{Sid}` value can be either the `sid` or the `identity` of the User resource to fetch.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to fetch the User resource from.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID of the User resource to fetch. This value can be either the `sid` or the `identity` of the User resource to fetch.","schema":{"type":"string"},"required":true}]
```

Fetch a User resource

```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 fetchUser() {
  const user = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("Sid")
    .fetch();

  console.log(user.sid);
}

fetchUser();
```

```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)

user = (
    client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("Sid")
    .fetch()
)

print(user.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service;
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 user = await UserResource.FetchAsync(
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", pathSid: "Sid");

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

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

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.User;

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);
        User user = User.fetcher("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Sid").fetch();

        System.out.println(user.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.ChatV2.FetchUser("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"Sid")
	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);

$user = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("Sid")
    ->fetch();

print $user->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)

user = @client
       .chat
       .v2
       .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
       .users('Sid')
       .fetch

puts user.sid
```

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

twilio api:chat:v2:services:users:fetch \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid Sid
```

```bash
curl -X GET "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/Sid" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "Sid",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "jing",
  "attributes": null,
  "is_online": true,
  "is_notifiable": null,
  "friendly_name": null,
  "joined_channels_count": 0,
  "date_created": "2016-03-24T21:05:19Z",
  "date_updated": "2016-03-24T21:05:19Z",
  "links": {
    "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
    "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
  },
  "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Read multiple User resources

`GET https://chat.twilio.com/v2/Services/{ServiceSid}/Users`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to read the User resources from.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true}]
```

### 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 100.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":100}},{"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"}}]
```

Read multiple User resources

```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 listUser() {
  const users = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users.list({ limit: 20 });

  users.forEach((u) => console.log(u.sid));
}

listUser();
```

```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)

users = client.chat.v2.services(
    "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).users.list(limit=20)

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

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

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service;
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 users = await UserResource.ReadAsync(
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", limit: 20);

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

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

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.User;
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<User> users = User.reader("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").limit(20).read();

        for (User record : users) {
            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"
	chat "github.com/twilio/twilio-go/rest/chat/v2"
	"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 := &chat.ListUserParams{}
	params.SetLimit(20)

	resp, err := client.ChatV2.ListUser("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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);

$users = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users->read(20);

foreach ($users 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)

users = @client
        .chat
        .v2
        .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        .users
        .list(limit: 20)

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

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

twilio api:chat:v2:services:users:list \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "users"
  },
  "users": [
    {
      "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "identity": "jing",
      "attributes": null,
      "is_online": true,
      "is_notifiable": null,
      "friendly_name": null,
      "date_created": "2016-03-24T21:05:19Z",
      "date_updated": "2016-03-24T21:05:19Z",
      "joined_channels_count": 0,
      "links": {
        "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
        "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
      },
      "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ]
}
```

## Update a User resource

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

The `{Sid}` value can be either the `sid` or the `identity` of the User resource to update.

### Headers

```json
[{"name":"X-Twilio-Webhook-Enabled","in":"header","description":"The X-Twilio-Webhook-Enabled HTTP request header","schema":{"type":"string","enum":["true","false"],"refName":"user_enum_webhook_enabled_type","modelName":"user_enum_webhook_enabled_type"}}]
```

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to update the User resource in.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateUserRequest","properties":{"RoleSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RL[0-9a-fA-F]{32}$","description":"The SID of the [Role](/docs/chat/rest/role-resource) to assign to the User."},"Attributes":{"type":"string","description":"A valid JSON string that contains application-specific data.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":30}}},"FriendlyName":{"type":"string","description":"A descriptive string that you create to describe the resource. It is often used for display purposes.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"RoleSid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Attributes\": \"{\\\"test\\\":\\\"test\\\"}\",\n  \"FriendlyName\": \"friendly_name\"\n}","meta":"","code":"{\n  \"RoleSid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Attributes\": \"{\\\"test\\\":\\\"test\\\"}\",\n  \"FriendlyName\": \"friendly_name\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"RoleSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Attributes\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["test","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"],["\\\"","#79C0FF"],["test","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly_name\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a User resource

```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 updateUser() {
  const user = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("Sid")
    .update({ roleSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" });

  console.log(user.sid);
}

updateUser();
```

```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)

user = (
    client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("Sid")
    .update(role_sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
)

print(user.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service;
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 user = await UserResource.UpdateAsync(
            roleSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "Sid");

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

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

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.User;

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);
        User user = User.updater("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Sid")
                        .setRoleSid("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                        .update();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	chat "github.com/twilio/twilio-go/rest/chat/v2"
	"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 := &chat.UpdateUserParams{}
	params.SetRoleSid("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

	resp, err := client.ChatV2.UpdateUser("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"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);

$user = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("Sid")
    ->update(["roleSid" => "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]);

print $user->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)

user = @client
       .chat
       .v2
       .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
       .users('Sid')
       .update(role_sid: 'RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

puts user.sid
```

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

twilio api:chat:v2:services:users:update \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid Sid \
   --role-sid RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X POST "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/Sid" \
--data-urlencode "RoleSid=RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "Sid",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "jing",
  "attributes": null,
  "is_online": true,
  "is_notifiable": null,
  "friendly_name": null,
  "joined_channels_count": 0,
  "date_created": "2016-03-24T21:05:19Z",
  "date_updated": "2016-03-24T21:05:19Z",
  "links": {
    "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
    "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
  },
  "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete a User resource

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

The `{Sid}` value can be either the `sid` or the `identity` of the User resource to delete.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to delete the User resource from.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID of the User resource to delete. This value can be either the `sid` or the `identity` of the User resource to delete.","schema":{"type":"string"},"required":true}]
```

Delete a User resource

```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 deleteUser() {
  await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("Sid")
    .remove();
}

deleteUser();
```

```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.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").users(
    "Sid"
).delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service;
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 UserResource.DeleteAsync(
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", pathSid: "Sid");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.User;

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);
        User.deleter("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Sid").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.ChatV2.DeleteUser("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"Sid")
	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->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("Sid")
    ->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
  .chat
  .v2
  .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .users('Sid')
  .delete
```

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

twilio api:chat:v2:services:users:remove \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid Sid
```

```bash
curl -X DELETE "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/Sid" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
