The UserConversation resource lists the Conversations in which a particular User is an active Participant. Use this resource to:
Please note that UnreadMessageCount returns a maximum value of 1000
Each UserConversation resource contains these properties.
The unique ID of the Account responsible for this conversation.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation Service this conversation belongs to.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation for this User Conversation.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The number of unread Messages in the Conversation for the Participant.
The index of the last Message in the Conversation that the Participant has read.
The unique ID of the participant the user conversation belongs to.
^MB[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique string that identifies the User resource.
^US[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The human-readable name of this conversation, limited to 256 characters. Optional.
The current state of this User Conversation. One of inactive
, active
or closed
.
inactive
active
closed
An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
The date that this conversation was created, given in ISO 8601 format.
The date that this conversation was last updated, given in ISO 8601 format.
The Notification Level of this User Conversation. One of default
or muted
.
default
muted
An application-defined string that uniquely identifies the Conversation resource. It can be used to address the resource in place of the resource's conversation_sid
in the URL.
Contains absolute URLs to access the participant and conversation of this conversation.
GET https://conversations.twilio.com/v1/Users/{UserSid}/Conversations/{ConversationSid}
The {UserSid}
value can be either the sid
or the identity
of the User resource and the {ConversationSid}
value can be either the sid
or the unique_name
of the Conversation to fetch.
The unique SID identifier of the User resource. This value can be either the sid
or the identity
of the User resource.
The unique SID identifier of the Conversation. This value can be either the sid
or the unique_name
of the Conversation resource.
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 fetchUserConversation() {11const userConversation = await client.conversations.v112.users("USXXXXXXXXXXXXX")13.userConversations("CHXXXXXXXXXXXXX")14.fetch();1516console.log(userConversation.accountSid);17}1819fetchUserConversation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"conversation_sid": "CHXXXXXXXXXXXXX",5"unread_messages_count": 100,6"last_read_message_index": 100,7"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"user_sid": "USXXXXXXXXXXXXX",9"friendly_name": "friendly_name",10"conversation_state": "inactive",11"timers": {12"date_inactive": "2015-12-16T22:19:38Z",13"date_closed": "2015-12-16T22:28:38Z"14},15"attributes": "{}",16"date_created": "2015-07-30T20:00:00Z",17"date_updated": "2015-07-30T20:00:00Z",18"created_by": "created_by",19"notification_level": "default",20"unique_name": "unique_name",21"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"participant": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"conversation": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"25}26}
GET https://conversations.twilio.com/v1/Users/{UserSid}/Conversations
The {UserSid}
value can be either the sid
or the identity
of the User resource to read UserConversation resources from.
The unique SID identifier of the User resource. This value can be either the sid
or the identity
of the User resource.
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 listUserConversation() {11const userConversations = await client.conversations.v112.users("USXXXXXXXXXXXXX")13.userConversations.list({ limit: 20 });1415userConversations.forEach((u) => console.log(u.accountSid));16}1718listUserConversation();
1{2"conversations": [],3"meta": {4"page": 0,5"page_size": 50,6"first_page_url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0",7"previous_page_url": null,8"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0",9"next_page_url": null,10"key": "conversations"11}12}
POST https://conversations.twilio.com/v1/Users/{UserSid}/Conversations/{ConversationSid}
The unique SID identifier of the User resource. This value can be either the sid
or the identity
of the User resource.
The unique SID identifier of the Conversation. This value can be either the sid
or the unique_name
of the Conversation resource.
application/x-www-form-urlencoded
The Notification Level of this User Conversation. One of default
or muted
.
default
muted
The date of the last message read in conversation by the user, given in ISO 8601 format.
The index of the last Message in the Conversation that the Participant has read.
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 updateUserConversation() {11const userConversation = await client.conversations.v112.users("USXXXXXXXXXXXXX")13.userConversations("CHXXXXXXXXXXXXX")14.update({ notificationLevel: "default" });1516console.log(userConversation.accountSid);17}1819updateUserConversation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"conversation_sid": "CHXXXXXXXXXXXXX",5"unread_messages_count": 100,6"last_read_message_index": 100,7"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"user_sid": "USXXXXXXXXXXXXX",9"friendly_name": "friendly_name",10"conversation_state": "inactive",11"timers": {12"date_inactive": "2015-12-16T22:19:38Z",13"date_closed": "2015-12-16T22:28:38Z"14},15"attributes": "{}",16"date_created": "2015-07-30T20:00:00Z",17"date_updated": "2015-07-30T20:00:00Z",18"created_by": "created_by",19"notification_level": "default",20"unique_name": "unique_name",21"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"participant": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"conversation": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"25}26}
POST https://conversations.twilio.com/v1/Users/{UserSid}/Conversations/{ConversationSid}
The NotificationLevel
property expresses whether a user receives pushes for this conversation or not. This can be set separately for each user/conversation pair.
The unique SID identifier of the User resource. This value can be either the sid
or the identity
of the User resource.
The unique SID identifier of the Conversation. This value can be either the sid
or the unique_name
of the Conversation resource.
application/x-www-form-urlencoded
The Notification Level of this User Conversation. One of default
or muted
.
default
muted
The date of the last message read in conversation by the user, given in ISO 8601 format.
The index of the last Message in the Conversation that the Participant has read.
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 updateUserConversation() {11const userConversation = await client.conversations.v112.users("UserSid")13.userConversations("ConversationSid")14.update({ notificationLevel: "muted" });1516console.log(userConversation.notificationLevel);17}1819updateUserConversation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"conversation_sid": "ConversationSid",5"unread_messages_count": 100,6"last_read_message_index": 100,7"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"user_sid": "UserSid",9"friendly_name": "friendly_name",10"conversation_state": "inactive",11"timers": {12"date_inactive": "2015-12-16T22:19:38Z",13"date_closed": "2015-12-16T22:28:38Z"14},15"attributes": "{}",16"date_created": "2015-07-30T20:00:00Z",17"date_updated": "2015-07-30T20:00:00Z",18"created_by": "created_by",19"notification_level": "muted",20"unique_name": "unique_name",21"url": "https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"participant": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"conversation": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"25}26}
DELETE https://conversations.twilio.com/v1/Users/{UserSid}/Conversations/{ConversationSid}
The unique SID identifier of the User resource. This value can be either the sid
or the identity
of the User resource.
The unique SID identifier of the Conversation. This value can be either the sid
or the unique_name
of the Conversation resource.
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 deleteUserConversation() {11await client.conversations.v112.users("USXXXXXXXXXXXXX")13.userConversations("CHXXXXXXXXXXXXX")14.remove();15}1617deleteUserConversation();