Conversations User Resource
In Conversations, Users are Participants with privileges such as the ability to edit and delete Messages.
Every Conversation Participant who connects with a Chat SDK (browser or mobile) is backed by a User. Participants over SMS or other non-chat channel, in contrast, do not have a corresponding User. Attached to the User is:
-
the Role assigned to the User
, which determines their permissions in your application
-
a JSON blob of arbitrary Attributes
, which you can use to store profile information for display in your application
-
Online/Offline status
, determined by whether the User is presently connected through a frontend SDK
-
the Identity string
, which uniquely identifies a user in each Conversation Service.
We recommend following the standard URI specification and avoid the following reserved characters ! * ' ( ) ; : @ & = + $ , / ? % # [ ]
for values such as identity and friendly name.
All URLs in the reference documentation use the following base URL:
_10https://conversations.twilio.com/v1
Using the REST API, you can interact with User resources in the default Conversation Service instance via a "shortened" URL that does not include the Conversation Service instance SID ("ISXXX..."). If you are only using one Conversation Service (the default), you do not need to include the Conversation Service SID in your URL, e.g.
For Conversations applications that build on more than one Conversation Service instance, you will need to specify the Conversation Service SID in the REST API call:
_10GET /v1/Services/<Service SID, ISXXX...>/Users/
Resource properties
sid
type: SID<US>
The unique string that we created to identify the User resource.
Pattern:
^US[0-9a-fA-F]{32}$
chat_service_sid
type: SID<IS>
friendly_name
type: string
The string that you assigned to describe the resource.
attributes
type: string
The JSON Object string that stores application-specific data. If attributes have not been set, {}
is returned.
is_online
type: boolean
Whether the User is actively connected to this Conversations Service 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 this Conversations Service, even if the Service's reachability_enabled
is true
.
is_notifiable
type: boolean
Whether the User has a potentially valid Push Notification registration (APN or GCM) for this Conversations Service. 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_created
type: string<date-time>
date_updated
type: string<date-time>
url
type: string<uri>
An absolute API resource URL for this user.
links
type: object<uri-map>
POST https://conversations.twilio.com/v1/Users
Request headers
X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
Request body parameters
Identity
type: stringRequired
FriendlyName
type: string
The string that you assigned to describe the resource.
Attributes
type: string
The JSON Object string that stores application-specific data. If attributes have not been set, {}
is returned.
Users are usually autocreated with default roles the first time the appear. To control a User's assigned Role from the moment of creation, use this resource.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.conversations.v1.users
_10 .create({identity: 'RedgrenGrumbholdt'})
_10 .then(user => console.log(user.sid));
_19 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "identity": "RedgrenGrumbholdt",
_19 "friendly_name": "name",
_19 "is_notifiable": null,
_19 "date_created": "2019-12-16T22:18:37Z",
_19 "date_updated": "2019-12-16T22:18:38Z",
_19 "url": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "user_conversations": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conversations"
GET https://conversations.twilio.com/v1/Users/{Sid}
URI parameters
Sid
type: string
The SID of the User resource to fetch. This value can be either the sid
or the identity
of the User resource to fetch.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .then(user => console.log(user.friendlyName));
_19 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "friendly_name": "name",
_19 "is_notifiable": null,
_19 "date_created": "2019-12-16T22:18:37Z",
_19 "date_updated": "2019-12-16T22:18:38Z",
_19 "url": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19 "user_conversations": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conversations"
GET https://conversations.twilio.com/v1/Users
URI parameters
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.conversations.v1.users
_10 .then(users => users.forEach(u => console.log(u.sid)));
_51 "first_page_url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=0",
_51 "previous_page_url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=0",
_51 "url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=0",
_51 "next_page_url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=1",
_51 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "friendly_name": "name",
_51 "is_notifiable": null,
_51 "date_created": "2019-12-16T22:18:37Z",
_51 "date_updated": "2019-12-16T22:18:38Z",
_51 "url": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "user_conversations": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conversations"
_51 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "identity": "agent0034",
_51 "friendly_name": "John from customs",
_51 "is_notifiable": null,
_51 "date_created": "2020-03-24T20:38:21Z",
_51 "date_updated": "2020-03-24T20:38:21Z",
_51 "url": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_51 "user_conversations": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conversations"
POST https://conversations.twilio.com/v1/Users/{Sid}
Request headers
X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
URI parameters
Sid
type: string
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
FriendlyName
type: string
The string that you assigned to describe the resource.
Attributes
type: string
The JSON Object string that stores application-specific data. If attributes have not been set, {}
is returned.
Example for updating the friendly_name and role_sid for a user
_13// Download the helper library from https://www.twilio.com/docs/node/install
_13// Find your Account SID and Auth Token at twilio.com/console
_13// and set the environment variables. See http://twil.io/secure
_13const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13const authToken = process.env.TWILIO_AUTH_TOKEN;
_13const client = require('twilio')(accountSid, authToken);
_13client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13 friendlyName: 'new name',
_13 roleSid: 'RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_13 .then(user => console.log(user.friendlyName));
_20 "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "friendly_name": "new name",
_20 "is_notifiable": null,
_20 "date_created": "2019-12-16T22:18:37Z",
_20 "date_updated": "2019-12-16T22:18:38Z",
_20 "url": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "user_conversations": "https://conversations.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conversations"
DELETE https://conversations.twilio.com/v1/Users/{Sid}
Request headers
X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
URI parameters
Sid
type: string
The SID of the User resource to delete. This value can be either the sid
or the identity
of the User resource to delete.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();