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

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.

A Channel resource of Programmable Chat represents a chat room, which is a familiar concept for what is, programmatically, a scope in which Messages can be sent and received by its members. Members can be added or invited to join channels and Channels exist within a Chat Service scope.

Channels can have an optional unique_name that can replace the Channel's {ChannelSid} in the URL. This allows a channel to be named something specific and be addressed by that name. A Channel's unique_name must be unique within its Service instance.

The User Channels resource lists all the Channels to which a specific User is a Member.


Twilio Console

twilio-console page anchor

Chat Channels are organized by their Chat service. You can view that Channels in a Chat service by using your Twilio console when logged in to the console and selecting the Chat Service from the list. Within a Chat Service, you can browse its Channels.


Each Channel resource contains these properties.

Property nameTypePIIDescription
sidSID<CH>
Not PII

The unique string that we created to identify the Channel resource.

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

account_sidSID<AC>

The SID of the Account that created the Channel resource.

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

service_sidSID<IS>

The SID of the Service the Channel resource is associated with.

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

friendly_namestring
PII MTL: 30 days

The string that you assigned to describe the resource.


unique_namestring

An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid in the URL.


attributesstring

The JSON string that stores application-specific data. If attributes have not been set, {} is returned.


typeenum<string>

The visibility of the channel. Can be: public or private.

Possible values:
publicprivate

date_createdstring<date-time>

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedstring<date-time>

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


created_bystring

The identity of the User that created the channel. If the Channel was created by using the API, the value is system.


members_countinteger

The number of Members in the Channel.


messages_countinteger

The number of Messages that have been passed in the Channel.


urlstring<uri>

The absolute URL of the Channel resource.


linksobject<uri-map>

The absolute URLs of the Members, Messages, Invites, Webhooks and, if it exists, the last Message for the Channel.


Create a Channel resource

create-a-channel-resource page anchor
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels

Headers

headers page anchor
Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to create the Channel resource under.

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

A descriptive string that you create to describe the new resource. It can be up to 64 characters long.


UniqueNamestringOptional

An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the Channel resource's sid in the URL. This value must be 64 characters or less in length and be unique within the Service.


AttributesstringOptional

A valid JSON string that contains application-specific data.


Typeenum<string>Optional

The visibility of the channel. Can be: public or private and defaults to public.

Possible values:
publicprivate

DateCreatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source.


DateUpdatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was last updated. The default value is null. Note that this parameter should only be used in cases where a Channel is being recreated from a backup/separate source and where a Message was previously updated.


CreatedBystringOptional

The identity of the User that created the channel. Default is: system.

Create a Channel resource

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const channel = await client.chat.v2
_14
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_14
.channels.create();
_14
_14
console.log(channel.sid);

Output

_22
{
_22
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"friendly_name": "friendly_name",
_22
"unique_name": "unique_name",
_22
"attributes": "{ \"foo\": \"bar\" }",
_22
"type": "public",
_22
"date_created": "2015-12-16T22:18:37Z",
_22
"date_updated": "2015-12-16T22:18:38Z",
_22
"created_by": "username",
_22
"members_count": 0,
_22
"messages_count": 0,
_22
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"links": {
_22
"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
_22
"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
_22
"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",
_22
"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",
_22
"last_message": null
_22
}
_22
}


Fetch a Channel resource

fetch-a-channel-resource page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{Sid}

When fetching a Channel resource, the {Sid} value can be either the sid or the unique_name of the Channel resource to fetch.

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to fetch the Channel resource from.

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

Sidstringrequired

The SID of the Channel resource to fetch. This value can be either the sid or the unique_name of the Channel resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
import twilio from "twilio";
_15
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = twilio(accountSid, authToken);
_15
_15
const channel = await client.chat.v2
_15
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_15
.channels("Sid")
_15
.fetch();
_15
_15
console.log(channel.sid);

Output

_22
{
_22
"sid": "Sid",
_22
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"friendly_name": "friendly_name",
_22
"unique_name": "unique_name",
_22
"attributes": "{ \"foo\": \"bar\" }",
_22
"type": "public",
_22
"date_created": "2015-12-16T22:18:37Z",
_22
"date_updated": "2015-12-16T22:18:37Z",
_22
"created_by": "system",
_22
"members_count": 0,
_22
"messages_count": 0,
_22
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"links": {
_22
"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
_22
"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
_22
"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",
_22
"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",
_22
"last_message": null
_22
}
_22
}


Read multiple Channel resources

read-multiple-channel-resources page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to read the Channel resources from.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Property nameTypeRequiredPIIDescription
Typearray[enum<string>]Optional

The visibility of the Channels to read. Can be: public or private and defaults to public.

Possible values:
publicprivate

PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Read multiple Channel resources

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const channels = await client.chat.v2
_14
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_14
.channels.list({ limit: 20 });
_14
_14
channels.forEach((c) => console.log(c.sid));

Output

_29
{
_29
"channels": [
_29
{
_29
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"friendly_name": "friendly_name",
_29
"unique_name": "unique_name",
_29
"attributes": "attributes",
_29
"type": "private",
_29
"date_created": "2009-07-06T20:30:00Z",
_29
"date_updated": "2009-07-06T20:30:00Z",
_29
"created_by": "created_by",
_29
"members_count": 655,
_29
"messages_count": 537,
_29
"url": "https://www.example.com",
_29
"links": {}
_29
}
_29
],
_29
"meta": {
_29
"first_page_url": "https://www.example.com",
_29
"key": "key",
_29
"next_page_url": "https://www.example.com",
_29
"page": 653,
_29
"page_size": 757,
_29
"previous_page_url": "https://www.example.com",
_29
"url": "https://www.example.com"
_29
}
_29
}


Update a Channel resource

update-a-channel-resource page anchor
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{Sid}

When updating a Channel resource, the {Sid} value can be either the sid or the unique_name of the Channel resource to update.

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to update the Channel resource in.

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

Sidstringrequired

The SID of the Channel resource to update. This value can be either the sid or the unique_name of the Channel resource to update.

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

A descriptive string that you create to describe the resource. It can be up to 256 characters long.


UniqueNamestringOptional

An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid in the URL. This value must be 256 characters or less in length and unique within the Service.


AttributesstringOptional

A valid JSON string that contains application-specific data.


DateCreatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source.


DateUpdatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was last updated.


CreatedBystringOptional

The identity of the User that created the channel. Default is: system.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
import twilio from "twilio";
_15
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = twilio(accountSid, authToken);
_15
_15
const channel = await client.chat.v2
_15
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_15
.channels("Sid")
_15
.update({ friendlyName: "FriendlyName" });
_15
_15
console.log(channel.sid);

Output

_22
{
_22
"sid": "Sid",
_22
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"friendly_name": "FriendlyName",
_22
"unique_name": "unique_name",
_22
"attributes": "{ \"foo\": \"bar\" }",
_22
"type": "public",
_22
"date_created": "2015-12-16T22:18:37Z",
_22
"date_updated": "2015-12-16T22:18:38Z",
_22
"created_by": "username",
_22
"members_count": 0,
_22
"messages_count": 0,
_22
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"links": {
_22
"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
_22
"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
_22
"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",
_22
"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",
_22
"last_message": null
_22
}
_22
}


Delete a Channel resource

delete-a-channel-resource page anchor
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{Sid}

When deleting a Channel resource, the {Sid} value can be either the sid or the unique_name of the Channel resource to delete.

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to delete the resource from.

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

Sidstringrequired

The SID of the Channel resource to delete. This value can be either the sid or the unique_name of the Channel resource to delete.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
import twilio from "twilio";
_13
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = twilio(accountSid, authToken);
_13
_13
await client.chat.v2
_13
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_13
.channels("Sid")
_13
.remove();


Rate this page: