# Stream Resource

A Stream is a pub-sub primitive that lets you broadcast JSON messages at a high rate to an elastic group of subscribers.

* Messages are ephemeral - they can be published (created), but they cannot be queried, updated or deleted
* The maximum Message payload size as serialized JSON is 4KB.
* The maximum Message publishing rate per Stream is 30 per second.
* Message delivery to remote endpoints is not guaranteed.
* Messages may be received by remote endpoints in a different order than they were published.

See also [Stream Message](/docs/sync/api/stream-message-resource) for information about the messages in a stream.

## Sync Stream properties

```json
{"type":"object","refName":"sync.v1.service.sync_stream","modelName":"sync_v1_service_sync_stream","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TO[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Sync Stream resource."},"unique_name":{"type":"string","nullable":true,"description":"An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the Sync Stream resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Sync Service](/docs/sync/api/service) the resource is associated with."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Message Stream resource."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"The URLs of the Stream's nested resources."},"date_expires":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Message Stream expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Message Stream does not expire, this value is `null`. The Stream might not be deleted immediately after it expires."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"created_by":{"type":"string","nullable":true,"description":"The identity of the Stream's creator. If the Stream is created from the client SDK, the value matches the Access Token's `identity` field. If the Stream was created from the REST API, the value is 'system'.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}}
```

## Create a Sync Stream resource

`POST https://sync.twilio.com/v1/Services/{ServiceSid}/Streams`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) to create the new Stream in.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateSyncStreamRequest","properties":{"UniqueName":{"type":"string","description":"An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"Ttl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live)."}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"UniqueName\": \"unique_name\",\n  \"Ttl\": 3600\n}","meta":"","code":"{\n  \"UniqueName\": \"unique_name\",\n  \"Ttl\": 3600\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"UniqueName\"","#7EE787"],[":","#C9D1D9"]," ",["\"unique_name\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["3600","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a Sync Stream resource

```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 createSyncStream() {
  const syncStream = await client.sync.v1
    .services("ServiceSid")
    .syncStreams.create();

  console.log(syncStream.sid);
}

createSyncStream();
```

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

sync_stream = client.sync.v1.services("ServiceSid").sync_streams.create()

print(sync_stream.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;
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 syncStream = await SyncStreamResource.CreateAsync(pathServiceSid: "ServiceSid");

        Console.WriteLine(syncStream.Sid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.SyncStream;

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);
        SyncStream syncStream = SyncStream.creator("ServiceSid").create();

        System.out.println(syncStream.getSid());
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/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 := &sync.CreateSyncStreamParams{}

	resp, err := client.SyncV1.CreateSyncStream("ServiceSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

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

$sync_stream = $twilio->sync->v1->services("ServiceSid")->syncStreams->create();

print $sync_stream->sid;
```

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

sync_stream = @client
              .sync
              .v1
              .services('ServiceSid')
              .sync_streams
              .create

puts sync_stream.sid
```

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

twilio api:sync:v1:services:streams:create \
   --service-sid ServiceSid
```

```bash
curl -X POST "https://sync.twilio.com/v1/Services/ServiceSid/Streams" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "links": {
    "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages"
  },
  "service_sid": "ServiceSid",
  "sid": "TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch a Sync Stream resource

`GET https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Stream resource to fetch.","schema":{"type":"string"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Stream resource to fetch.","schema":{"type":"string"},"required":true}]
```

Fetch a Sync Stream resource

```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 fetchSyncStream() {
  const syncStream = await client.sync.v1
    .services("ServiceSid")
    .syncStreams("Sid")
    .fetch();

  console.log(syncStream.sid);
}

fetchSyncStream();
```

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

sync_stream = client.sync.v1.services("ServiceSid").sync_streams("Sid").fetch()

print(sync_stream.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;
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 syncStream =
            await SyncStreamResource.FetchAsync(pathServiceSid: "ServiceSid", pathSid: "Sid");

        Console.WriteLine(syncStream.Sid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.SyncStream;

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);
        SyncStream syncStream = SyncStream.fetcher("ServiceSid", "Sid").fetch();

        System.out.println(syncStream.getSid());
    }
}
```

```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.SyncV1.FetchSyncStream("ServiceSid",
		"Sid")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

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

$sync_stream = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncStreams("Sid")
    ->fetch();

print $sync_stream->sid;
```

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

sync_stream = @client
              .sync
              .v1
              .services('ServiceSid')
              .sync_streams('Sid')
              .fetch

puts sync_stream.sid
```

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

twilio api:sync:v1:services:streams:fetch \
   --service-sid ServiceSid \
   --sid Sid
```

```bash
curl -X GET "https://sync.twilio.com/v1/Services/ServiceSid/Streams/Sid" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "links": {
    "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages"
  },
  "service_sid": "ServiceSid",
  "sid": "Sid",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Read multiple Sync Stream resources

`GET https://sync.twilio.com/v1/Services/{ServiceSid}/Streams`

**Note:** Without a `PageSize` query parameter, this will return only the first 50 Message Streams. Add a `PageSize` query parameter to fetch up to 100 items at once. The example has a `PageSize` value of 20.

See [paging](/docs/usage/twilios-response#pagination) for more information.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Stream resources to read.","schema":{"type":"string"},"required":true}]
```

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 100.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":100}},{"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 multiple Sync Stream resources

```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 listSyncStream() {
  const syncStreams = await client.sync.v1
    .services("ServiceSid")
    .syncStreams.list({ limit: 20 });

  syncStreams.forEach((s) => console.log(s.sid));
}

listSyncStream();
```

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

sync_streams = client.sync.v1.services("ServiceSid").sync_streams.list(limit=20)

for record in sync_streams:
    print(record.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;
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 syncStreams =
            await SyncStreamResource.ReadAsync(pathServiceSid: "ServiceSid", limit: 20);

        foreach (var record in syncStreams) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.SyncStream;
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<SyncStream> syncStreams = SyncStream.reader("ServiceSid").limit(20).read();

        for (SyncStream record : syncStreams) {
            System.out.println(record.getSid());
        }
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/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 := &sync.ListSyncStreamParams{}
	params.SetLimit(20)

	resp, err := client.SyncV1.ListSyncStream("ServiceSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Sid != nil {
				fmt.Println(*resp[record].Sid)
			} else {
				fmt.Println(resp[record].Sid)
			}
		}
	}
}
```

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

$syncStreams = $twilio->sync->v1->services("ServiceSid")->syncStreams->read(20);

foreach ($syncStreams as $record) {
    print $record->sid;
}
```

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

sync_streams = @client
               .sync
               .v1
               .services('ServiceSid')
               .sync_streams
               .list(limit: 20)

sync_streams.each do |record|
   puts record.sid
end
```

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

twilio api:sync:v1:services:streams:list \
   --service-sid ServiceSid
```

```bash
curl -X GET "https://sync.twilio.com/v1/Services/ServiceSid/Streams?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "streams": [],
  "meta": {
    "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0",
    "key": "streams",
    "next_page_url": null,
    "page": 0,
    "page_size": 50,
    "previous_page_url": null,
    "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0"
  }
}
```

## Update a Sync Stream resource

`POST https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Stream resource to update.","schema":{"type":"string"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Stream resource to update.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateSyncStreamRequest","properties":{"Ttl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live)."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Ttl\": 3600\n}","meta":"","code":"{\n  \"Ttl\": 3600\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["3600","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a Sync Stream resource

```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 updateSyncStream() {
  const syncStream = await client.sync.v1
    .services("ServiceSid")
    .syncStreams("Sid")
    .update({ ttl: 42 });

  console.log(syncStream.sid);
}

updateSyncStream();
```

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

sync_stream = (
    client.sync.v1.services("ServiceSid").sync_streams("Sid").update(ttl=42)
)

print(sync_stream.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;
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 syncStream = await SyncStreamResource.UpdateAsync(
            ttl: 42, pathServiceSid: "ServiceSid", pathSid: "Sid");

        Console.WriteLine(syncStream.Sid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.SyncStream;

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);
        SyncStream syncStream = SyncStream.updater("ServiceSid", "Sid").setTtl(42).update();

        System.out.println(syncStream.getSid());
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/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 := &sync.UpdateSyncStreamParams{}
	params.SetTtl(42)

	resp, err := client.SyncV1.UpdateSyncStream("ServiceSid",
		"Sid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

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

$sync_stream = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncStreams("Sid")
    ->update(["ttl" => 42]);

print $sync_stream->sid;
```

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

sync_stream = @client
              .sync
              .v1
              .services('ServiceSid')
              .sync_streams('Sid')
              .update(ttl: 42)

puts sync_stream.sid
```

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

twilio api:sync:v1:services:streams:update \
   --service-sid ServiceSid \
   --sid Sid \
   --ttl 42
```

```bash
curl -X POST "https://sync.twilio.com/v1/Services/ServiceSid/Streams/Sid" \
--data-urlencode "Ttl=42" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "links": {
    "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages"
  },
  "service_sid": "ServiceSid",
  "sid": "Sid",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete a Sync Stream resource

`DELETE https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Stream resource to delete.","schema":{"type":"string"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Stream resource to delete.","schema":{"type":"string"},"required":true}]
```

Delete a Sync Stream resource

```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 deleteSyncStream() {
  await client.sync.v1.services("ServiceSid").syncStreams("Sid").remove();
}

deleteSyncStream();
```

```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.sync.v1.services("ServiceSid").sync_streams("Sid").delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;
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 SyncStreamResource.DeleteAsync(pathServiceSid: "ServiceSid", pathSid: "Sid");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.SyncStream;

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);
        SyncStream.deleter("ServiceSid", "Sid").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.SyncV1.DeleteSyncStream("ServiceSid",
		"Sid")
	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->sync->v1
    ->services("ServiceSid")
    ->syncStreams("Sid")
    ->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
  .sync
  .v1
  .services('ServiceSid')
  .sync_streams('Sid')
  .delete
```

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

twilio api:sync:v1:services:streams:remove \
   --service-sid ServiceSid \
   --sid Sid
```

```bash
curl -X DELETE "https://sync.twilio.com/v1/Services/ServiceSid/Streams/Sid" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
