User Channel Resource
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.
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 Channel resource of Programmable Chat is a read-only resource that describes a Channel that the User is a Member of.
Each User Channel resource contains these properties.
The SID of the Account that created the User Channel resource.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Service the User Channel resource is associated with.
^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Channel the User Channel resource belongs to.
^CH[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the User the User Channel belongs to.
^US[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of a Member that represents the User on the Channel.
^MB[0-9a-fA-F]{32}$Min length: 34Max length: 34The status of the User on the Channel. Can be: joined, invited, or not_participating.
joinedinvitednot_participatingThe number of unread Messages in the Channel for the User. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See Consumption Horizon feature to learn how to mark messages as consumed.
The absolute URLs of the Members, Messages , Invites and, if it exists, the last Message for the Channel.
The push notification level of the User for the Channel. Can be: default or muted.
defaultmutedGET https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{UserSid}/Channels/{ChannelSid}
The {UserSid} value can be either the sid or the identity of the User resource and the {ChannelSid} value can be either the sid or the unique_name of the Channel to fetch.
The SID of the Service to fetch the User Channel resource from.
^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the User to fetch the User Channel resource from. This value can be either the sid or the identity of the User 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 fetchUserChannel() {11const userChannel = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("UserSid")14.userChannels("ChannelSid")15.fetch();1617console.log(userChannel.accountSid);18}1920fetchUserChannel();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"channel_sid": "ChannelSid",5"user_sid": "UserSid",6"member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"status": "joined",8"last_consumed_message_index": 5,9"unread_messages_count": 5,10"notification_level": "default",11"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"links": {13"channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"15}16}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{UserSid}/Channels
The {UserSid} value can be either the sid or the identity of the User resource to read User Channel resources from.
The SID of the Service to read the User Channel resources from.
^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34How many resources to return in each list page. The default is 50, and the maximum is 1000.
1Maximum: 1000The 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 listUserChannel() {11const userChannels = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("UserSid")14.userChannels.list({ limit: 20 });1516userChannels.forEach((u) => console.log(u.accountSid));17}1819listUserChannel();
Response
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",6"previous_page_url": null,7"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",8"next_page_url": null,9"key": "channels"10},11"channels": [12{13"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",18"status": "joined",19"last_consumed_message_index": 5,20"unread_messages_count": 5,21"notification_level": "default",22"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",23"links": {24"channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",25"member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"26}27}28]29}
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{UserSid}/Channels/{ChannelSid}
The NotificationLevel property expresses whether a user receives pushes for this channel or not. This can be set separately for each user/channel pair.
application/x-www-form-urlencodedThe push notification level of the User for the Channel. Can be: default or muted.
defaultmuted1// 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 updateUserChannel() {11const userChannel = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.users("UserSid")14.userChannels("ChannelSid")15.update({ notificationLevel: "muted" });1617console.log(userChannel.notificationLevel);18}1920updateUserChannel();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"channel_sid": "ChannelSid",5"user_sid": "UserSid",6"member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"status": "joined",8"last_consumed_message_index": 5,9"unread_messages_count": 5,10"notification_level": "muted",11"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"links": {13"channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"15}16}