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


Webhook Properties

webhook-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<WH>Optional
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>Optional

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>Optional

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>Optional

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

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

typestringOptional

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


urlstring<uri>Optional

The absolute URL of the Channel Webhook resource.


configurationobjectOptional

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>Optional

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>Optional

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.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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 resourceLink to code sample: Create a Channel Webhook resource
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createChannelWebhook() {
11
const webhook = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.webhooks.create({ type: "webhook" });
15
16
console.log(webhook.sid);
17
}
18
19
createChannelWebhook();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "ChannelSid",
5
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"type": "webhook",
7
"configuration": {
8
"url": "dummy",
9
"method": "GET",
10
"filters": [
11
"onMessageSent",
12
"onChannelDestroyed"
13
],
14
"retry_count": 2
15
},
16
"date_created": "2016-03-24T21:05:50Z",
17
"date_updated": "2016-03-24T21:05:50Z",
18
"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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchChannelWebhook() {
11
const webhook = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.fetch();
16
17
console.log(webhook.sid);
18
}
19
20
fetchChannelWebhook();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "ChannelSid",
5
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"type": "studio",
7
"configuration": {
8
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"date_created": "2016-03-24T21:05:50Z",
11
"date_updated": "2016-03-24T21:05:50Z",
12
"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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listChannelWebhook() {
11
const webhooks = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.webhooks.list({ limit: 20 });
15
16
webhooks.forEach((w) => console.log(w.sid));
17
}
18
19
listChannelWebhook();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 5,
5
"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
6
"previous_page_url": null,
7
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
8
"next_page_url": null,
9
"key": "webhooks"
10
},
11
"webhooks": [
12
{
13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"type": "webhook",
18
"configuration": {
19
"url": "dummy",
20
"method": "GET",
21
"filters": [
22
"onMessageSent",
23
"onChannelDestroyed"
24
],
25
"retry_count": 2
26
},
27
"date_created": "2016-03-24T21:05:50Z",
28
"date_updated": "2016-03-24T21:05:50Z",
29
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
30
},
31
{
32
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
33
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
34
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
35
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
36
"type": "trigger",
37
"configuration": {
38
"url": "dummy",
39
"method": "POST",
40
"filters": [
41
"keyword1",
42
"keyword2"
43
],
44
"retry_count": 3
45
},
46
"date_created": "2016-03-24T21:05:50Z",
47
"date_updated": "2016-03-24T21:05:50Z",
48
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
49
},
50
{
51
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
52
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
53
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
54
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
55
"type": "studio",
56
"configuration": {
57
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
58
},
59
"date_created": "2016-03-24T21:05:50Z",
60
"date_updated": "2016-03-24T21:05:50Z",
61
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
62
}
63
]
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
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateChannelWebhook() {
11
const webhook = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({ "configuration.url": "Configuration.Url" });
16
17
console.log(webhook.sid);
18
}
19
20
updateChannelWebhook();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "ChannelSid",
5
"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"type": "trigger",
7
"configuration": {
8
"url": "dummy",
9
"method": "POST",
10
"filters": [
11
"keyword1",
12
"keyword2"
13
],
14
"retry_count": 3
15
},
16
"date_created": "2016-03-24T21:05:50Z",
17
"date_updated": "2016-03-24T21:05:51Z",
18
"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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteChannelWebhook() {
11
await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.remove();
16
}
17
18
deleteChannelWebhook();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.