Skip to contentSkip to navigationSkip to topbar
Rate 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.

Resource properties
sidtype: SID<CH>Not PII

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


account_sidtype: SID<AC>Not PII

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


service_sidtype: SID<IS>Not PII

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


friendly_nametype: stringPII MTL: 30 days

The string that you assigned to describe the resource.


unique_nametype: stringPII MTL: 30 days

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.


attributestype: stringPII MTL: 30 days

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


typetype: enum<STRING>Not PII

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

Possible values:
publicprivate

date_createdtype: string<DATE TIME>Not PII

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


date_updatedtype: string<DATE TIME>Not PII

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_bytype: stringPII MTL: 30 days

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


members_counttype: integerNot PII

The number of Members in the Channel.


messages_counttype: integerNot PII

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


urltype: string<URI>Not PII

The absolute URL of the Channel resource.



Create a Channel resource

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

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

The SID of the Service(link takes you to an external page) to create the Channel resource under.


X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII
Header Parameter

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

Request body parameters
FriendlyNametype: stringPII MTL: 30 days

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


UniqueNametype: stringPII MTL: 30 days

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.


Attributestype: stringPII MTL: 30 days

A valid JSON string that contains application-specific data.


Typetype: enum<STRING>Not PII

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

Possible values:
publicprivate

DateCreatedtype: string<DATE TIME>Not PII

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.


DateUpdatedtype: string<DATE TIME>Not PII

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.


CreatedBytype: stringPII MTL: 30 days

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

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

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

Output

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


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.

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

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


Sidtype: stringNot PII
Path Parameter

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

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

Output

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


Read multiple Channel resources

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

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

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


Typetype: string[]Not PII
Query Parameter

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

Possible values:
publicprivate

PageSizetype: integerNot PII
Query Parameter

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


Pagetype: integerNot PII
Query Parameter

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


PageTokentype: stringNot PII
Query Parameter

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

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

Output

_37
{
_37
"channels": [
_37
{
_37
"sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37
"friendly_name": "friendly_name",
_37
"unique_name": "unique_name",
_37
"attributes": {
_37
"foo": "bar"
_37
},
_37
"type": "public",
_37
"date_created": "2015-12-16T22:18:37Z",
_37
"date_updated": "2015-12-16T22:18:37Z",
_37
"created_by": "system",
_37
"members_count": 0,
_37
"messages_count": 0,
_37
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37
"links": {
_37
"members": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Members",
_37
"messages": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_37
"invites": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites",
_37
"webhooks": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks",
_37
"last_message": null
_37
}
_37
}
_37
],
_37
"meta": {
_37
"page": 0,
_37
"page_size": 50,
_37
"first_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_37
"previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_37
"url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=0",
_37
"next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels?PageSize=50&Page=1",
_37
"key": "channels"
_37
}
_37
}


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.

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

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


Sidtype: stringNot PII
Path Parameter

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.


X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII
Header Parameter

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

Request body parameters
FriendlyNametype: stringPII MTL: 30 days

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


UniqueNametype: stringPII MTL: 30 days

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.


Attributestype: stringPII MTL: 30 days

A valid JSON string that contains application-specific data.


DateCreatedtype: string<DATE TIME>Not PII

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.


DateUpdatedtype: string<DATE TIME>Not PII

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.


CreatedBytype: stringPII MTL: 30 days

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

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

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

Output

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


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.

URI parameters
ServiceSidtype: SID<IS>Not PII
Path Parameter

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


Sidtype: stringNot PII
Path Parameter

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.


X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII
Header Parameter

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

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


Rate this Page: