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

Channel Webhook 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 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.


ChannelWebhook Properties

channelwebhook-properties page anchor
Property nameTypePIIDescription
sidSID<WH>
Not PII

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

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

account_sidSID<AC>

The SID of the Account that created the Channel Webhook resource.

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

service_sidSID<IS>

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

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

channel_sidSID<CH>

The SID of the Channel the Channel Webhook resource belongs to.

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

typestring

The type of webhook. Can be: webhook, studio, or trigger.


urlstring<uri>

The absolute URL of the Channel Webhook resource.


configurationobject

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>

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.


Create a ChannelWebhook resource

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

The {ChannelSid} value can be the Channel's sid or its unique_name.

Path parameters

path-parameters page anchor
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: 34Max length: 34

ChannelSidstringrequired

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
Typeenum<string>required

The type of webhook. Can be: webhook, studio, or trigger.

Possible values:
webhooktriggerstudio

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.

Possible values:
GETPOST

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: 34Max 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.

Create a Channel Webhook resource

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

_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
_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
_19
async function createChannelWebhook() {
_19
const webhook = await client.chat.v2
_19
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.channels("ChannelSid")
_19
.webhooks.create({ type: "studio" });
_19
_19
console.log(webhook.sid);
_19
}
_19
_19
createChannelWebhook();

Output

_19
{
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_sid": "ChannelSid",
_19
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"type": "studio",
_19
"configuration": {
_19
"url": "dummy",
_19
"method": "GET",
_19
"filters": [
_19
"onMessageSent",
_19
"onChannelDestroyed"
_19
],
_19
"retry_count": 2
_19
},
_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"
_19
}


Fetch a ChannelWebhook resource

fetch-a-channelwebhook-resource page anchor
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: 34Max length: 34

ChannelSidstringrequired

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.


SidSID<WH>required

The SID of the Channel Webhook resource to fetch.

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

Fetch a Channel Webhook resource

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

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function fetchChannelWebhook() {
_20
const webhook = await client.chat.v2
_20
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.channels("ChannelSid")
_20
.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.fetch();
_20
_20
console.log(webhook.sid);
_20
}
_20
_20
fetchChannelWebhook();

Output

_13
{
_13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13
"channel_sid": "ChannelSid",
_13
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13
"type": "studio",
_13
"configuration": {
_13
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_13
},
_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"
_13
}


Read multiple ChannelWebhook resources

read-multiple-channelwebhook-resources page anchor
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: 34Max length: 34

ChannelSidstringrequired

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
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 Webhook resources

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

_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
_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
_19
async function listChannelWebhook() {
_19
const webhooks = await client.chat.v2
_19
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.channels("ChannelSid")
_19
.webhooks.list({ limit: 20 });
_19
_19
webhooks.forEach((w) => console.log(w.sid));
_19
}
_19
_19
listChannelWebhook();

Output

_64
{
_64
"meta": {
_64
"page": 0,
_64
"page_size": 5,
_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
"key": "webhooks"
_64
},
_64
"webhooks": [
_64
{
_64
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"type": "webhook",
_64
"configuration": {
_64
"url": "dummy",
_64
"method": "GET",
_64
"filters": [
_64
"onMessageSent",
_64
"onChannelDestroyed"
_64
],
_64
"retry_count": 2
_64
},
_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
},
_64
{
_64
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"type": "trigger",
_64
"configuration": {
_64
"url": "dummy",
_64
"method": "POST",
_64
"filters": [
_64
"keyword1",
_64
"keyword2"
_64
],
_64
"retry_count": 3
_64
},
_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
},
_64
{
_64
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_64
"type": "studio",
_64
"configuration": {
_64
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_64
},
_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
}
_64
]
_64
}


Update a ChannelWebhook resource

update-a-channelwebhook-resource page anchor
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: 34Max length: 34

ChannelSidstringrequired

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.


SidSID<WH>required

The SID of the Channel Webhook resource to update.

Pattern: ^WH[0-9a-fA-F]{32}$Min length: 34Max 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.

Possible values:
GETPOST

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: 34Max 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.

Update a Channel Webhook resource

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

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async 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
_20
console.log(webhook.sid);
_20
}
_20
_20
updateChannelWebhook();

Output

_19
{
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_sid": "ChannelSid",
_19
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"type": "trigger",
_19
"configuration": {
_19
"url": "dummy",
_19
"method": "POST",
_19
"filters": [
_19
"keyword1",
_19
"keyword2"
_19
],
_19
"retry_count": 3
_19
},
_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"
_19
}


Delete a ChannelWebhook resource

delete-a-channelwebhook-resource page anchor
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: 34Max length: 34

ChannelSidstringrequired

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.


SidSID<WH>required

The SID of the Channel Webhook resource to delete.

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

Delete a Channel Webhook resource

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

_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
_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
_18
async function deleteChannelWebhook() {
_18
await client.chat.v2
_18
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.channels("ChannelSid")
_18
.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.remove();
_18
}
_18
_18
deleteChannelWebhook();


Rate this page: