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.
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.
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.
The unique string that we created to identify the Channel resource.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Channel resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Channel resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
The JSON string that stores application-specific data. If attributes have not been set, {}
is returned.
The visibility of the channel. Can be: public
or private
.
public
private
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The identity
of the User that created the channel. If the Channel was created by using the API, the value is system
.
The number of Messages that have been passed in the Channel.
0
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels
The X-Twilio-Webhook-Enabled HTTP request header
true
false
application/x-www-form-urlencoded
A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
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.
A valid JSON string that contains application-specific data.
The visibility of the channel. Can be: public
or private
and defaults to public
.
public
private
The date, specified in ISO 8601 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.
The date, specified in ISO 8601 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.
The identity
of the User that created the channel. Default is: system
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createChannel() {11const channel = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels.create();1415console.log(channel.sid);16}1718createChannel();
1{2"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "friendly_name",6"unique_name": "unique_name",7"attributes": "{ \"foo\": \"bar\" }",8"type": "public",9"date_created": "2015-12-16T22:18:37Z",10"date_updated": "2015-12-16T22:18:38Z",11"created_by": "username",12"members_count": 0,13"messages_count": 0,14"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"links": {16"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",17"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",18"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",19"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",20"last_message": null21}22}
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.
The SID of the Service to fetch the Channel resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchChannel() {11const channel = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("Sid")14.fetch();1516console.log(channel.sid);17}1819fetchChannel();
1{2"sid": "Sid",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "friendly_name",6"unique_name": "unique_name",7"attributes": "{ \"foo\": \"bar\" }",8"type": "public",9"date_created": "2015-12-16T22:18:37Z",10"date_updated": "2015-12-16T22:18:37Z",11"created_by": "system",12"members_count": 0,13"messages_count": 0,14"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"links": {16"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",17"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",18"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",19"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",20"last_message": null21}22}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels
The visibility of the Channels to read. Can be: public
or private
and defaults to public
.
public
private
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listChannel() {11const channels = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels.list({ limit: 20 });1415channels.forEach((c) => console.log(c.sid));16}1718listChannel();
1{2"channels": [3{4"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"friendly_name": "friendly_name",8"unique_name": "unique_name",9"attributes": "{ \"foo\": \"bar\" }",10"type": "public",11"date_created": "2015-12-16T22:18:37Z",12"date_updated": "2015-12-16T22:18:37Z",13"created_by": "system",14"members_count": 0,15"messages_count": 0,16"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"links": {18"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",19"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",20"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",21"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",22"last_message": null23}24}25],26"meta": {27"page": 0,28"page_size": 50,29"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",30"previous_page_url": null,31"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",32"next_page_url": null,33"key": "channels"34}35}
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.
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Service to update the Channel resource in.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 256 characters long.
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.
A valid JSON string that contains application-specific data.
The date, specified in ISO 8601 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.
The date, specified in ISO 8601 format, to assign to the resource as the date it was last updated.
The identity
of the User that created the channel. Default is: system
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateChannel() {11const channel = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("Sid")14.update({ friendlyName: "FriendlyName" });1516console.log(channel.sid);17}1819updateChannel();
1{2"sid": "Sid",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"friendly_name": "FriendlyName",6"unique_name": "unique_name",7"attributes": "{ \"foo\": \"bar\" }",8"type": "public",9"date_created": "2015-12-16T22:18:37Z",10"date_updated": "2015-12-16T22:18:38Z",11"created_by": "username",12"members_count": 0,13"messages_count": 0,14"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"links": {16"members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",17"messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",18"invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",19"webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",20"last_message": null21}22}
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.
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Service to delete the resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteChannel() {11await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("Sid")14.remove();15}1617deleteChannel();