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
Resource properties
account_sid
type: SID<AC>
The unique SID identifier of the Account.
Pattern:
^AC[0-9a-fA-F]{32}$
type
type: string
Type of event being subscribed to.
schema_version
type: integer
The schema version that the Subscription should use.
subscription_sid
type: SID<DF>
The unique SID identifier of the Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
url
type: string<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.
URI parameters
SubscriptionSid
type: SID<DF>
The unique SID identifier of the Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
Request body parameters
Type
type: stringRequired
Type of event being subscribed to.
SchemaVersion
type: integer
The schema version that the Subscription should use.
Adds an event type to the subscription to the latest schema version available
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .create({type: 'com.twilio.messaging.message.delivered'})
_11 .then(subscribed_event => console.log(subscribed_event.type));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "type": "com.twilio.messaging.message.delivered",
_10 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.delivered"
Add an event type specifying the schema version to be used
_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
_14const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14const authToken = process.env.TWILIO_AUTH_TOKEN;
_14const client = require('twilio')(accountSid, authToken);
_14client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14 type: 'com.twilio.messaging.message.delivered'
_14 .then(subscribed_event => console.log(subscribed_event.type));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "type": "com.twilio.messaging.message.delivered",
_10 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.delivered"
GET https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents
Get all event types associated with a particular subscription
URI parameters
SubscriptionSid
type: SID<DF>
The unique SID identifier of the Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(subscribedEvents => subscribedEvents.forEach(s => console.log(s.type)));
_27 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "type": "com.twilio.messaging.message.delivered",
_27 "subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.delivered"
_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 "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",
POST https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents/{Type}
Updates the event type
URI parameters
SubscriptionSid
type: SID<DF>
The unique SID identifier of the Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
Type
type: string
Type of event being subscribed to.
Request body parameters
SchemaVersion
type: integer
The schema version that the Subscription should use.
Downgrade the version of the subscribed event type
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .subscribedEvents('com.twilio.messaging.message.delivered')
_11 .update({schemaVersion: 1})
_11 .then(subscribed_event => console.log(subscribed_event.type));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "subscription_sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "type": "com.twilio.messaging.message.delivered",
_10 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/com.twilio.messaging.message.delivered"
DELETE https://events.twilio.com/v1/Subscriptions/{SubscriptionSid}/SubscribedEvents/{Type}
Deletes an event type on a subscription.
URI parameters
SubscriptionSid
type: SID<DF>
The unique SID identifier of the Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
Type
type: string
Type of event being subscribed to.
_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
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.events.v1.subscriptions('DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .subscribedEvents('com.twilio.messaging.message.delivered')