# User Channel Resource

> \[!CAUTION]
>
> 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](https://www.twilio.com/en-us/changelog/programmable-chat-end-of-life-notice).
>
> If you're starting a new project, please visit the [Conversations Docs](/docs/conversations) to begin. If you've already built on Programmable Chat, please visit our [Migration Guide](/docs/conversations/migrating-chat-conversations) to learn about how to switch.

The User Channel resource of Programmable Chat is a read-only resource that describes a [Channel](/docs/chat/rest/channel-resource) that the User is a Member of.

## Channel Properties

Each User Channel resource contains these properties.

```json
{"type":"object","refName":"chat.v2.service.user.user_channel","modelName":"chat_v2_service_user_user_channel","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the User Channel resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Service](/docs/chat/rest/service-resource) the User Channel resource is associated with."},"channel_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^CH[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Channel](/docs/chat/channels) the User Channel resource belongs to."},"user_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^US[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [User](/docs/chat/rest/user-resource) the User Channel belongs to."},"member_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^MB[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of a [Member](/docs/chat/rest/member-resource) that represents the User on the Channel."},"status":{"type":"string","enum":["joined","invited","notParticipating"],"description":"The status of the User on the Channel. Can be: `joined`, `invited`, or `notParticipating`.","refName":"user_channel_enum_channel_status","modelName":"user_channel_enum_channel_status"},"last_consumed_message_index":{"type":"integer","nullable":true,"description":"The index of the last [Message](/docs/chat/rest/message-resource) in the [Channel](/docs/chat/channels) that the Member has read."},"unread_messages_count":{"type":"integer","nullable":true,"description":"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](/docs/chat/consumption-horizon) to learn how to mark messages as consumed."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"The absolute URLs of the [Members](/docs/chat/rest/member-resource), [Messages](/docs/chat/rest/message-resource) , [Invites](/docs/chat/rest/invite-resource) and, if it exists, the last [Message](/docs/chat/rest/message-resource) for the Channel."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the User Channel resource."},"notification_level":{"type":"string","enum":["default","muted"],"description":"The push notification level of the User for the Channel. Can be: `default` or `muted`.","refName":"user_channel_enum_notification_level","modelName":"user_channel_enum_notification_level"}}}
```

## Fetch a UserChannel resource

`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

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to fetch the User Channel resource from.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"UserSid","in":"path","description":"The SID of the [User](/docs/chat/rest/user-resource) to fetch the User Channel resource from. This value can be either the `sid` or the `identity` of the User resource.","schema":{"type":"string"},"required":true},{"name":"ChannelSid","in":"path","description":"The SID of the [Channel](/docs/chat/channels) that has the User Channel to fetch. This value can be either the `sid` or the `unique_name` of the Channel to fetch.","schema":{"type":"string"},"required":true}]
```

Fetch a UserChannel resource

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchUserChannel() {
  const userChannel = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .userChannels("ChannelSid")
    .fetch();

  console.log(userChannel.accountSid);
}

fetchUserChannel();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user_channel = (
    client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .user_channels("ChannelSid")
    .fetch()
)

print(user_channel.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service.User;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var userChannel = await UserChannelResource.FetchAsync(
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathUserSid: "UserSid",
            pathChannelSid: "ChannelSid");

        Console.WriteLine(userChannel.AccountSid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.user.UserChannel;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        UserChannel userChannel =
            UserChannel.fetcher("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "UserSid", "ChannelSid").fetch();

        System.out.println(userChannel.getAccountSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.ChatV2.FetchUserChannel("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"UserSid",
		"ChannelSid")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.AccountSid != nil {
			fmt.Println(*resp.AccountSid)
		} else {
			fmt.Println(resp.AccountSid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$user_channel = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("UserSid")
    ->userChannels("ChannelSid")
    ->fetch();

print $user_channel->accountSid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user_channel = @client
               .chat
               .v2
               .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .users('UserSid')
               .user_channels('ChannelSid')
               .fetch

puts user_channel.account_sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:chat:v2:services:users:channels:fetch \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --user-sid UserSid \
   --channel-sid ChannelSid
```

```bash
curl -X GET "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/UserSid/Channels/ChannelSid" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "channel_sid": "ChannelSid",
  "user_sid": "UserSid",
  "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "joined",
  "last_consumed_message_index": 5,
  "unread_messages_count": 5,
  "notification_level": "default",
  "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
```

## Read multiple UserChannel resources

`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.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to read the User Channel resources from.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"UserSid","in":"path","description":"The SID of the [User](/docs/chat/rest/user-resource) to read the User Channel resources from. This value can be either the `sid` or the `identity` of the User resource.","schema":{"type":"string"},"required":true}]
```

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 50.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":50}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

Read multiple UserChannel resources

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listUserChannel() {
  const userChannels = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .userChannels.list({ limit: 20 });

  userChannels.forEach((u) => console.log(u.accountSid));
}

listUserChannel();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user_channels = (
    client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .user_channels.list(limit=20)
)

for record in user_channels:
    print(record.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service.User;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var userChannels = await UserChannelResource.ReadAsync(
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathUserSid: "UserSid",
            limit: 20);

        foreach (var record in userChannels) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.user.UserChannel;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<UserChannel> userChannels =
            UserChannel.reader("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "UserSid").limit(20).read();

        for (UserChannel record : userChannels) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	chat "github.com/twilio/twilio-go/rest/chat/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &chat.ListUserChannelParams{}
	params.SetLimit(20)

	resp, err := client.ChatV2.ListUserChannel("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"UserSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].AccountSid != nil {
				fmt.Println(*resp[record].AccountSid)
			} else {
				fmt.Println(resp[record].AccountSid)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$userChannels = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("UserSid")
    ->userChannels->read(20);

foreach ($userChannels as $record) {
    print $record->accountSid;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user_channels = @client
                .chat
                .v2
                .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                .users('UserSid')
                .user_channels
                .list(limit: 20)

user_channels.each do |record|
   puts record.account_sid
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:chat:v2:services:users:channels:list \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --user-sid UserSid
```

```bash
curl -X GET "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/UserSid/Channels?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "channels"
  },
  "channels": [
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "status": "joined",
      "last_consumed_message_index": 5,
      "unread_messages_count": 5,
      "notification_level": "default",
      "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "links": {
        "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
      }
    }
  ]
}
```

## Set the NotificationLevel

`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.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/chat/rest/service-resource) to update the User Channel resource in.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true},{"name":"UserSid","in":"path","description":"The SID of the [User](/docs/chat/rest/user-resource) to update the User Channel resource from. This value can be either the `sid` or the `identity` of the User resource.","schema":{"type":"string"},"required":true},{"name":"ChannelSid","in":"path","description":"The SID of the [Channel](/docs/chat/channels) with the User Channel resource to update. This value can be the Channel resource's `sid` or `unique_name`.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateUserChannelRequest","properties":{"NotificationLevel":{"type":"string","enum":["default","muted"],"description":"The push notification level of the User for the Channel. Can be: `default` or `muted`.","refName":"user_channel_enum_notification_level","modelName":"user_channel_enum_notification_level"},"LastConsumedMessageIndex":{"type":"integer","nullable":true,"description":"The index of the last [Message](/docs/chat/rest/message-resource) in the [Channel](/docs/chat/channels) that the Member has read."},"LastConsumptionTimestamp":{"type":"string","format":"date-time","description":"The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](/docs/chat/rest/message-resource) read event for the Member within the [Channel](/docs/chat/channels)."}}},"examples":{"updateNotificationLevel":{"value":{"lang":"json","value":"{\n  \"NotificationLevel\": \"muted\"\n}","meta":"","code":"{\n  \"NotificationLevel\": \"muted\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"NotificationLevel\"","#7EE787"],[":","#C9D1D9"]," ",["\"muted\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"updateLastConsumedMessageIndex":{"value":{"lang":"json","value":"{\n  \"LastConsumedMessageIndex\": 10\n}","meta":"","code":"{\n  \"LastConsumedMessageIndex\": 10\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"LastConsumedMessageIndex\"","#7EE787"],[":","#C9D1D9"]," ",["10","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Mute Notifications for a Channel

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateUserChannel() {
  const userChannel = await client.chat.v2
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .userChannels("ChannelSid")
    .update({ notificationLevel: "muted" });

  console.log(userChannel.notificationLevel);
}

updateUserChannel();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user_channel = (
    client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .users("UserSid")
    .user_channels("ChannelSid")
    .update(notification_level="muted")
)

print(user_channel.notification_level)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Chat.V2.Service.User;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var userChannel = await UserChannelResource.UpdateAsync(
            notificationLevel: UserChannelResource.NotificationLevelEnum.Muted,
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathUserSid: "UserSid",
            pathChannelSid: "ChannelSid");

        Console.WriteLine(userChannel.NotificationLevel);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.user.UserChannel;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        UserChannel userChannel = UserChannel.updater("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "UserSid", "ChannelSid")
                                      .setNotificationLevel(UserChannel.NotificationLevel.MUTED)
                                      .update();

        System.out.println(userChannel.getNotificationLevel());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	chat "github.com/twilio/twilio-go/rest/chat/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &chat.UpdateUserChannelParams{}
	params.SetNotificationLevel("muted")

	resp, err := client.ChatV2.UpdateUserChannel("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"UserSid",
		"ChannelSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.NotificationLevel != nil {
			fmt.Println(resp.NotificationLevel)
		} else {
			fmt.Println(resp.NotificationLevel)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$user_channel = $twilio->chat->v2
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->users("UserSid")
    ->userChannels("ChannelSid")
    ->update(["notificationLevel" => "muted"]);

print $user_channel->notificationLevel;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user_channel = @client
               .chat
               .v2
               .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .users('UserSid')
               .user_channels('ChannelSid')
               .update(notification_level: 'muted')

puts user_channel.notification_level
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:chat:v2:services:users:channels:update \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --user-sid UserSid \
   --channel-sid ChannelSid \
   --notification-level muted
```

```bash
curl -X POST "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/UserSid/Channels/ChannelSid" \
--data-urlencode "NotificationLevel=muted" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "channel_sid": "ChannelSid",
  "user_sid": "UserSid",
  "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "joined",
  "last_consumed_message_index": 5,
  "unread_messages_count": 5,
  "notification_level": "muted",
  "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
```
