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

User Channel Resource


(error)

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(link takes you to an external page).

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.


UserChannel Properties

userchannel-properties page anchor

Each User Channel resource contains these properties.

account_sidSID<AC>
Not PII

The SID of the Account(link takes you to an external page) that created the User Channel resource.

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

service_sidSID<IS>

The SID of the Service(link takes you to an external page) the User Channel resource is associated with.

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

channel_sidSID<CH>

The SID of the Channel(link takes you to an external page) the User Channel resource belongs to.

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

user_sidSID<US>

The SID of the User(link takes you to an external page) the User Channel belongs to.

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

member_sidSID<MB>

The SID of a Member(link takes you to an external page) that represents the User on the Channel.

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

statusenum<string>

The status of the User on the Channel. Can be: joined, invited, or not_participating.

Possible values:
joinedinvitednot_participating

last_consumed_message_indexinteger

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(link takes you to an external page) to learn how to mark messages as consumed.


urlstring<uri>

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:
defaultmuted

Fetch a UserChannel resource

fetch-a-userchannel-resource page anchor
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.

Path parameters

path-parameters page anchor
ServiceSidSID<IS>required

The SID of the Service(link takes you to an external page) to fetch the User Channel resource from.

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

UserSidstringrequired

The SID of the User(link takes you to an external page) to fetch the User Channel resource from. This value can be either the sid or the identity of the User resource.


ChannelSidstringrequired

The SID of the Channel(link takes you to an external page) that has the User Channel to fetch. This value can be either the sid or the unique_name of the Channel to fetch.

Fetch a UserChannel resource

fetch-a-userchannel-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.userChannels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.fetch()
_12
.then(user_channel => console.log(user_channel.serviceSid));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"user_sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"member_sid": "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"status": "joined",
_16
"last_consumed_message_index": 5,
_16
"unread_messages_count": 5,
_16
"notification_level": "default",
_16
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"links": {
_16
"channel": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"member": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Members/MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}
_16
}


Read multiple UserChannel resources

read-multiple-userchannel-resources page anchor
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.

ServiceSidSID<IS>required

The SID of the Service(link takes you to an external page) to read the User Channel resources from.

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

UserSidstringrequired

The SID of the User(link takes you to an external page) to read the User Channel resources from. This value can be either the sid or the identity of the User resource.

PageSizeinteger

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

Minimum: 1Maximum: 1000

Pageinteger

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

Minimum: 0

PageTokenstring

The page token. This is provided by the API.

Read multiple UserChannel resources

read-multiple-userchannel-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.userChannels
_12
.list({limit: 20})
_12
.then(userChannels => userChannels.forEach(u => console.log(u.serviceSid)));

Output

_29
{
_29
"meta": {
_29
"page": 0,
_29
"page_size": 50,
_29
"first_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_29
"previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_29
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_29
"next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=1",
_29
"key": "channels"
_29
},
_29
"channels": [
_29
{
_29
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"user_sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"member_sid": "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"status": "joined",
_29
"last_consumed_message_index": 5,
_29
"unread_messages_count": 5,
_29
"notification_level": "default",
_29
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"links": {
_29
"channel": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"member": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Members/MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_29
}
_29
}
_29
]
_29
}


Set the NotificationLevel

set-the-notificationlevel page anchor
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.

ServiceSidSID<IS>required

The SID of the Service(link takes you to an external page) to update the User Channel resource in.

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

UserSidstringrequired

The SID of the User(link takes you to an external page) to update the User Channel resource from. This value can be either the sid or the identity of the User resource.


ChannelSidstringrequired

The SID of the Channel(link takes you to an external page) with the User Channel resource to update. This value can be the Channel resource's sid or unique_name.

NotificationLevelenum<string>

The push notification level to assign to the User Channel. Can be: default or muted.

Possible values:
defaultmuted

LastConsumedMessageIndexinteger

LastConsumptionTimestampstring<date-time>

Mute Notifications for a Channel

mute-notifications-for-a-channel page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.userChannels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.update({notificationLevel: 'muted'})
_12
.then(user_channel => console.log(user_channel.notificationLevel));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"user_sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"member_sid": "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"status": "joined",
_16
"last_consumed_message_index": 5,
_16
"unread_messages_count": 5,
_16
"notification_level": "muted",
_16
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"links": {
_16
"channel": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"member": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Members/MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}
_16
}


Rate this page: