# 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](/docs/events/event-streams/subscription/subscribed-event-api).

## Subscription Properties

```json
{"type":"object","refName":"events.v1.subscription","modelName":"events_v1_subscription","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Account."},"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DF[0-9a-fA-F]{32}$","nullable":true,"description":"A 34 character string that uniquely identifies this Subscription."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Subscription was created, given in ISO 8601 format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Subscription was updated, given in ISO 8601 format."},"description":{"type":"string","nullable":true,"description":"A human readable description for the Subscription"},"sink_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$","nullable":true,"description":"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."},"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 Subscription."}}}
```

## Create a Subscription

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

Make a new Subscription.

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateSubscriptionRequest","required":["Description","SinkSid","Types"],"properties":{"Description":{"type":"string","description":"A human readable description for the Subscription **This value should not contain PII.**"},"SinkSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$","description":"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."},"Types":{"type":"array","description":"An array of objects containing the subscribed Event Types"}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"SinkSid\": \"DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Description\": \"A subscription\",\n  \"Types\": [\n    \"{\\\"type\\\": \\\"com.twilio.messaging.message.delivered\\\",\\\"schema_version\\\": 1}\",\n    \"{\\\"type\\\": \\\"com.twilio.messaging.message.failed\\\",\\\"schema_version\\\": 12}\"\n  ],\n  \"Filter\": \"messageStatus == 'FAILED' AND errorCode == 30004\"\n}","meta":"","code":"{\n  \"SinkSid\": \"DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"Description\": \"A subscription\",\n  \"Types\": [\n    \"{\\\"type\\\": \\\"com.twilio.messaging.message.delivered\\\",\\\"schema_version\\\": 1}\",\n    \"{\\\"type\\\": \\\"com.twilio.messaging.message.failed\\\",\\\"schema_version\\\": 12}\"\n  ],\n  \"Filter\": \"messageStatus == 'FAILED' AND errorCode == 30004\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"SinkSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Description\"","#7EE787"],[":","#C9D1D9"]," ",["\"A subscription\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Types\"","#7EE787"],[": [","#C9D1D9"],"\n    ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["type","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["com.twilio.messaging.message.delivered","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"],["\\\"","#79C0FF"],["schema_version","#A5D6FF"],["\\\"","#79C0FF"],[": 1}\"","#A5D6FF"],[",","#C9D1D9"],"\n    ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["type","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["com.twilio.messaging.message.failed","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"],["\\\"","#79C0FF"],["schema_version","#A5D6FF"],["\\\"","#79C0FF"],[": 12}\"","#A5D6FF"],"\n  ",["],","#C9D1D9"],"\n  ",["\"Filter\"","#7EE787"],[":","#C9D1D9"]," ",["\"messageStatus == 'FAILED' AND errorCode == 30004\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a new Subscription

```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 createSubscription() {
  const subscription = await client.events.v1.subscriptions.create({
    description: '"A subscription"',
    sinkSid: "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    types: [
      {
        type: "com.twilio.messaging.message.delivered",
      },
      {
        type: "com.twilio.messaging.message.sent",
        schema_version: 2,
      },
    ],
  });

  console.log(subscription.accountSid);
}

createSubscription();
```

```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)

subscription = client.events.v1.subscriptions.create(
    types=[
        {"type": "com.twilio.messaging.message.delivered"},
        {"type": "com.twilio.messaging.message.sent", "schema_version": 2},
    ],
    description='"A subscription"',
    sink_sid="DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)

print(subscription.account_sid)
```

```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 subscription = await SubscriptionResource.CreateAsync(
            types: new List<
                Object> { new Dictionary<string, Object>() { { "type", "com.twilio.messaging.message.delivered" } }, new Dictionary<string, Object>() { { "type", "com.twilio.messaging.message.sent" }, { "schema_version", 2 } } },
            description: "\"A subscription\"",
            sinkSid: "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(subscription.AccountSid);
    }
}
```

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

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

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);
        Subscription subscription = Subscription
                                        .creator("\"A subscription\"",
                                            "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                                            Arrays.asList(
                                                new HashMap<String, Object>() {
                                                    {
                                                        put("type", "com.twilio.messaging.message.delivered");
                                                    }
                                                },
                                                new HashMap<String, Object>() {
                                                    {
                                                        put("type", "com.twilio.messaging.message.sent");
                                                        put("schema_version", 2);
                                                    }
                                                }))
                                        .create();

        System.out.println(subscription.getAccountSid());
    }
}
```

```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.CreateSubscriptionParams{}
	params.SetTypes([]interface{}{
		map[string]interface{}{
			"type": "com.twilio.messaging.message.delivered",
		},
		map[string]interface{}{
			"type":           "com.twilio.messaging.message.sent",
			"schema_version": 2,
		},
	})
	params.SetDescription("\"A subscription\"")
	params.SetSinkSid("DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

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

```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);

$subscription = $twilio->events->v1->subscriptions->create(
    "\"A subscription\"", // Description
    "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", // SinkSid
    [
        [
            "type" => "com.twilio.messaging.message.delivered",
        ],
        [
            "type" => "com.twilio.messaging.message.sent",
            "schema_version" => 2,
        ],
    ] // Types
);

print $subscription->accountSid;
```

```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)

subscription = @client
               .events
               .v1
               .subscriptions
               .create(
                 types: [
                   {
                     'type' => 'com.twilio.messaging.message.delivered'
                   },
                   {
                     'type' => 'com.twilio.messaging.message.sent',
                     'schema_version' => 2
                   }
                 ],
                 description: '"A subscription"',
                 sink_sid: 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
               )

puts subscription.account_sid
```

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

twilio api:events:v1:subscriptions:create \
   --types "{\"type\":\"com.twilio.messaging.message.delivered\"}" "{\"type\":\"com.twilio.messaging.message.sent\",\"schema_version\":2}" \
   --description "\"A subscription\"" \
   --sink-sid DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X POST "https://events.twilio.com/v1/Subscriptions" \
--data-urlencode "Types={\"type\":\"com.twilio.messaging.message.delivered\"}" \
--data-urlencode "Types={\"type\":\"com.twilio.messaging.message.sent\",\"schema_version\":2}" \
--data-urlencode "Description=\"A subscription\"" \
--data-urlencode "SinkSid=DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:01:33Z",
  "sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sink_sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "description": "\"A subscription\"",
  "url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents"
  }
}
```

## Fetch a Subscription

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

Retrieve a specific Subscription using its Subscription ID.

### Path parameters

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

Fetch Subscription

```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 fetchSubscription() {
  const subscription = await client.events.v1
    .subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(subscription.accountSid);
}

fetchSubscription();
```

```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)

subscription = client.events.v1.subscriptions(
    "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).fetch()

print(subscription.account_sid)
```

```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 subscription =
            await SubscriptionResource.FetchAsync(pathSid: "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(subscription.AccountSid);
    }
}
```

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

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

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);
        Subscription subscription = Subscription.fetcher("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

        System.out.println(subscription.getAccountSid());
    }
}
```

```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.FetchSubscription("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.AccountSid != nil {
			fmt.Println(*resp.AccountSid)
		} else {
			fmt.Println(resp.AccountSid)
		}
	}
}
```

```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);

$subscription = $twilio->events->v1
    ->subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $subscription->accountSid;
```

```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)

subscription = @client
               .events
               .v1
               .subscriptions('DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .fetch

puts subscription.account_sid
```

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

twilio api:events:v1:subscriptions:fetch \
   --sid DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

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

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:01:33Z",
  "sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sink_sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "description": "A subscription",
  "url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents"
  }
}
```

## Get all Subscriptions

`GET https://events.twilio.com/v1/Subscriptions`

Retrieve information on all created subscriptions

### Query parameters

```json
[{"name":"SinkSid","in":"query","description":"The SID of the sink that the list of Subscriptions should be filtered by.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^DG[0-9a-fA-F]{32}$"},"examples":{"readResultsFilteredBySinkSid":{"value":"DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}}},{"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 Subscriptions

```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 listSubscription() {
  const subscriptions = await client.events.v1.subscriptions.list({
    limit: 20,
  });

  subscriptions.forEach((s) => console.log(s.accountSid));
}

listSubscription();
```

```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)

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

for record in subscriptions:
    print(record.account_sid)
```

```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 subscriptions = await SubscriptionResource.ReadAsync(limit: 20);

        foreach (var record in subscriptions) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.events.v1.Subscription;
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<Subscription> subscriptions = Subscription.reader().limit(20).read();

        for (Subscription record : subscriptions) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

```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.ListSubscriptionParams{}
	params.SetLimit(20)

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

```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);

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

foreach ($subscriptions as $record) {
    print $record->accountSid;
}
```

```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)

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

subscriptions.each do |record|
   puts record.account_sid
end
```

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

twilio api:events:v1:subscriptions:list
```

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

```json
{
  "subscriptions": [
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "date_created": "2015-07-30T20:00:00Z",
      "date_updated": "2015-07-30T20:01:33Z",
      "sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "sink_sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "description": "A subscription",
      "url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "links": {
        "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents"
      }
    },
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "date_created": "2015-07-30T20:00:00Z",
      "date_updated": "2015-07-30T20:01:33Z",
      "sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
      "sink_sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "description": "Another subscription",
      "url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
      "links": {
        "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/SubscribedEvents"
      }
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 20,
    "first_page_url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=0",
    "previous_page_url": null,
    "url": "https://events.twilio.com/v1/Subscriptions?PageSize=20&Page=0",
    "next_page_url": null,
    "key": "subscriptions"
  }
}
```

## Update a Subscription

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

Modify an existing Subscription identified by its Subscription ID.

### Path parameters

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

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateSubscriptionRequest","properties":{"Description":{"type":"string","description":"A human readable description for the Subscription."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Description\": \"Updated description\",\n  \"Filter\": \"messageStatus == 'FAILED' AND errorCode == 30004\"\n}","meta":"","code":"{\n  \"Description\": \"Updated description\",\n  \"Filter\": \"messageStatus == 'FAILED' AND errorCode == 30004\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Description\"","#7EE787"],[":","#C9D1D9"]," ",["\"Updated description\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Filter\"","#7EE787"],[":","#C9D1D9"]," ",["\"messageStatus == 'FAILED' AND errorCode == 30004\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Change subscription description

```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 updateSubscription() {
  const subscription = await client.events.v1
    .subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update({ description: '"Updated description"' });

  console.log(subscription.accountSid);
}

updateSubscription();
```

```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)

subscription = client.events.v1.subscriptions(
    "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).update(description='"Updated description"')

print(subscription.account_sid)
```

```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 subscription = await SubscriptionResource.UpdateAsync(
            description: "\"Updated description\"", pathSid: "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(subscription.AccountSid);
    }
}
```

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

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

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);
        Subscription subscription = Subscription.updater("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                        .setDescription("\"Updated description\"")
                                        .update();

        System.out.println(subscription.getAccountSid());
    }
}
```

```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.UpdateSubscriptionParams{}
	params.SetDescription("\"Updated description\"")

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

```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);

$subscription = $twilio->events->v1
    ->subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->update(["description" => "\"Updated description\""]);

print $subscription->accountSid;
```

```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)

subscription = @client
               .events
               .v1
               .subscriptions('DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .update(description: '"Updated description"')

puts subscription.account_sid
```

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

twilio api:events:v1:subscriptions:update \
   --sid DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --description "\"Updated description\""
```

```bash
curl -X POST "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--data-urlencode "Description=\"Updated description\"" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2020-07-30T20:01:33Z",
  "sid": "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sink_sid": "DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
  "description": "\"Updated description\"",
  "url": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "subscribed_events": "https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents"
  }
}
```

## Delete a Subscription

`DELETE https://events.twilio.com/v1/Subscriptions/{Sid}`

Remove a Subscription identified by its Subscription ID.

### Path parameters

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

Delete Subscription

```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 deleteSubscription() {
  await client.events.v1
    .subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .remove();
}

deleteSubscription();
```

```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.subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").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 SubscriptionResource.DeleteAsync(pathSid: "DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

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

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);
        Subscription.deleter("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").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.DeleteSubscription("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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
    ->subscriptions("DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->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
  .subscriptions('DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:events:v1:subscriptions:remove \
   --sid DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

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