Menu

Expand
Rate this page:

Sink Resource

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:

"sink_configuration": { 
  "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test", 
  "role_arn": "arn:aws:iam::111111111:role/Role", 
  "external_id": "a secret value here"
}
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:

"sink_configuration": { 
    "destination": "http://example.org/webhook",
    "method": "<POST|GET>",
    "batch_events": <true|false>
}
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.
batch_events false if you want to receive single events and true if you want events sent in batches. Batched events currently have a 64kB data limit.

Here is an example of the sink_configuration object for a Segment Sink:

"sink_configuration": { 
    "write_key": "lwfOUDBL0VK33XstNWD3uJ7Eei2BdgY3"
}
Parameter Description
write_key Segment write key for the Segment source that you will use

Each Sink also has a status property. The value of this property will be one of initialized, validating, and active. To receive events, a Sink must be in active status.

Status Description
initialized The Sink has been created in the Event Streams API, but the connection still needs to be validated.
validating A test event has been published to the Sink. The validation process has started, but has not yet been completed by the customer.
active The sink has been validated or validation is not required. Events can only be delivered to Sinks with active status.

When a new Kinesis Sink is created, its default status is initialized. To make it active, you need to complete the following steps.

  1. First create a Sink resource of type Kinesis. The status of the Kinesis Sink will be initialized by default.
  2. Create a Sink Test Resource using your new Sink. The URL for this POST request is provided in the new Sink’s links object. This will publish a test event to your Sink.
  3. Check your Sink to see if the test event was successfully published. If so, this confirms that you’ve set up your Sink correctly.
  4. If the test was successful, retrieve the test_id and create a Sink Validate resource. The URL for this POST request is provided in the Sink’s links object. This will let Twilio know that you successfully configured the Sink, and will toggle the Sink’s status to active.

Webhook and Segment Sinks are active by default, so you do not have to validate them. However, if you choose to validate them, you can still do so with the Test and Validate resources mentioned above.

Sink properties

Resource Properties in REST API format
date_created
date_time<iso8601> Not PII

The date that this Sink was created, given in ISO 8601 format.

date_updated
date_time<iso8601> Not PII

The date that this Sink was updated, given in ISO 8601 format.

description
string Not PII

A human readable description for the Sink

sid
sid<DG> Not PII

A 34 character string that uniquely identifies this Sink.

sink_configuration
object Not PII

The information required for Twilio to connect to the provided Sink encoded as JSON.

sink_type
enum:sink_type Not PII

The Sink type. Can only be "kinesis" or "webhook" currently.

status
enum:status Not PII

The Status of this Sink. One of initialized, validating, active or failed.

url
url Not PII

The URL of this resource.

links
uri_map Not PII

Contains a dictionary of URL links to nested resources of this Sink.

Create a Sink resource

post
https://events.twilio.com/v1/Sinks
Parameters
Parameters in REST API format
description
Required
post string Not PII

A human readable description for the Sink This value should not contain PII.

sink_configuration
Required
post object Not PII

The information required for Twilio to connect to the provided Sink encoded as JSON.

sink_type
Required
post ienum:sink_type Not PII

The Sink type. Can only be "kinesis" or "webhook" currently.

Example 1
Loading Code Sample...
        
        

        Create Sink

        Fetch a Sink resource

        get
        https://events.twilio.com/v1/Sinks/{Sid}

        Fetches a Sink configuration by its SID.

        Parameters
        Parameters in REST API format
        sid
        Path
        get sid<DG> Not PII

        A 34 character string that uniquely identifies this Sink.

        Example 1
        Loading Code Sample...
              
              

              Fetch Sink

              Read multiple Sink resources

              get
              https://events.twilio.com/v1/Sinks

              Gets a list of all Sinks belonging to the account associated with the request. Supports pagination.

              Parameters
              Parameters in REST API format
              in_use
              Optional
              get boolean Not PII

              A boolean query parameter filtering the results to return sinks used/not used by a subscription.

              status
              Optional
              get string Not PII

              A String query parameter filtering the results by status initialized, validating, active or failed.

              Example 1
              Loading Code Sample...
                    
                    

                    Read Sink

                    Update Sink

                    post
                    https://events.twilio.com/v1/Sinks/{Sid}

                    Updates the description of a Sink

                    Parameters
                    Parameters in REST API format
                    sid
                    Path
                    post sid<DG> Not PII

                    A 34 character string that uniquely identifies this Sink.

                    description
                    Required
                    post string Not PII

                    A human readable description for the Sink This value should not contain PII.

                    Example 1
                    Loading Code Sample...
                          
                          

                          Update Sink

                          Delete a Sink resource

                          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.

                          Parameters
                          Parameters in REST API format
                          sid
                          Path
                          delete sid<DG> Not PII

                          A 34 character string that uniquely identifies this Sink.

                          Example 1
                          Loading Code Sample...
                                
                                

                                Delete Sink

                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                                Loading Code Sample...
                                      
                                      
                                      

                                      Thank you for your feedback!

                                      Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      thanks-feedback-gif