Subscription Resource
You can use the Subscriptions API to subscribe to specific Twilio events and versions, and manage your subscriptions.
With the Subscriptions API you can:
-
Create new Subscriptions.
-
Fetch a specific Subscription.
-
Fetch a list of Subscriptions.
-
Update a Subscription.
-
Delete a Subscription.
A subscription is comprised of a set of pairs of Event Types and Schema versions that can be modified using the SubscribedEvents API.
Resource properties
account_sid
type: SID<AC>
The unique SID identifier of the Account.
Pattern:
^AC[0-9a-fA-F]{32}$
sid
type: SID<DF>
A 34 character string that uniquely identifies this Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
date_created
type: string<date-time>
The date that this Subscription was created, given in ISO 8601 format.
date_updated
type: string<date-time>
The date that this Subscription was updated, given in ISO 8601 format.
description
type: string
A human readable description for the Subscription
sink_sid
type: SID<DG>
The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
Pattern:
^DG[0-9a-fA-F]{32}$
url
type: string<uri>
The URL of this resource.
links
type: object<uri-map>
Contains a dictionary of URL links to nested resources of this Subscription.
POST https://events.twilio.com/v1/Subscriptions
Make a new Subscription.
Request body parameters
Description
type: stringRequired
A human readable description for the Subscription This value should not contain PII.
SinkSid
type: SID<DG>Required
The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
Pattern:
^DG[0-9a-fA-F]{32}$
Types
type: arrayRequired
An array of objects containing the subscribed Event Types
_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
_14 description: `"A subscription"`,
_14 types: [{'type': 'com.twilio.messaging.message.delivered'}, {'type': 'com.twilio.messaging.message.sent', 'schema_version': 2}],
_14 sinkSid: 'DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_14 .then(subscription => console.log(subscription.sid));
_12 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "date_created": "2015-07-30T20:00:00Z",
_12 "date_updated": "2015-07-30T20:01:33Z",
_12 "sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "sink_sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "description": "\"A subscription\"",
_12 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents"
GET https://events.twilio.com/v1/Subscriptions/{Sid}
Retrieve a specific Subscription using its Subscription ID.
URI parameters
Sid
type: SID<DF>
A 34 character string that uniquely identifies this Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
_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 .then(subscription => console.log(subscription.sid));
_12 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "date_created": "2015-07-30T20:00:00Z",
_12 "date_updated": "2015-07-30T20:01:33Z",
_12 "sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "sink_sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "description": "A subscription",
_12 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents"
GET https://events.twilio.com/v1/Subscriptions
Retrieve information on all created subscriptions
URI parameters
SinkSid
type: SID<DG>
The SID of the sink that the list of Subscriptions should be filtered by.
Pattern:
^DG[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.
_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
_10 .then(subscriptions => subscriptions.forEach(s => console.log(s.sid)));
_37 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "date_created": "2015-07-30T20:00:00Z",
_37 "date_updated": "2015-07-30T20:01:33Z",
_37 "sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "sink_sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "description": "A subscription",
_37 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents"
_37 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "date_created": "2015-07-30T20:00:00Z",
_37 "date_updated": "2015-07-30T20:01:33Z",
_37 "sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "sink_sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "description": "Another subscription",
_37 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_37 "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents"
_37 "first_page_url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=0",
_37 "previous_page_url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=0",
_37 "url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=0",
_37 "next_page_url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=1",
_37 "key": "subscriptions"
POST https://events.twilio.com/v1/Subscriptions/{Sid}
Modify an existing Subscription identified by its Subscription ID.
URI parameters
Sid
type: SID<DF>
A 34 character string that uniquely identifies this Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
Request body parameters
Description
type: string
A human readable description for the Subscription.
SinkSid
type: SID<DG>
The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
Pattern:
^DG[0-9a-fA-F]{32}$
_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 .update({description: `"Updated description"`})
_10 .then(subscription => console.log(subscription.sid));
_12 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "date_created": "2015-07-30T20:00:00Z",
_12 "date_updated": "2020-07-30T20:01:33Z",
_12 "sid": "DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "sink_sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "description": "\"Updated description\"",
_12 "url": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12 "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents"
DELETE https://events.twilio.com/v1/Subscriptions/{Sid}
Remove a Subscription identified by its Subscription ID.
URI parameters
Sid
type: SID<DF>
A 34 character string that uniquely identifies this Subscription.
Pattern:
^DF[0-9a-fA-F]{32}$
_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').remove();