User Channel Resource
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.
Property nameTypePIIDescription
The SID of the Account that created the User Channel resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the User Channel resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the User Channel resource belongs to.
Pattern: ^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User the User Channel belongs to.
Pattern: ^US[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of a Member that represents the User on the Channel.
Pattern: ^MB[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The status of the User on the Channel. Can be: joined
, invited
, or not_participating
.
Possible values: joined
invited
not_participating
last_consumed_message_indexinteger The index of the last Message in the Channel that the Member has read.
unread_messages_countinteger The 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 URL of the User Channel resource.
notification_levelenum<string> The push notification level of the User for the Channel. Can be: default
or muted
.
Possible values: default
muted
GET 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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to fetch the User Channel resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The 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.
The SID of the Channel that has the User Channel to fetch. This value can be either the sid
or the unique_name
of the Channel to fetch.
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function fetchUserChannel() {
_20 const userChannel = await client.chat.v2
_20 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .userChannels("ChannelSid")
_20 console.log(userChannel.accountSid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "channel_sid": "ChannelSid",
_16 "user_sid": "UserSid",
_16 "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "last_consumed_message_index": 5,
_16 "unread_messages_count": 5,
_16 "notification_level": "default",
_16 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to read the User Channel resources from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User to read the User Channel resources from. This value can be either the sid
or the identity
of the User resource.
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function listUserChannel() {
_19 const userChannels = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .userChannels.list({ limit: 20 });
_19 userChannels.forEach((u) => console.log(u.accountSid));
_29 "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
_29 "previous_page_url": null,
_29 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
_29 "next_page_url": null,
_29 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "last_consumed_message_index": 5,
_29 "unread_messages_count": 5,
_29 "notification_level": "default",
_29 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29 "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service to update the User Channel resource in.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the User to update the User Channel resource from. This value can be either the sid
or the identity
of the User resource.
The SID of the Channel with the User Channel resource to update. This value can be the Channel resource's sid
or unique_name
.
Property nameTypeRequiredPIIDescription
NotificationLevelenum<string>Optional The push notification level to assign to the User Channel. Can be: default
or muted
.
Possible values: default
muted
LastConsumedMessageIndexintegerOptional The index of the last Message in the Channel that the Member has read.
LastConsumptionTimestampstring<date-time>Optional
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function updateUserChannel() {
_20 const userChannel = await client.chat.v2
_20 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .userChannels("ChannelSid")
_20 .update({ notificationLevel: "muted" });
_20 console.log(userChannel.notificationLevel);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "channel_sid": "ChannelSid",
_16 "user_sid": "UserSid",
_16 "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "last_consumed_message_index": 5,
_16 "unread_messages_count": 5,
_16 "notification_level": "muted",
_16 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"