# Flex Chat Channel Resource

> \[!NOTE]
>
> This guide is for Flex UI 1.x.x and channels that use Programmable Chat and Proxy. Programmable Chat for Flex will reach end of life on June 1, 2026. If you're new to Flex or currently using Programmable Chat, [build with Flex Conversations](/docs/flex/conversations) or [migrate](/docs/flex/developer/conversations/programmable-chat-to-flex-conversations).

Flex Chat Channels allow agents to communicate with your customers across multiple channels like Webchat, SMS, and WhatsApp through a single chat interface. You can create a chat channel in Flex whenever you want to initiate a new communication flow between an agent and a customer. The Flex Chat Channel is an implementation of the [Chat Channel Resource](/docs/chat/rest/channel-resource) orchestrated for Flex.

## Channel Properties

```json
{"type":"object","refName":"flex.v1.channel","modelName":"flex_v1_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 Channel resource and owns this Workflow."},"flex_flow_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^FO[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Flex Flow."},"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^CH[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Channel resource."},"user_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^US[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the chat user."},"task_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^WT[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external`"},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Flex chat channel resource."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Flex chat channel was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Flex chat channel was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."}}}
```

## Create a Channel resource

`POST https://flex-api.twilio.com/v1/Channels`

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateChannelRequest","required":["FlexFlowSid","Identity","ChatUserFriendlyName","ChatFriendlyName"],"properties":{"FlexFlowSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^FO[0-9a-fA-F]{32}$","description":"The SID of the Flex Flow."},"Identity":{"type":"string","description":"The `identity` value that uniquely identifies the new resource's chat User."},"ChatUserFriendlyName":{"type":"string","description":"The chat participant's friendly name."},"ChatFriendlyName":{"type":"string","description":"The chat channel's friendly name."},"Target":{"type":"string","description":"The Target Contact Identity, for example the phone number of an SMS."},"ChatUniqueName":{"type":"string","description":"The chat channel's unique name."},"PreEngagementData":{"type":"string","description":"The pre-engagement data."},"TaskSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^WT[0-9a-fA-F]{32}$","description":"The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external`"},"TaskAttributes":{"type":"string","description":"The Task attributes to be added for the TaskRouter Task."},"LongLived":{"type":"boolean","description":"Whether to create the channel as long-lived."}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"FlexFlowSid\": \"FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Target\": \"def\",\n  \"Identity\": \"abc\",\n  \"ChatUserFriendlyName\": \"friendly2\",\n  \"ChatFriendlyName\": \"friendly1\",\n  \"ChatUniqueName\": \"unique\",\n  \"PreEngagementData\": \"{}\",\n  \"TaskSid\": \"WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"TaskAttributes\": \"{}\",\n  \"LongLived\": true\n}","meta":"","code":"{\n  \"FlexFlowSid\": \"FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Target\": \"def\",\n  \"Identity\": \"abc\",\n  \"ChatUserFriendlyName\": \"friendly2\",\n  \"ChatFriendlyName\": \"friendly1\",\n  \"ChatUniqueName\": \"unique\",\n  \"PreEngagementData\": \"{}\",\n  \"TaskSid\": \"WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"TaskAttributes\": \"{}\",\n  \"LongLived\": true\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FlexFlowSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Target\"","#7EE787"],[":","#C9D1D9"]," ",["\"def\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"abc\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ChatUserFriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly2\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ChatFriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly1\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ChatUniqueName\"","#7EE787"],[":","#C9D1D9"]," ",["\"unique\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"PreEngagementData\"","#7EE787"],[":","#C9D1D9"]," ",["\"{}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"TaskSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"TaskAttributes\"","#7EE787"],[":","#C9D1D9"]," ",["\"{}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"LongLived\"","#7EE787"],[":","#C9D1D9"]," ",["true","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create 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 createChannel() {
  const channel = await client.flexApi.v1.channel.create({
    chatFriendlyName: "ChatFriendlyName",
    chatUserFriendlyName: "ChatUserFriendlyName",
    flexFlowSid: "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    identity: "Identity",
  });

  console.log(channel.accountSid);
}

createChannel();
```

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

channel = client.flex_api.v1.channel.create(
    flex_flow_sid="FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    identity="Identity",
    chat_user_friendly_name="ChatUserFriendlyName",
    chat_friendly_name="ChatFriendlyName",
)

print(channel.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.FlexApi.V1;
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 channel = await ChannelResource.CreateAsync(
            flexFlowSid: "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            identity: "Identity",
            chatUserFriendlyName: "ChatUserFriendlyName",
            chatFriendlyName: "ChatFriendlyName");

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

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

import com.twilio.Twilio;
import com.twilio.rest.flexapi.v1.Channel;

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);
        Channel channel =
            Channel
                .creator("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", "ChatUserFriendlyName", "ChatFriendlyName")
                .create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	flex "github.com/twilio/twilio-go/rest/flex/v1"
	"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 := &flex.CreateChannelParams{}
	params.SetFlexFlowSid("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	params.SetIdentity("Identity")
	params.SetChatUserFriendlyName("ChatUserFriendlyName")
	params.SetChatFriendlyName("ChatFriendlyName")

	resp, err := client.FlexV1.CreateChannel(params)
	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);

