# 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.

> \[!NOTE]
>
> Not seeing a sink type you would like to configure? [Submit a sink type request](https://docs.google.com/forms/d/e/1FAIpQLSeveilrOFwfYUHTOGksmwZzQE6UHtbYlNkIFylQxUP_A6XzbQ/viewform).

An example of the `sink_configuration`object for a Kinesis Sink:

```json
"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](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html). |

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

```json
"sink_configuration": { 
    "destination": "http://example.org/webhook",
    "method": "<POST|GET>"
}
```

| Parameter     | Description                                           | Accepted values | Example                      |
| ------------- | ----------------------------------------------------- | --------------- | ---------------------------- |
| `destination` | The customers' url endpoint                           | Webhook URL     | `http://example.org/webhook` |
| `method`      | The HTTP method for updating the data on the webhook. | `GET` ,  `POST` |                              |

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

```json
"sink_configuration": { 
    "write_key": "lwfOUDBL0VK33XstNWD3uJ7Eei2BdgY3"
}
```

| Parameter   | Description                                                                                            |
| ----------- | ------------------------------------------------------------------------------------------------------ |
| `write_key` | [Segment write key](/docs/segment/connections/find-writekey/) for the Segment source that you will use |

## Sink Properties

```json
{"type":"object","refName":"events.v1.sink","modelName":"events_v1_sink","properties":{"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Sink was created, given in ISO 8601 format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Sink was updated, given in ISO 8601 format."},"description":{"type":"string","nullable":true,"description":"A human readable description for the Sink"},"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$","nullable":true,"description":"A 34 character string that uniquely identifies this Sink."},"sink_configuration":{"nullable":true,"description":"The information required for Twilio to connect to the provided Sink encoded as JSON."},"sink_type":{"type":"string","enum":["kinesis","webhook","segment","email"],"description":"The Sink type. Can only be \"kinesis\" or \"webhook\" currently.","refName":"sink_enum_sink_type","modelName":"sink_enum_sink_type"},"status":{"type":"string","enum":["initialized","validating","active","failed"],"description":"The Status of this Sink. One of `initialized`, `validating`, `active` or `failed`.","refName":"sink_enum_status","modelName":"sink_enum_status"},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"Contains a dictionary of URL links to nested resources of this Sink."}}}
```

## Create a Sink resource

`POST https://events.twilio.com/v1/Sinks`

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateSinkRequest","required":["Description","SinkConfiguration","SinkType"],"properties":{"Description":{"type":"string","description":"A human readable description for the Sink **This value should not contain PII.**"},"SinkConfiguration":{"description":"The information required for Twilio to connect to the provided Sink encoded as JSON."},"SinkType":{"type":"string","enum":["kinesis","webhook","segment","email"],"description":"The Sink type. Can only be \"kinesis\" or \"webhook\" currently.","refName":"sink_enum_sink_type","modelName":"sink_enum_sink_type"}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Description\": \"My Kinesis Sink\",\n  \"SinkType\": \"kinesis\",\n  \"SinkConfiguration\": \"{\\\"arn\\\": \\\"arn:aws:kinesis:us-east-1:111111111:stream/test\\\",\\\"role_arn\\\": \\\"arn:aws:iam::111111111:role/Role\\\",\\\"external_id\\\": \\\"1234567890\\\"}\"\n}","meta":"","code":"{\n  \"Description\": \"My Kinesis Sink\",\n  \"SinkType\": \"kinesis\",\n  \"SinkConfiguration\": \"{\\\"arn\\\": \\\"arn:aws:kinesis:us-east-1:111111111:stream/test\\\",\\\"role_arn\\\": \\\"arn:aws:iam::111111111:role/Role\\\",\\\"external_id\\\": \\\"1234567890\\\"}\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Description\"","#7EE787"],[":","#C9D1D9"]," ",["\"My Kinesis Sink\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"SinkType\"","#7EE787"],[":","#C9D1D9"]," ",["\"kinesis\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"SinkConfiguration\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["arn","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["arn:aws:kinesis:us-east-1:111111111:stream/test","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"],["\\\"","#79C0FF"],["role_arn","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["arn:aws:iam::111111111:role/Role","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"],["\\\"","#79C0FF"],["external_id","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["1234567890","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"createSegment":{"value":{"lang":"json","value":"{\n  \"Description\": \"My segment Sink\",\n  \"SinkType\": \"segment\",\n  \"SinkConfiguration\": \"{\\\"write_key\\\": \\\"MY_WRITEKEY\\\"}\"\n}","meta":"","code":"{\n  \"Description\": \"My segment Sink\",\n  \"SinkType\": \"segment\",\n  \"SinkConfiguration\": \"{\\\"write_key\\\": \\\"MY_WRITEKEY\\\"}\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Description\"","#7EE787"],[":","#C9D1D9"]," ",["\"My segment Sink\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"SinkType\"","#7EE787"],[":","#C9D1D9"]," ",["\"segment\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"SinkConfiguration\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["write_key","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["MY_WRITEKEY","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create Sink

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createSink() {
  const sink = await client.events.v1.sinks.create({
    description: "My Kinesis Sink",
    sinkConfiguration: {
      arn: "arn:aws:kinesis:us-east-1:111111111:stream/test",
      role_arn: "arn:aws:iam::111111111:role/Role",
      external_id: "1234567890",
    },
    sinkType: "kinesis",
  });

  console.log(sink.dateCreated);
}

createSink();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sink = client.events.v1.sinks.create(
    description="My Kinesis Sink",
    sink_type="kinesis",
    sink_configuration={
        "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
        "role_arn": "arn:aws:iam::111111111:role/Role",
        "external_id": "1234567890",
    },
)

print(sink.date_created)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var sink = await SinkResource.CreateAsync(
            description: "My Kinesis Sink",
            sinkType: SinkResource.SinkTypeEnum.Kinesis,
            sinkConfiguration: new Dictionary<string, Object>() {
                { "arn", "arn:aws:kinesis:us-east-1:111111111:stream/test" },
                { "role_arn", "arn:aws:iam::111111111:role/Role" },
                { "external_id", "1234567890" }
            });

        Console.WriteLine(sink.DateCreated);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.events.v1.Sink;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Sink sink = Sink.creator("My Kinesis Sink", new HashMap<String, Object>() {
                            {
                                put("arn", "arn:aws:kinesis:us-east-1:111111111:stream/test");
                                put("role_arn", "arn:aws:iam::111111111:role/Role");
                                put("external_id", "1234567890");
                            }
                        }, Sink.SinkType.KINESIS).create();

        System.out.println(sink.getDateCreated());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	events "github.com/twilio/twilio-go/rest/events/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &events.CreateSinkParams{}
	params.SetDescription("My Kinesis Sink")
	params.SetSinkType("kinesis")
	params.SetSinkConfiguration(map[string]interface{}{
		"arn":         "arn:aws:kinesis:us-east-1:111111111:stream/test",
		"role_arn":    "arn:aws:iam::111111111:role/Role",
		"external_id": "1234567890",
	})

	resp, err := client.EventsV1.CreateSink(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.DateCreated != nil {
			fmt.Println(*resp.DateCreated)
		} else {
			fmt.Println(resp.DateCreated)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sink = $twilio->events->v1->sinks->create(
    "My Kinesis Sink", // Description
    [
        "arn" => "arn:aws:kinesis:us-east-1:111111111:stream/test",
        "role_arn" => "arn:aws:iam::111111111:role/Role",
        "external_id" => "1234567890",
    ], // SinkConfiguration
    "kinesis" // SinkType
);

print $sink->dateCreated?->format("r");
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sink = @client
       .events
       .v1
       .sinks
       .create(
         description: 'My Kinesis Sink',
         sink_type: 'kinesis',
         sink_configuration: {
           'arn' => 'arn:aws:kinesis:us-east-1:111111111:stream/test',
           'role_arn' => 'arn:aws:iam::111111111:role/Role',
           'external_id' => '1234567890'
         }
       )

puts sink.date_created
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:sinks:create \
   --description "My Kinesis Sink" \
   --sink-type kinesis \
   --sink-configuration "{\"arn\":\"arn:aws:kinesis:us-east-1:111111111:stream/test\",\"role_arn\":\"arn:aws:iam::111111111:role/Role\",\"external_id\":\"1234567890\"}"
```

```bash
SINK_CONFIGURATION_OBJ=$(cat << EOF
{
  "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
  "role_arn": "arn:aws:iam::111111111:role/Role",
  "external_id": "1234567890"
}
EOF
)
curl -X POST "https://events.twilio.com/v1/Sinks" \
--data-urlencode "Description=My Kinesis Sink" \
--data-urlencode "SinkType=kinesis" \
--data-urlencode "SinkConfiguration=$SINK_CONFIGURATION_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "status": "initialized",
  "sink_configuration": {
    "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
    "role_arn": "arn:aws:iam::111111111:role/Role",
    "external_id": "1234567890"
  },
  "description": "My Kinesis Sink",
  "sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "sink_type": "kinesis",
  "date_updated": "2015-07-30T20:00:00Z",
  "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",
    "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"
  }
}
```

## Fetch a Sink resource

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

Fetches a Sink configuration by its SID.

### Path parameters

```json
[{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Sink.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch Sink

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchSink() {
  const sink = await client.events.v1
    .sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .fetch();

  console.log(sink.sinkConfiguration);
}

fetchSink();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sink = client.events.v1.sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(sink.sink_configuration)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var sink = await SinkResource.FetchAsync(pathSid: "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(sink.SinkConfiguration);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.Sink;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Sink sink = Sink.fetcher("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch();

        System.out.println(sink.getSinkConfiguration());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.EventsV1.FetchSink("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.SinkConfiguration != nil {
			fmt.Println(*resp.SinkConfiguration)
		} else {
			fmt.Println(resp.SinkConfiguration)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sink = $twilio->events->v1
    ->sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

print $sink->sinkConfiguration;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sink = @client
       .events
       .v1
       .sinks('DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .fetch

puts sink.sink_configuration
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:sinks:fetch \
   --sid DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

```bash
curl -X GET "https://events.twilio.com/v1/Sinks/DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "status": "initialized",
  "sink_configuration": {
    "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
    "role_arn": "arn:aws:iam::111111111:role/Role",
    "external_id": "1234567890"
  },
  "description": "A Sink",
  "sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2015-07-30T20:00:00Z",
  "sink_type": "kinesis",
  "date_updated": "2015-07-30T20:00:00Z",
  "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",
    "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"
  }
}
```

## 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.

### Query parameters

```json
[{"name":"InUse","in":"query","description":"A boolean query parameter filtering the results to return sinks used/not used by a subscription.","schema":{"type":"boolean"},"examples":{"readResultsInUse":{"value":true}}},{"name":"Status","in":"query","description":"A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.","schema":{"type":"string"},"examples":{"readResultsStatus":{"value":"active"}}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 1000.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":1000}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

Read Sink

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listSink() {
  const sinks = await client.events.v1.sinks.list({ limit: 20 });

  sinks.forEach((s) => console.log(s.dateCreated));
}

listSink();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sinks = client.events.v1.sinks.list(limit=20)

for record in sinks:
    print(record.date_created)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var sinks = await SinkResource.ReadAsync(limit: 20);

        foreach (var record in sinks) {
            Console.WriteLine(record.DateCreated);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.Sink;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Sink> sinks = Sink.reader().limit(20).read();

        for (Sink record : sinks) {
            System.out.println(record.getDateCreated());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	events "github.com/twilio/twilio-go/rest/events/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &events.ListSinkParams{}
	params.SetLimit(20)

	resp, err := client.EventsV1.ListSink(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].DateCreated != nil {
				fmt.Println(*resp[record].DateCreated)
			} else {
				fmt.Println(resp[record].DateCreated)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sinks = $twilio->events->v1->sinks->read([], 20);

foreach ($sinks as $record) {
    print $record->dateCreated?->format("r");
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sinks = @client
        .events
        .v1
        .sinks
        .list(limit: 20)

sinks.each do |record|
   puts record.date_created
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:sinks:list
```

```bash
curl -X GET "https://events.twilio.com/v1/Sinks?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sinks": [
    {
      "status": "initialized",
      "sink_configuration": {
        "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
        "role_arn": "arn:aws:iam::111111111:role/Role",
        "external_id": "1234567890"
      },
      "description": "A Sink",
      "sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "date_created": "2015-07-30T19:00:00Z",
      "sink_type": "kinesis",
      "date_updated": "2015-07-30T19:00:00Z",
      "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "links": {
        "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",
        "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"
      }
    },
    {
      "status": "initialized",
      "sink_configuration": {
        "arn": "arn:aws:kinesis:us-east-1:222222222:stream/test",
        "role_arn": "arn:aws:iam::111111111:role/Role",
        "external_id": "1234567890"
      },
      "description": "ANOTHER Sink",
      "sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
      "date_created": "2015-07-30T20:00:00Z",
      "sink_type": "kinesis",
      "date_updated": "2015-07-30T20:00:00Z",
      "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
      "links": {
        "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Test",
        "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Validate"
      }
    },
    {
      "status": "active",
      "sink_configuration": {
        "destination": "http://example.org/webhook",
        "method": "POST",
        "batch_events": true
      },
      "description": "A webhook Sink",
      "sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac",
      "date_created": "2015-07-30T21:00:00Z",
      "sink_type": "webhook",
      "date_updated": "2015-07-30T21:00:00Z",
      "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac",
      "links": {
        "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test",
        "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Validate"
      }
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 20,
    "first_page_url": "https://events.twilio.com/v1/Sinks?PageSize=20&Page=0",
    "previous_page_url": null,
    "url": "https://events.twilio.com/v1/Sinks?PageSize=20&Page=0",
    "next_page_url": null,
    "key": "sinks"
  }
}
```

## Update Sink

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

Updates the description of a Sink

### Path parameters

```json
[{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Sink.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateSinkRequest","required":["Description"],"properties":{"Description":{"type":"string","description":"A human readable description for the Sink **This value should not contain PII.**"}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Description\": \"My Kinesis Sink\"\n}","meta":"","code":"{\n  \"Description\": \"My Kinesis Sink\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Description\"","#7EE787"],[":","#C9D1D9"]," ",["\"My Kinesis Sink\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update Sink

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateSink() {
  const sink = await client.events.v1
    .sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .update({ description: "My Kinesis Sink" });

  console.log(sink.dateCreated);
}

updateSink();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sink = client.events.v1.sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").update(
    description="My Kinesis Sink"
)

print(sink.date_created)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var sink = await SinkResource.UpdateAsync(
            description: "My Kinesis Sink", pathSid: "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(sink.DateCreated);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.Sink;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Sink sink = Sink.updater("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "My Kinesis Sink").update();

        System.out.println(sink.getDateCreated());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	events "github.com/twilio/twilio-go/rest/events/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &events.UpdateSinkParams{}
	params.SetDescription("My Kinesis Sink")

	resp, err := client.EventsV1.UpdateSink("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.DateCreated != nil {
			fmt.Println(*resp.DateCreated)
		} else {
			fmt.Println(resp.DateCreated)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sink = $twilio->events->v1
    ->sinks("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->update(
        "My Kinesis Sink" // Description
    );

print $sink->dateCreated?->format("r");
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sink = @client
       .events
       .v1
       .sinks('DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .update(description: 'My Kinesis Sink')

puts sink.date_created
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:sinks:update \
   --sid DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
   --description "My Kinesis Sink"
```

```bash
curl -X POST "https://events.twilio.com/v1/Sinks/DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "Description=My Kinesis Sink" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "status": "initialized",
  "sink_configuration": {
    "arn": "arn:aws:kinesis:us-east-1:111111111:stream/test",
    "role_arn": "arn:aws:iam::111111111:role/Role",
    "external_id": "1234567890"
  },
  "description": "My Kinesis Sink",
  "sid": "DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2015-07-30T20:00:00Z",
  "sink_type": "kinesis",
  "date_updated": "2015-07-30T20:00:00Z",
  "url": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "sink_test": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test",
    "sink_validate": "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate"
  }
}
```

## 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.

### Path parameters

```json
[{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Sink.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$"},"required":true}]
```

Delete Sink

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function deleteSink() {
  await client.events.v1.sinks("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").remove();
}

deleteSink();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

client.events.v1.sinks("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete()
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        await SinkResource.DeleteAsync(pathSid: "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.Sink;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Sink.deleter("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete();
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	err := client.EventsV1.DeleteSink("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$twilio->events->v1->sinks("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")->delete();
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client
  .events
  .v1
  .sinks('DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:sinks:remove \
   --sid DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
