Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Chat User Resource


(error)

Danger

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(link takes you to an external page).

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.

(warning)

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

user-properties page anchor

The User resource contains these properties.

Resource properties
sidtype: SID<US>Not PII

The unique string that we created to identify the User resource.


account_sidtype: SID<AC>Not PII

The SID of the Account(link takes you to an external page) that created the User resource.


service_sidtype: SID<IS>Not PII

The SID of the Service(link takes you to an external page) the User resource is associated with.


attributestype: stringPII MTL: 30 days

The JSON string that stores application-specific data. If attributes have not been set, {} is returned.


friendly_nametype: stringPII MTL: 30 days

The string that you assigned to describe the resource.


role_sidtype: SID<RL>Not PII

The SID of the Role(link takes you to an external page) assigned to the user.


identitytype: stringPII MTL: 30 days

The application-defined string that uniquely identifies the resource's User within the Service(link takes you to an external page). This value is often a username or an email address, and is case-sensitive. See access tokens(link takes you to an external page) for more info.


is_onlinetype: booleanNot PII

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_notifiabletype: booleanNot PII

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_createdtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


joined_channels_counttype: integerNot PII

The number of Channels the User is a Member of.


linkstype: object<URI MAP>Not PII

The absolute URLs of the Channel(link takes you to an external page) and Binding(link takes you to an external page) resources related to the user.


urltype: string<URI>Not PII

The absolute URL of the User resource.


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

Parameters

create-parameters page anchor
Request headers
X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to create the User resource under.


Request body parameters
Identitytype: stringPII MTL: 30 days
Required

The identity value that uniquely identifies the new resource's User(link takes you to an external page) within the Service(link takes you to an external page). This value is often a username or email address. See the Identity documentation for more info.


RoleSidtype: SID<RL>Not PII

The SID of the Role(link takes you to an external page) to assign to the new User.


Attributestype: stringPII MTL: 30 days

A valid JSON string that contains application-specific data.


FriendlyNametype: stringPII MTL: 30 days

A descriptive string that you create to describe the new resource. This value is often used for display purposes.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users
_11
.create({identity: 'identity'})
_11
.then(user => console.log(user.sid));

Output

_19
{
_19
"sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"identity": "jing",
_19
"attributes": null,
_19
"is_online": true,
_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
"links": {
_19
"user_channels": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_19
"user_bindings": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings"
_19
},
_19
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_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.

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to fetch the User resource from.


Sidtype: stringNot PII
Path Parameter

The SID of the User resource to fetch. This value can be either the sid or the identity of the User resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(user => console.log(user.friendlyName));

Output

_19
{
_19
"sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"identity": "jing",
_19
"attributes": null,
_19
"is_online": true,
_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
"links": {
_19
"user_channels": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_19
"user_bindings": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings"
_19
},
_19
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_19
}


Read multiple User resources

read-multiple-user-resources page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Users

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to read the User resources from.


PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

Read multiple User resources

read-multiple-user-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users
_11
.list({limit: 20})
_11
.then(users => users.forEach(u => console.log(u.sid)));

Output

_32
{
_32
"meta": {
_32
"page": 0,
_32
"page_size": 50,
_32
"first_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users?PageSize=50&Page=0",
_32
"previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users?PageSize=50&Page=0",
_32
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users?PageSize=50&Page=0",
_32
"next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users?PageSize=50&Page=1",
_32
"key": "users"
_32
},
_32
"users": [
_32
{
_32
"sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_32
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_32
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_32
"role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_32
"identity": "jing",
_32
"attributes": null,
_32
"is_online": true,
_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
"links": {
_32
"user_channels": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_32
"user_bindings": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings"
_32
},
_32
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_32
}
_32
]
_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.

Request headers
X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to update the User resource in.


Sidtype: stringNot PII
Path Parameter

The SID of the User resource to update. This value can be either the sid or the identity of the User resource to update.


Request body parameters
RoleSidtype: SID<RL>Not PII

The SID of the Role(link takes you to an external page) to assign to the User.


Attributestype: stringPII MTL: 30 days

A valid JSON string that contains application-specific data.


FriendlyNametype: stringPII MTL: 30 days

A descriptive string that you create to describe the resource. It is often used for display purposes.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.update({roleSid: 'RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'})
_11
.then(user => console.log(user.friendlyName));

Output

_19
{
_19
"sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
"identity": "jing",
_19
"attributes": null,
_19
"is_online": true,
_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
"links": {
_19
"user_channels": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_19
"user_bindings": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings"
_19
},
_19
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_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.

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to delete the User resource from.


Sidtype: stringNot PII
Path Parameter

The SID of the User resource to delete. This value can be either the sid or the identity of the User resource to delete.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Rate this page: