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.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
The 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.
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.
The unique string that we created to identify the User resource.
^US[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the User resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the User resource is associated with.
^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 SID of the Role assigned to the user.
^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
.
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The number of Channels the User is a Member of.
0
The absolute URL of the User resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Users
The X-Twilio-Webhook-Enabled HTTP request header
true
false
application/x-www-form-urlencoded
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.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A valid JSON string that contains application-specific data.
A descriptive string that you create to describe the new resource. This value is often used for display purposes.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createUser() {11const user = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users.create({ identity: "Identity" });1415console.log(user.sid);16}1718createUser();
1{2"sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"identity": "Identity",7"attributes": null,8"is_online": true,9"is_notifiable": null,10"friendly_name": null,11"joined_channels_count": 0,12"date_created": "2016-03-24T21:05:19Z",13"date_updated": "2016-03-24T21:05:19Z",14"links": {15"user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",16"user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"17},18"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
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.
The SID of the Service to fetch the User resource from.
^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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchUser() {11const user = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("Sid")14.fetch();1516console.log(user.sid);17}1819fetchUser();
1{2"sid": "Sid",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"identity": "jing",7"attributes": null,8"is_online": true,9"is_notifiable": null,10"friendly_name": null,11"joined_channels_count": 0,12"date_created": "2016-03-24T21:05:19Z",13"date_updated": "2016-03-24T21:05:19Z",14"links": {15"user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",16"user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"17},18"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Users
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listUser() {11const users = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users.list({ limit: 20 });1415users.forEach((u) => console.log(u.sid));16}1718listUser();
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",6"previous_page_url": null,7"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0",8"next_page_url": null,9"key": "users"10},11"users": [12{13"sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"identity": "jing",18"attributes": null,19"is_online": true,20"is_notifiable": null,21"friendly_name": null,22"date_created": "2016-03-24T21:05:19Z",23"date_updated": "2016-03-24T21:05:19Z",24"joined_channels_count": 0,25"links": {26"user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",27"user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"28},29"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"30}31]32}
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.
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Service to update the User resource in.
^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.
application/x-www-form-urlencoded
The SID of the Role to assign to the User.
^RL[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A valid JSON string that contains application-specific data.
A descriptive string that you create to describe the resource. It is often used for display purposes.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateUser() {11const user = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("Sid")14.update({ roleSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" });1516console.log(user.sid);17}1819updateUser();
1{2"sid": "Sid",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"identity": "jing",7"attributes": null,8"is_online": true,9"is_notifiable": null,10"friendly_name": null,11"joined_channels_count": 0,12"date_created": "2016-03-24T21:05:19Z",13"date_updated": "2016-03-24T21:05:19Z",14"links": {15"user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",16"user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"17},18"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
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.
The SID of the Service to delete the User resource from.
^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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteUser() {11await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("Sid")14.remove();15}1617deleteUser();