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
Resource properties
account_sidtype: SID<AC>Not PII

The unique SID identifier of the Account.


typetype: stringNot PII

Type of event being subscribed to.


schema_versiontype: integerNot PII

The schema version that the Subscription should use.


subscription_sidtype: SID<DF>Not PII

The unique SID identifier of the Subscription.


urltype: string<URI>Not PII

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.

Parameters

create-parameters page anchor
URI parameters
SubscriptionSidtype: SID<DF>Not PII
Path Parameter

The unique SID identifier of the Subscription.


Request body parameters
Typetype: stringNot PII
Required

Type of event being subscribed to.


SchemaVersiontype: integerNot PII

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

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

Output

_10
{
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"type": "com.twilio.messaging.message.delivered",
_10
"schema_version": 2,
_10
"url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_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 = require('twilio')(accountSid, authToken);
_14
_14
client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14
.subscribedEvents
_14
.create({
_14
schemaVersion: 2,
_14
type: 'com.twilio.messaging.message.delivered'
_14
})
_14
.then(subscribed_event => console.log(subscribed_event.type));

Output

_10
{
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"type": "com.twilio.messaging.message.delivered",
_10
"schema_version": 2,
_10
"url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/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

URI parameters
SubscriptionSidtype: SID<DF>Not PII
Path Parameter

The unique SID identifier of the Subscription.


PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

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

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

Output

_27
{
_27
"types": [
_27
{
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"type": "com.twilio.messaging.message.delivered",
_27
"schema_version": 2,
_27
"subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.delivered"
_27
},
_27
{
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"type": "com.twilio.messaging.message.failed",
_27
"schema_version": 15,
_27
"subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.failed"
_27
}
_27
],
_27
"meta": {
_27
"page": 0,
_27
"page_size": 50,
_27
"first_page_url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents?PageSize=50&Page=0",
_27
"previous_page_url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents?PageSize=50&Page=0",
_27
"url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents?PageSize=50&Page=0",
_27
"next_page_url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents?PageSize=50&Page=1",
_27
"key": "types"
_27
}
_27
}


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

Updates the event type

URI parameters
SubscriptionSidtype: SID<DF>Not PII
Path Parameter

The unique SID identifier of the Subscription.


Typetype: stringNot PII
Path Parameter

Type of event being subscribed to.


Request body parameters
SchemaVersiontype: integerNot PII

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

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

Output

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


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

Deletes an event type on a subscription.

URI parameters
SubscriptionSidtype: SID<DF>Not PII
Path Parameter

The unique SID identifier of the Subscription.


Typetype: stringNot PII
Path Parameter

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

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


Rate this page: