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

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.


API Base URL

api-base-url page anchor

All URLs in the reference documentation use the following base URL:


_10
https://conversations.twilio.com/v1

Using the shortened base URL

using-the-shortened-base-url page anchor

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.


_10
GET /v1/Users/

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:


_10
GET /v1/Services/<Service SID, ISXXX...>/Users/


Property nameTypePIIDescription
sidSID<US>
Not PII

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

Pattern: ^US[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>

The SID of the Account that created the User resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

chat_service_sidSID<IS>

The SID of the Conversation Service the User resource is associated with.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34

role_sidSID<RL>

The SID of a service-level Role assigned to the user.

Pattern: ^RL[0-9a-fA-F]{32}$Min length: 34Max length: 34

identitystring
PII MTL: 30 days

The application-defined string that uniquely identifies the resource's User within the Conversation Service. This value is often a username or an email address, and is case-sensitive.


friendly_namestring

The string that you assigned to describe the resource.


attributesstring

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


is_onlineboolean

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_notifiableboolean

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_updatedstring<date-time>

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


urlstring<uri>

An absolute API resource URL for this user.


linksobject<uri-map>

Create a Conversations User

create-a-conversations-user page anchor
POST https://conversations.twilio.com/v1/Users

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
Identitystringrequired

The application-defined string that uniquely identifies the resource's User within the Conversation Service. This value is often a username or an email address, and is case-sensitive.


FriendlyNamestringOptional

The string that you assigned to describe the resource.


AttributesstringOptional

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


RoleSidSID<RL>Optional

The SID of a service-level Role to assign to the user.

Pattern: ^RL[0-9a-fA-F]{32}$Min length: 34Max length: 34

Create a User

create-a-user page anchor

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.

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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function createUser() {
_18
const user = await client.conversations.v1.users.create({
_18
identity: "RedgrenGrumbholdt",
_18
});
_18
_18
console.log(user.sid);
_18
}
_18
_18
createUser();

Output

_17
{
_17
"sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"identity": "RedgrenGrumbholdt",
_17
"friendly_name": "name",
_17
"attributes": "{ \"duty\": \"tech\" }",
_17
"is_online": true,
_17
"is_notifiable": null,
_17
"date_created": "2019-12-16T22:18:37Z",
_17
"date_updated": "2019-12-16T22:18:38Z",
_17
"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"links": {
_17
"user_conversations": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations"
_17
}
_17
}


Fetch a specific User Resource

fetch-a-specific-user-resource page anchor
GET https://conversations.twilio.com/v1/Users/{Sid}

Property nameTypeRequiredPIIDescription
Sidstringrequired

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function fetchUser() {
_16
const user = await client.conversations.v1.users("Sid").fetch();
_16
_16
console.log(user.sid);
_16
}
_16
_16
fetchUser();

Output

_17
{
_17
"sid": "Sid",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"identity": "admin",
_17
"friendly_name": "name",
_17
"attributes": "{ \"duty\": \"tech\" }",
_17
"is_online": true,
_17
"is_notifiable": null,
_17
"date_created": "2019-12-16T22:18:37Z",
_17
"date_updated": "2019-12-16T22:18:38Z",
_17
"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"links": {
_17
"user_conversations": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations"
_17
}
_17
}


Read multiple ConversationUser resources

read-multiple-conversationuser-resources page anchor
GET https://conversations.twilio.com/v1/Users

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function listUser() {
_16
const users = await client.conversations.v1.users.list({ limit: 20 });
_16
_16
users.forEach((u) => console.log(u.sid));
_16
}
_16
_16
listUser();

Output

_47
{
_47
"meta": {
_47
"page": 0,
_47
"page_size": 50,
_47
"first_page_url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=0",
_47
"previous_page_url": null,
_47
"url": "https://conversations.twilio.com/v1/Users?PageSize=50&Page=0",
_47
"next_page_url": null,
_47
"key": "users"
_47
},
_47
"users": [
_47
{
_47
"sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"identity": "admin",
_47
"friendly_name": "name",
_47
"attributes": "{ \"duty\": \"tech\" }",
_47
"is_online": true,
_47
"is_notifiable": null,
_47
"date_created": "2019-12-16T22:18:37Z",
_47
"date_updated": "2019-12-16T22:18:38Z",
_47
"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"links": {
_47
"user_conversations": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations"
_47
}
_47
},
_47
{
_47
"sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"identity": "agent0034",
_47
"friendly_name": "John from customs",
_47
"attributes": "{ \"duty\": \"agent\" }",
_47
"is_online": false,
_47
"is_notifiable": null,
_47
"date_created": "2020-03-24T20:38:21Z",
_47
"date_updated": "2020-03-24T20:38:21Z",
_47
"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"links": {
_47
"user_conversations": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations"
_47
}
_47
}
_47
]
_47
}


Update a ConversationUser resource

update-a-conversationuser-resource page anchor
POST https://conversations.twilio.com/v1/Users/{Sid}

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
Sidstringrequired

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

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

The string that you assigned to describe the resource.


AttributesstringOptional

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


RoleSidSID<RL>Optional

The SID of a service-level Role to assign to the user.

Pattern: ^RL[0-9a-fA-F]{32}$Min length: 34Max length: 34

Example for updating the friendly_name and role_sid for a user

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function updateUser() {
_19
const user = await client.conversations.v1.users("Sid").update({
_19
friendlyName: "new name",
_19
roleSid: "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_19
});
_19
_19
console.log(user.sid);
_19
}
_19
_19
updateUser();

Output

_17
{
_17
"sid": "Sid",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"identity": "admin",
_17
"friendly_name": "new name",
_17
"attributes": "{ \"duty\": \"tech\", \"team\": \"internals\" }",
_17
"is_online": true,
_17
"is_notifiable": null,
_17
"date_created": "2019-12-16T22:18:37Z",
_17
"date_updated": "2019-12-16T22:18:38Z",
_17
"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"links": {
_17
"user_conversations": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations"
_17
}
_17
}


DELETE https://conversations.twilio.com/v1/Users/{Sid}

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
Sidstringrequired

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
async function deleteUser() {
_14
await client.conversations.v1.users("Sid").remove();
_14
}
_14
_14
deleteUser();


Rate this page: