Users Resource
Danger
This is reference documentation for the v1 REST API, which has been deprecated. You should use the current v2 REST API.
The User resource of Programmable Chat represents a particular user represented by an
Identity as provided by the developer. Users exist within a single Chat
Service instance. Users need to be unique (by Identity) within a Service instance.
User records are used to assign permissions via Roles within a Service instance
and determine what the user can and cannot do within the instance.
Users can be created within a Service instance via the client capability token
or via the User resource REST API methods.
The first time a new Identity is encountered by Chat within a Service
instance, a new User instance will be created using the Identity encountered.
If the Identity exists, the existing User record will be used for that
session/request. This is true for endpoints and Access Tokens, and for creating Members
in a POST
to the Members resource.
Users can also be retrieved by either User Sid or Identity via a GET
to the Users resource.
Each user has 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 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. Note If this property has been assigned a value, it's only displayed in a FETCH action that returns a single resource; otherwise, it's null. If the 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. 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 this 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.
_10GET /Services/{Instance SID}/Users
_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.v1
_18 .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_18 .users.list({ limit: 20 });
_18 users.forEach((u) => console.log(u.sid));
_31 "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
_31 "previous_page_url": null,
_31 "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",
_31 "next_page_url": null,
_31 "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_31 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_31 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_31 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_31 "is_notifiable": null,
_31 "friendly_name": null,
_31 "date_created": "2016-03-24T21:05:19Z",
_31 "date_updated": "2016-03-24T21:05:19Z",
_31 "joined_channels_count": 0,
_31 "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
_31 "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10POST /Services/{Instance SID}/Users
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to create the 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 details.
The SID of the Role assigned 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.v1
_18 .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_18 .users.create({ identity: "IDENTITY" });
_18 console.log(user.sid);
_18 "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "identity": "IDENTITY",
_18 "is_notifiable": null,
_18 "friendly_name": null,
_18 "joined_channels_count": 0,
_18 "date_created": "2016-03-24T21:05:19Z",
_18 "date_updated": "2016-03-24T21:05:19Z",
_18 "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
_18 "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10GET /Services/{Instance SID}/Users/{Identity}
_10GET /Services/{Instance SID}/Users/{User SID}
_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.v1
_19 .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_19 .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_19 console.log(user.sid);
_18 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "is_notifiable": null,
_18 "friendly_name": null,
_18 "joined_channels_count": 0,
_18 "date_created": "2016-03-24T21:05:19Z",
_18 "date_updated": "2016-03-24T21:05:19Z",
_18 "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
_18 "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10POST /Services/{Instance SID}/Users/{User SID}
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to update the resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Twilio-provided string that uniquely identifies the User resource to update.
Property nameTypeRequiredPIIDescription
The SID of the Role assigned to this 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.v1
_19 .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_19 .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_19 .update({ roleSid: "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });
_19 console.log(user.sid);
_18 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "is_notifiable": null,
_18 "friendly_name": null,
_18 "joined_channels_count": 0,
_18 "date_created": "2016-03-24T21:05:19Z",
_18 "date_updated": "2016-03-24T21:05:19Z",
_18 "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
_18 "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10DELETE /Services/{Instance SID}/Users/{User SID}
_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("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_17 .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")