Skip to contentSkip to navigationSkip to topbar
On this page

Subscribed Event Resource


With this API the user can perform CRUD operations on an Event associated with a Subscription.

With the Subscribed Event API you can:

  • Add an existing event type to a subscription
  • Get all events associated with a subscription
  • Update an event on a subscription
  • Delete an event on a subscription

SubscribedEvent Properties

subscribedevent-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>Optional
Not PII

The unique SID identifier of the Account.

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

typestringOptional

Type of event being subscribed to.


schema_versionintegerOptional

The schema version that the Subscription should use.

Default: 0

subscription_sidSID<DF>Optional

The unique SID identifier of the Subscription.

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

urlstring<uri>Optional

The URL of this resource.


POST https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents

This endpoint adds an existing event type to a particular subscription. It is possible to specify the version of the schema to use for the given event type. Otherwise the last available schema version will be used for the added event type.

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
SubscriptionSidSID<DF>required

The unique SID identifier of the Subscription.

Pattern: ^DF[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
Typestringrequired

Type of event being subscribed to.


SchemaVersionintegerOptional

The schema version that the Subscription should use.

Add Event Type to SubscriptionLink to code sample: Add Event Type to Subscription
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 createSubscribedEvent() {
11
const subscribedEvent = await client.events.v1
12
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.subscribedEvents.create({
14
type: "com.twilio.messaging.message.delivered",
15
});
16
17
console.log(subscribedEvent.accountSid);
18
}
19
20
createSubscribedEvent();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"type": "com.twilio.messaging.message.delivered",
5
"schema_version": 2,
6
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
7
}
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 createSubscribedEvent() {
11
const subscribedEvent = await client.events.v1
12
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.subscribedEvents.create({
14
schemaVersion: 2,
15
type: "com.twilio.messaging.message.delivered",
16
});
17
18
console.log(subscribedEvent.accountSid);
19
}
20
21
createSubscribedEvent();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"type": "com.twilio.messaging.message.delivered",
5
"schema_version": 2,
6
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
7
}

GET https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents

Get all event types associated with a particular subscription

Property nameTypeRequiredPIIDescription
SubscriptionSidSID<DF>required

The unique SID identifier of the Subscription.

Pattern: ^DF[0-9a-fA-F]{32}$Min length: 34Max length: 34
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 listSubscribedEvent() {
11
const subscribedEvents = await client.events.v1
12
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.subscribedEvents.list({ limit: 20 });
14
15
subscribedEvents.forEach((s) => console.log(s.accountSid));
16
}
17
18
listSubscribedEvent();

Output

1
{
2
"types": [],
3
"meta": {
4
"page": 0,
5
"page_size": 10,
6
"first_page_url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents?PageSize=10&Page=0",
7
"previous_page_url": null,
8
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents?PageSize=10&Page=0",
9
"next_page_url": null,
10
"key": "types"
11
}
12
}

POST https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents/{Type}

Updates the event type

Property nameTypeRequiredPIIDescription
SubscriptionSidSID<DF>required

The unique SID identifier of the Subscription.

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

Typestringrequired

Type of event being subscribed to.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
SchemaVersionintegerOptional

The schema version that the Subscription should use.

Change schema version of subscribed event typeLink to code sample: Change schema version of subscribed event type
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 updateSubscribedEvent() {
11
const subscribedEvent = await client.events.v1
12
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.subscribedEvents("com.twilio.messaging.message.delivered")
14
.update({ schemaVersion: 1 });
15
16
console.log(subscribedEvent.accountSid);
17
}
18
19
updateSubscribedEvent();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"type": "com.twilio.messaging.message.delivered",
5
"schema_version": 1,
6
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
7
}

DELETE https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents/{Type}

Deletes an event type on a subscription.

Property nameTypeRequiredPIIDescription
SubscriptionSidSID<DF>required

The unique SID identifier of the Subscription.

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

Typestringrequired

Type of event being subscribed to.

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 deleteSubscribedEvent() {
11
await client.events.v1
12
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.subscribedEvents("com.twilio.messaging.message.delivered")
14
.remove();
15
}
16
17
deleteSubscribedEvent();