$channel = $twilio->flexApi->v1->channel->create(
    "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", // FlexFlowSid
    "Identity", // Identity
    "ChatUserFriendlyName", // ChatUserFriendlyName
    "ChatFriendlyName" // ChatFriendlyName
);

print $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)

channel = @client
          .flex_api
          .v1
          .channel
          .create(
            flex_flow_sid: 'FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            identity: 'Identity',
            chat_user_friendly_name: 'ChatUserFriendlyName',
            chat_friendly_name: 'ChatFriendlyName'
          )

puts channel.account_sid
```

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

twilio api:flex:v1:channels:create \
   --flex-flow-sid FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity \
   --chat-user-friendly-name ChatUserFriendlyName \
   --chat-friendly-name ChatFriendlyName
```

```bash
curl -X POST "https://flex-api.twilio.com/v1/Channels" \
--data-urlencode "FlexFlowSid=FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--data-urlencode "Identity=Identity" \
--data-urlencode "ChatUserFriendlyName=ChatUserFriendlyName" \
--data-urlencode "ChatFriendlyName=ChatFriendlyName" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-08-01T22:10:40Z",
  "date_updated": "2016-08-01T22:10:40Z",
  "url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch a Channel resource

`GET https://flex-api.twilio.com/v1/Channels/{Sid}`

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the Flex chat channel resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^CH[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch 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 fetchChannel() {
  const channel = await client.flexApi.v1
    .channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(channel.accountSid);
}

fetchChannel();
```

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

channel = client.flex_api.v1.channel(
    "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).fetch()

print(channel.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.FlexApi.V1;
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 channel =
            await ChannelResource.FetchAsync(pathSid: "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.flexapi.v1.Channel;

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);
        Channel channel = Channel.fetcher("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

        System.out.println(channel.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.FlexV1.FetchChannel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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);

$channel = $twilio->flexApi->v1
    ->channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $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)

channel = @client
          .flex_api
          .v1
          .channel('CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
          .fetch

puts channel.account_sid
```

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

twilio api:flex:v1:channels:fetch \
   --sid CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-08-01T22:10:40Z",
  "date_updated": "2016-08-01T22:10:40Z",
  "url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Read multiple Channel resources

`GET https://flex-api.twilio.com/v1/Channels`

### 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 1000.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":1000}},{"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"}}]
```

List multiple Channels

```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 listChannel() {
  const channels = await client.flexApi.v1.channel.list({ limit: 20 });

  channels.forEach((c) => console.log(c.accountSid));
}

listChannel();
```

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

channels = client.flex_api.v1.channel.list(limit=20)

for record in 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.FlexApi.V1;
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 channels = await ChannelResource.ReadAsync(limit: 20);

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

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

import com.twilio.Twilio;
import com.twilio.rest.flexapi.v1.Channel;
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<Channel> channels = Channel.reader().limit(20).read();

        for (Channel record : channels) {
            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"
	flex "github.com/twilio/twilio-go/rest/flex/v1"
	"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 := &flex.ListChannelParams{}
	params.SetLimit(20)

	resp, err := client.FlexV1.ListChannel(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);

$channels = $twilio->flexApi->v1->channel->read(20);

foreach ($channels 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)

channels = @client
           .flex_api
           .v1
           .channel
           .list(limit: 20)

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

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

twilio api:flex:v1:channels:list
```

```bash
curl -X GET "https://flex-api.twilio.com/v1/Channels?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "flex_chat_channels"
  },
  "flex_chat_channels": [
    {
      "flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "date_created": "2016-08-01T22:10:40Z",
      "date_updated": "2016-08-01T22:10:40Z",
      "url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ]
}
```

## Delete a Channel resource

`DELETE https://flex-api.twilio.com/v1/Channels/{Sid}`

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the Flex chat channel resource to delete.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^CH[0-9a-fA-F]{32}$"},"required":true}]
```

Delete 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 deleteChannel() {
  await client.flexApi.v1
    .channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .remove();
}

deleteChannel();
```

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

client.flex_api.v1.channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete()
```

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

using System;
using Twilio;
using Twilio.Rest.FlexApi.V1;
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);

        await ChannelResource.DeleteAsync(pathSid: "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.flexapi.v1.Channel;

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);
        Channel.deleter("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete();
    }
}
```

```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()

	err := client.FlexV1.DeleteChannel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```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);

$twilio->flexApi->v1->channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")->delete();
```

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

@client
  .flex_api
  .v1
  .channel('CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:flex:v1:channels:remove \
   --sid CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
