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

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

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

_17
// Download the helper library from https://www.twilio.com/docs/node/install
_17
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
const subscribedEvent = await client.events.v1
_17
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.subscribedEvents.create({
_17
schemaVersion: 2,
_17
type: "com.twilio.messaging.message.delivered",
_17
});
_17
_17
console.log(subscribedEvent.accountSid);

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const subscribedEvents = await client.events.v1
_14
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_14
.subscribedEvents.list({ limit: 20 });
_14
_14
subscribedEvents.forEach((s) => console.log(s.accountSid));

Output

_20
{
_20
"meta": {
_20
"first_page_url": "https://www.example.com",
_20
"next_page_url": "https://www.example.com",
_20
"page": 382,
_20
"page_size": 73,
_20
"previous_page_url": "https://www.example.com",
_20
"url": "https://www.example.com",
_20
"key": "key"
_20
},
_20
"types": [
_20
{
_20
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_20
"type": "type",
_20
"schema_version": 935,
_20
"subscription_sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_20
"url": "https://www.example.com"
_20
}
_20
]
_20
}


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

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

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

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
import twilio from "twilio";
_13
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = twilio(accountSid, authToken);
_13
_13
await client.events.v1
_13
.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_13
.subscribedEvents("com.twilio.messaging.message.delivered")
_13
.remove();


Rate this page: