Chat User Resource
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.
The User resource contains these properties.
Property nameTypePIIDescription
The unique string that we created to identify the User resource.
Pattern: ^US[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the User resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the User resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The JSON string that stores application-specific data. If attributes have not been set, {}
is returned.
The string that you assigned to describe the resource.
The SID of the Role assigned to the user.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The application-defined string that uniquely identifies the resource's User within the Service. This value is often a username or an email address, and is case-sensitive. See access tokens for more info.
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
.
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_createdstring<date-time>
date_updatedstring<date-time>
joined_channels_countinteger The number of Channels the User is a Member of.
The absolute URLs of the Channel and Binding resources related to the user.
The absolute URL of the User resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Users
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to create the User resource under.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
The identity
value that uniquely identifies the new resource's User within the Service. This value is often a username or email address. See the Identity documentation for more info.
The SID of the Role to assign to the new User.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A valid JSON string that contains application-specific data.
FriendlyNamestringOptional A descriptive string that you create to describe the new resource. This value is often used for display purposes.
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function createUser() {
_18 const user = await client.chat.v2
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .users.create({ identity: "Identity" });
_18 console.log(user.sid);
_19 "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "identity": "Identity",
_19 "is_notifiable": null,
_19 "friendly_name": null,
_19 "joined_channels_count": 0,
_19 "date_created": "2016-03-24T21:05:19Z",
_19 "date_updated": "2016-03-24T21:05:19Z",
_19 "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_19 "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_19 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to fetch the User resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User resource to fetch. This value can be either the sid
or the identity
of the User resource to fetch.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function fetchUser() {
_19 const user = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 console.log(user.sid);
_19 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "is_notifiable": null,
_19 "friendly_name": null,
_19 "joined_channels_count": 0,
_19 "date_created": "2016-03-24T21:05:19Z",
_19 "date_updated": "2016-03-24T21:05:19Z",
_19 "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_19 "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_19 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Users
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to read the User resources from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function listUser() {
_18 const users = await client.chat.v2
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .users.list({ limit: 20 });
_18 users.forEach((u) => console.log(u.sid));
_32 "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
_32 "previous_page_url": null,
_32 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
_32 "next_page_url": null,
_32 "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32 "is_notifiable": null,
_32 "friendly_name": null,
_32 "date_created": "2016-03-24T21:05:19Z",
_32 "date_updated": "2016-03-24T21:05:19Z",
_32 "joined_channels_count": 0,
_32 "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_32 "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_32 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to update the User resource in.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User resource to update. This value can be either the sid
or the identity
of the User resource to update.
Property nameTypeRequiredPIIDescription
The SID of the Role to assign to the User.
Pattern: ^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A valid JSON string that contains application-specific data.
FriendlyNamestringOptional A descriptive string that you create to describe the resource. It is often used for display purposes.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function updateUser() {
_19 const user = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .update({ roleSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" });
_19 console.log(user.sid);
_19 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "is_notifiable": null,
_19 "friendly_name": null,
_19 "joined_channels_count": 0,
_19 "date_created": "2016-03-24T21:05:19Z",
_19 "date_updated": "2016-03-24T21:05:19Z",
_19 "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_19 "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_19 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to delete the User resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User resource to delete. This value can be either the sid
or the identity
of the User resource to delete.
_17// Download the helper library from https://www.twilio.com/docs/node/install
_17const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17// Find your Account SID and Auth Token at twilio.com/console
_17// and set the environment variables. See http://twil.io/secure
_17const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17const authToken = process.env.TWILIO_AUTH_TOKEN;
_17const client = twilio(accountSid, authToken);
_17async function deleteUser() {
_17 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")