Skip to contentSkip to navigationSkip to topbar
Rate this page:
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 nameTypePIIDescription
account_sidSID<AC>
Not PII

The unique SID identifier of the Account.

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

typestring

Type of event being subscribed to.


schema_versioninteger

The schema version that the Subscription should use.


subscription_sidSID<DF>

The unique SID identifier of the Subscription.

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

urlstring<uri>

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
Property nameTypeRequiredPIIDescription
Typestringrequired

Type of event being subscribed to.


SchemaVersionintegerOptional

The schema version that the Subscription should use.

Add Event Type to Subscription

add-event-type-to-subscription page anchor

Adds an event type to the subscription to the latest schema version available

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 createSubscribedEvent() {
_20
const subscribedEvent = await client.events.v1
_20
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.subscribedEvents.create({
_20
type: "com.twilio.messaging.message.delivered",
_20
});
_20
_20
console.log(subscribedEvent.accountSid);
_20
}
_20
_20
createSubscribedEvent();

Output

_10
{
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"type": "com.twilio.messaging.message.delivered",
_10
"schema_version": 2,
_10
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
_10
}

Add Event Type with schema version

add-event-type-with-schema-version page anchor

Add an event type specifying the schema version to be used

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_21
// Download the helper library from https://www.twilio.com/docs/node/install
_21
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21
_21
// Find your Account SID and Auth Token at twilio.com/console
_21
// and set the environment variables. See http://twil.io/secure
_21
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21
const authToken = process.env.TWILIO_AUTH_TOKEN;
_21
const client = twilio(accountSid, authToken);
_21
_21
async function createSubscribedEvent() {
_21
const subscribedEvent = await client.events.v1
_21
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_21
.subscribedEvents.create({
_21
schemaVersion: 2,
_21
type: "com.twilio.messaging.message.delivered",
_21
});
_21
_21
console.log(subscribedEvent.accountSid);
_21
}
_21
_21
createSubscribedEvent();

Output

_10
{
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"type": "com.twilio.messaging.message.delivered",
_10
"schema_version": 2,
_10
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
_10
}


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.

Get all subscribed events types

get-all-subscribed-events-types 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 listSubscribedEvent() {
_18
const subscribedEvents = await client.events.v1
_18
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.subscribedEvents.list({ limit: 20 });
_18
_18
subscribedEvents.forEach((s) => console.log(s.accountSid));
_18
}
_18
_18
listSubscribedEvent();

Output

_12
{
_12
"types": [],
_12
"meta": {
_12
"page": 0,
_12
"page_size": 10,
_12
"first_page_url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents?PageSize=10&Page=0",
_12
"previous_page_url": null,
_12
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents?PageSize=10&Page=0",
_12
"next_page_url": null,
_12
"key": "types"
_12
}
_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.

Property nameTypeRequiredPIIDescription
SchemaVersionintegerOptional

The schema version that the Subscription should use.

Change schema version of subscribed event type

change-schema-version-of-subscribed-event-type page anchor

Downgrade the version of the subscribed event type

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 updateSubscribedEvent() {
_19
const subscribedEvent = await client.events.v1
_19
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.subscribedEvents("com.twilio.messaging.message.delivered")
_19
.update({ schemaVersion: 1 });
_19
_19
console.log(subscribedEvent.accountSid);
_19
}
_19
_19
updateSubscribedEvent();

Output

_10
{
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"type": "com.twilio.messaging.message.delivered",
_10
"schema_version": 1,
_10
"url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered"
_10
}


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.

Remove an event type from a subscription

remove-an-event-type-from-a-subscription page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_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
_17
async function deleteSubscribedEvent() {
_17
await client.events.v1
_17
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.subscribedEvents("com.twilio.messaging.message.delivered")
_17
.remove();
_17
}
_17
_17
deleteSubscribedEvent();


Rate this page: