Channel Resource
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.
Property name Type PII Description
The unique string that we created to identify the Channel resource.
Pattern: ^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Channel resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Channel resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The string that you assigned to describe the resource.
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
.
Possible values: public
private
date_created string<date-time> date_updated string<date-time> 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 Members in the Channel.
The number of Messages that have been passed in the Channel.
The absolute URL of the Channel resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels
Property name Type Required PII Description
ServiceSid SID<IS> required The SID of the Service to create the Channel resource under.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property name Type Required PII Description
FriendlyName string Optional 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
.
Possible values: public
private
DateCreated string<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.
DateUpdated string<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.
The identity
of the User that created the channel. Default is: system
.
_18 // Download the helper library from https://www.twilio.com/docs/node/install
_18 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18 // Find your Account SID and Auth Token at twilio.com/console
_18 // and set the environment variables. See http://twil.io/secure
_18 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18 const authToken = process.env.TWILIO_AUTH_TOKEN;
_18 const client = twilio(accountSid, authToken);
_18 async function createChannel() {
_18 const channel = await client.chat.v2
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 console.log(channel.sid);
_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 "date_created": "2015-12-16T22:18:37Z",
_22 "date_updated": "2015-12-16T22:18:38Z",
_22 "created_by": "username",
_22 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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",
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 name Type Required PII Description
ServiceSid SID<IS> required The SID of the Service to fetch the Channel resource from.
Pattern: ^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.
_19 // Download the helper library from https://www.twilio.com/docs/node/install
_19 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19 // Find your Account SID and Auth Token at twilio.com/console
_19 // and set the environment variables. See http://twil.io/secure
_19 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19 const authToken = process.env.TWILIO_AUTH_TOKEN;
_19 const client = twilio(accountSid, authToken);
_19 async function fetchChannel() {
_19 const channel = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 console.log(channel.sid);
_22 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22 "friendly_name": "friendly_name",
_22 "unique_name": "unique_name",
_22 "attributes": "{ \"foo\": \"bar\" }",
_22 "date_created": "2015-12-16T22:18:37Z",
_22 "date_updated": "2015-12-16T22:18:37Z",
_22 "created_by": "system",
_22 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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",
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels
Property name Type Required PII Description
ServiceSid SID<IS> required The SID of the Service to read the Channel resources from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property name Type Required PII Description
Type array[enum<string>] Optional The visibility of the Channels to read. Can be: public
or private
and defaults to public
.
Possible values: public
private
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_18 // Download the helper library from https://www.twilio.com/docs/node/install
_18 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18 // Find your Account SID and Auth Token at twilio.com/console
_18 // and set the environment variables. See http://twil.io/secure
_18 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18 const authToken = process.env.TWILIO_AUTH_TOKEN;
_18 const client = twilio(accountSid, authToken);
_18 async function listChannel() {
_18 const channels = await client.chat.v2
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .channels.list({ limit: 20 });
_18 channels.forEach((c) => console.log(c.sid));
_35 "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_35 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_35 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_35 "friendly_name": "friendly_name",
_35 "unique_name": "unique_name",
_35 "attributes": "{ \"foo\": \"bar\" }",
_35 "date_created": "2015-12-16T22:18:37Z",
_35 "date_updated": "2015-12-16T22:18:37Z",
_35 "created_by": "system",
_35 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_35 "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
_35 "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
_35 "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites",
_35 "webhooks": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",
_35 "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
_35 "previous_page_url": null,
_35 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
_35 "next_page_url": null,
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 name Type Required PII Description
ServiceSid SID<IS> required The SID of the Service to update the Channel resource in.
Pattern: ^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.
Property name Type Required PII Description
FriendlyName string Optional 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.
DateCreated string<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.
DateUpdated string<date-time> Optional The identity
of the User that created the channel. Default is: system
.
_19 // Download the helper library from https://www.twilio.com/docs/node/install
_19 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19 // Find your Account SID and Auth Token at twilio.com/console
_19 // and set the environment variables. See http://twil.io/secure
_19 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19 const authToken = process.env.TWILIO_AUTH_TOKEN;
_19 const client = twilio(accountSid, authToken);
_19 async function updateChannel() {
_19 const channel = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .update({ friendlyName: "FriendlyName" });
_19 console.log(channel.sid);
_22 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22 "friendly_name": "FriendlyName",
_22 "unique_name": "unique_name",
_22 "attributes": "{ \"foo\": \"bar\" }",
_22 "date_created": "2015-12-16T22:18:37Z",
_22 "date_updated": "2015-12-16T22:18:38Z",
_22 "created_by": "username",
_22 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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",
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 name Type Required PII Description
ServiceSid SID<IS> required The SID of the Service to delete the resource from.
Pattern: ^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.
_17 // Download the helper library from https://www.twilio.com/docs/node/install
_17 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17 // Find your Account SID and Auth Token at twilio.com/console
_17 // and set the environment variables. See http://twil.io/secure
_17 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17 const authToken = process.env.TWILIO_AUTH_TOKEN;
_17 const client = twilio(accountSid, authToken);
_17 async function deleteChannel() {
_17 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")