Sinks are the destinations to which events selected in a subscription will be delivered. Each sink has a sink_type
property. At this time, the Sink resource supports three types: AWS Kinesis indicated by the value kinesis
, Webhooks indicated by the value webhook
, and Segment indicated by the value segment
. Each Sink has a sink_configuration
property which expresses its set up.
Not seeing a sink type you would like to configure? Submit a sink type request.
An example of the sink_configuration
object for a Kinesis Sink:
1"sink_configuration": {2"arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",3"role_arn": "arn:aws:iam::111111111:role/Role",4"external_id": "a secret value here"5}
Parameter | Description |
---|---|
arn | The Amazon Resource Identifier for the Kinesis stream. |
role_arn | The Amazon Resource Identifier for the AWS role that has write access to the Kineses stream specified arn . |
external_id | An ID added to the role specified in role_arn which AWS requires in order to grant a third party access to a given resource. It helps prevent what is known as the Confused Deputy Problem. |
Here is an example of the sink_configuration
object for a Webhook Sink:
1"sink_configuration": {2"destination": "http://example.org/webhook",3"method": "<POST|GET>"4}
Parameter | Description |
---|---|
destination | The customers' url endpoint i.e http://example.org/webhook |
method | The HTTP method for updating the data on the webhook. The currently available options are GET and POST . |
Here is an example of the sink_configuration
object for a Segment Sink:
1"sink_configuration": {2"write_key": "lwfOUDBL0VK33XstNWD3uJ7Eei2BdgY3"3}
Parameter | Description |
---|---|
write_key | Segment write key for the Segment source that you will use |
The date that this Sink was created, given in ISO 8601 format.
The date that this Sink was updated, given in ISO 8601 format.
A 34 character string that uniquely identifies this Sink.
^DG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The information required for Twilio to connect to the provided Sink encoded as JSON.
The Sink type. Can only be "kinesis" or "webhook" currently.
kinesis
webhook
segment
The Status of this Sink. One of initialized
, validating
, active
or failed
.
initialized
validating
active
failed
Contains a dictionary of URL links to nested resources of this Sink.
POST https://events.twilio.com/v1/Sinks
application/x-www-form-urlencoded
A human readable description for the Sink This value should not contain PII.
The information required for Twilio to connect to the provided Sink encoded as JSON.
The Sink type. Can only be "kinesis" or "webhook" currently.
kinesis
webhook
segment
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createSink() {11const sink = await client.events.v1.sinks.create({12description: "My Kinesis Sink",13sinkConfiguration: {14arn: "arn:aws:kinesis:us-east-1:111111111:stream/test",15role_arn: "arn:aws:iam::111111111:role/Role",16external_id: "1234567890",17},18sinkType: "kinesis",19});2021console.log(sink.dateCreated);22}2324createSink();
1{2"status": "initialized",3"sink_configuration": {4"arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",5"role_arn": "arn:aws:iam::111111111:role/Role",6"external_id": "1234567890"7},8"description": "My Kinesis Sink",9"sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"date_created": "2015-07-30T20:00:00Z",11"sink_type": "kinesis",12"date_updated": "2015-07-30T20:00:00Z",13"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"links": {15"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",16"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"17}18}
GET https://events.twilio.com/v1/Sinks/{Sid}
Fetches a Sink configuration by its SID.
A 34 character string that uniquely identifies this Sink.
^DG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchSink() {11const sink = await client.events.v112.sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.fetch();1415console.log(sink.sinkConfiguration);16}1718fetchSink();
1{2"status": "initialized",3"sink_configuration": {4"arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",5"role_arn": "arn:aws:iam::111111111:role/Role",6"external_id": "1234567890"7},8"description": "A Sink",9"sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",10"date_created": "2015-07-30T20:00:00Z",11"sink_type": "kinesis",12"date_updated": "2015-07-30T20:00:00Z",13"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"links": {15"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",16"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"17}18}
GET https://events.twilio.com/v1/Sinks
Gets a list of all Sinks belonging to the account associated with the request. Supports pagination.
A boolean query parameter filtering the results to return sinks used/not used by a subscription.
A String query parameter filtering the results by status initialized
, validating
, active
or failed
.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listSink() {11const sinks = await client.events.v1.sinks.list({ limit: 20 });1213sinks.forEach((s) => console.log(s.dateCreated));14}1516listSink();
1{2"sinks": [3{4"status": "initialized",5"sink_configuration": {6"arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",7"role_arn": "arn:aws:iam::111111111:role/Role",8"external_id": "1234567890"9},10"description": "A Sink",11"sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"date_created": "2015-07-30T19:00:00Z",13"sink_type": "kinesis",14"date_updated": "2015-07-30T19:00:00Z",15"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"links": {17"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",18"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"19}20},21{22"status": "initialized",23"sink_configuration": {24"arn": "arn:aws:kinesis:us-east-1:222222222:stream/test",25"role_arn": "arn:aws:iam::111111111:role/Role",26"external_id": "1234567890"27},28"description": "ANOTHER Sink",29"sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",30"date_created": "2015-07-30T20:00:00Z",31"sink_type": "kinesis",32"date_updated": "2015-07-30T20:00:00Z",33"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",34"links": {35"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Test",36"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Validate"37}38},39{40"status": "active",41"sink_configuration": {42"destination": "http://example.org/webhook",43"method": "POST",44"batch_events": true45},46"description": "A webhook Sink",47"sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac",48"date_created": "2015-07-30T21:00:00Z",49"sink_type": "webhook",50"date_updated": "2015-07-30T21:00:00Z",51"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac",52"links": {53"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test",54"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Validate"55}56}57],58"meta": {59"page": 0,60"page_size": 20,61"first_page_url": "https://events.twilio.com/v1/Sinks?PageSize=20&Page=0",62"previous_page_url": null,63"url": "https://events.twilio.com/v1/Sinks?PageSize=20&Page=0",64"next_page_url": null,65"key": "sinks"66}67}
POST https://events.twilio.com/v1/Sinks/{Sid}
Updates the description of a Sink
A 34 character string that uniquely identifies this Sink.
^DG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A human readable description for the Sink This value should not contain PII.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateSink() {11const sink = await client.events.v112.sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.update({ description: "My Kinesis Sink" });1415console.log(sink.dateCreated);16}1718updateSink();
1{2"status": "initialized",3"sink_configuration": {4"arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",5"role_arn": "arn:aws:iam::111111111:role/Role",6"external_id": "1234567890"7},8"description": "My Kinesis Sink",9"sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",10"date_created": "2015-07-30T20:00:00Z",11"sink_type": "kinesis",12"date_updated": "2015-07-30T20:00:00Z",13"url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"links": {15"sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",16"sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"17}18}
DELETE https://events.twilio.com/v1/Sinks/{Sid}
Deletes the Sink with the specified SID. If the Sink has a Subscription associated with it, the Subscription must be deleted first in order to delete the Sink.
A 34 character string that uniquely identifies this Sink.
^DG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteSink() {11await client.events.v1.sinks("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").remove();12}1314deleteSink();