Channel Webhook Resource
A Channel Webhook resource describes a webhook target that is specific to a Channel. By default, events in a Programmable Chat instance are delivered to a webhook address that is specified for the whole Chat Service. However, you can use this resource to specify up to five unique webhook targets for each channel to handle exceptional cases.
The webhook target can be a Web URL or a Studio Flow.
Property nameTypePIIDescription
The unique string that we created to identify the Channel Webhook resource.
Pattern: ^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Channel Webhook resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Channel Webhook resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource belongs to.
Pattern: ^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The type of webhook. Can be: webhook
, studio
, or trigger
.
The absolute URL of the Channel Webhook resource.
The JSON string that describes how the channel webhook is configured. The configuration object contains the url
, method
, filters
, and retry_count
values that are configured by the create and update actions.
date_createdstring<date-time>
date_updatedstring<date-time>
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service with the Channel to create the Webhook resource under.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the new Channel Webhook resource belongs to. This value can be the Channel resource's sid
or unique_name
.
Property nameTypeRequiredPIIDescription
The type of webhook. Can be: webhook
, studio
, or trigger
.
Possible values: webhook
trigger
studio
Configuration.UrlstringOptional The URL of the webhook to call using the configuration.method
.
Configuration.Methodenum<string>Optional The HTTP method used to call configuration.url
. Can be: GET
or POST
and the default is POST
.
Configuration.Filtersarray[string]Optional The events that cause us to call the Channel Webhook. Used when type
is webhook
. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see Webhook Event Triggers.
Configuration.Triggersarray[string]Optional A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when type
= trigger
.
Configuration.FlowSidSID<FW>Optional The SID of the Studio Flow to call when an event in configuration.filters
occurs. Used only when type
is studio
.
Pattern: ^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Configuration.RetryCountintegerOptional The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const 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
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function createChannelWebhook() {
_19 const webhook = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .channels("ChannelSid")
_19 .webhooks.create({ type: "studio" });
_19 console.log(webhook.sid);
_19createChannelWebhook();
_19 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "channel_sid": "ChannelSid",
_19 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "date_created": "2016-03-24T21:05:50Z",
_19 "date_updated": "2016-03-24T21:05:50Z",
_19 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service with the Channel to fetch the Webhook resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to fetch belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to fetch.
Pattern: ^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function fetchChannelWebhook() {
_20 const webhook = await client.chat.v2
_20 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .channels("ChannelSid")
_20 .webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 console.log(webhook.sid);
_20fetchChannelWebhook();
_13 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "channel_sid": "ChannelSid",
_13 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_13 "date_created": "2016-03-24T21:05:50Z",
_13 "date_updated": "2016-03-24T21:05:50Z",
_13 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service with the Channel to read the resources from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resources to read belong to. This value can be the Channel resource's sid
or unique_name
.
Property nameTypeRequiredPIIDescription
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.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const 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
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function listChannelWebhook() {
_19 const webhooks = await client.chat.v2
_19 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .channels("ChannelSid")
_19 .webhooks.list({ limit: 20 });
_19 webhooks.forEach((w) => console.log(w.sid));
_64 "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
_64 "previous_page_url": null,
_64 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
_64 "next_page_url": null,
_64 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "date_created": "2016-03-24T21:05:50Z",
_64 "date_updated": "2016-03-24T21:05:50Z",
_64 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_64 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "date_created": "2016-03-24T21:05:50Z",
_64 "date_updated": "2016-03-24T21:05:50Z",
_64 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_64 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64 "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_64 "date_created": "2016-03-24T21:05:50Z",
_64 "date_updated": "2016-03-24T21:05:50Z",
_64 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service with the Channel that has the Webhook resource to update.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to update belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to update.
Pattern: ^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
Configuration.UrlstringOptional The URL of the webhook to call using the configuration.method
.
Configuration.Methodenum<string>Optional The HTTP method used to call configuration.url
. Can be: GET
or POST
and the default is POST
.
Configuration.Filtersarray[string]Optional The events that cause us to call the Channel Webhook. Used when type
is webhook
. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see Webhook Event Triggers.
Configuration.Triggersarray[string]Optional A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when type
= trigger
.
Configuration.FlowSidSID<FW>Optional The SID of the Studio Flow to call when an event in configuration.filters
occurs. Used only when type
= studio
.
Pattern: ^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Configuration.RetryCountintegerOptional The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function updateChannelWebhook() {
_20 const webhook = await client.chat.v2
_20 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .channels("ChannelSid")
_20 .webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .update({ "configuration.url": "Configuration.Url" });
_20 console.log(webhook.sid);
_20updateChannelWebhook();
_19 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "channel_sid": "ChannelSid",
_19 "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19 "date_created": "2016-03-24T21:05:50Z",
_19 "date_updated": "2016-03-24T21:05:51Z",
_19 "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required The SID of the Service with the Channel to delete the Webhook resource from.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to delete belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to delete.
Pattern: ^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const 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
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function deleteChannelWebhook() {
_18 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .channels("ChannelSid")
_18 .webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18deleteChannelWebhook();