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

Users 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.

(error)

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.


Properties

properties page anchor

Each user has 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 resource is associated with.


attributestype: stringPII MTL: 30 days

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.


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


joined_channels_counttype: integerNot PII

The number of Channels this 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.



_10
GET /Services/{Instance SID}/Users

List all Users

list-all-users-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.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users
_11
.list({limit: 20})
_11
.then(users => users.forEach(u => console.log(u.sid)));

Output

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



_10
POST /Services/{Instance SID}/Users

Parameters

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

The SID of the Service(link takes you to an external page) to create the 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 details.


RoleSidtype: SID<RL>Not PII

The SID of the Role(link takes you to an external page) assigned 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.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users
_11
.create({identity: 'IDENTITY'})
_11
.then(user => console.log(user.sid));

Output

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



_10
GET /Services/{Instance SID}/Users/{Identity}


_10
GET /Services/{Instance SID}/Users/{User SID}

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.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(user => console.log(user.friendlyName));

Output

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



_10
POST /Services/{Instance SID}/Users/{User SID}

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

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


Sidtype: stringNot PII
Path Parameter

The Twilio-provided string that uniquely identifies 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) assigned to this 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.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.update({roleSid: 'RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'})
_11
.then(user => console.log(user.friendlyName));

Output

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



_10
DELETE /Services/{Instance SID}/Users/{User SID}

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.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Rate this page: