# Deployment

Deployments let you set a particular [Build](/docs/serverless/api/resource/build) to be live on a particular [Environment](/docs/serverless/api/resource/environment).

## Deployment Properties

```json
{"type":"object","refName":"serverless.v1.service.environment.deployment","modelName":"serverless_v1_service_environment_deployment","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZD[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Deployment resource."},"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 Deployment resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Service that the Deployment resource is associated with."},"environment_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZE[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Environment for the Deployment."},"build_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZB[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Build for the deployment."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Deployment 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 Deployment resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Deployment resource."}}}
```

## Create a Deployment resource

`POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Deployments`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to create the Deployment resource under.","schema":{"type":"string"},"required":true},{"name":"EnvironmentSid","in":"path","description":"The SID of the Environment for the Deployment.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZE[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateDeploymentRequest","properties":{"BuildSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZB[0-9a-fA-F]{32}$","description":"The SID of the Build for the Deployment."},"IsPlugin":{"type":"boolean","description":"Whether the Deployment is a plugin."}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"BuildSid\": \"ZB00000000000000000000000000000000\",\n  \"IsPlugin\": false\n}","meta":"","code":"{\n  \"BuildSid\": \"ZB00000000000000000000000000000000\",\n  \"IsPlugin\": false\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"BuildSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"ZB00000000000000000000000000000000\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"IsPlugin\"","#7EE787"],[":","#C9D1D9"]," ",["false","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a Deployment

```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 createDeployment() {
  const deployment = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.create({ buildSid: "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });

  console.log(deployment.sid);
}

createDeployment();
```

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

deployment = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.create(build_sid="ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
)

print(deployment.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Environment;
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 deployment = await DeploymentResource.CreateAsync(
            buildSid: "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.environment.Deployment;

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);
        Deployment deployment = Deployment.creator("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                    .setBuildSid("ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                    .create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	serverless "github.com/twilio/twilio-go/rest/serverless/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 := &serverless.CreateDeploymentParams{}
	params.SetBuildSid("ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

	resp, err := client.ServerlessV1.CreateDeployment("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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);

$deployment = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->deployments->create(["buildSid" => "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]);

print $deployment->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)

deployment = @client
             .serverless
             .v1
             .services('ServiceSid')
             .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .deployments
             .create(build_sid: 'ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')

puts deployment.sid
```

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

twilio api:serverless:v1:services:environments:deployments:create \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --build-sid ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

```bash
curl -X POST "https://serverless.twilio.com/v1/Services/ServiceSid/Environments/ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments" \
--data-urlencode "BuildSid=ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "ZD00000000000000000000000000000000",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "build_sid": "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments/ZD00000000000000000000000000000000"
}
```

> \[!NOTE]
>
> `POST`ing to the deployment endpoint without a Build SID will delete any existing deployments in that Environment. Calls to Functions & Assets that were hosted by that Environment will result in 404s.

Clear all Deployments from an Environment

```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 createDeployment() {
  const deployment = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.create();

  console.log(deployment.sid);
}

createDeployment();
```

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

deployment = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.create()
)

print(deployment.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Environment;
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 deployment = await DeploymentResource.CreateAsync(
            pathServiceSid: "ServiceSid", pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.environment.Deployment;

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);
        Deployment deployment = Deployment.creator("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").create();

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

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

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

	resp, err := client.ServerlessV1.CreateDeployment("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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);

$deployment = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->deployments->create();

print $deployment->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)

deployment = @client
             .serverless
             .v1
             .services('ServiceSid')
             .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .deployments
             .create

puts deployment.sid
```

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

twilio api:serverless:v1:services:environments:deployments:create \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X POST "https://serverless.twilio.com/v1/Services/ServiceSid/Environments/ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "ZD00000000000000000000000000000000",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "build_sid": "ZB00000000000000000000000000000000",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments/ZD00000000000000000000000000000000"
}
```

## Fetch a Deployment resource

`GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Deployments/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to fetch the Deployment resource from.","schema":{"type":"string"},"required":true},{"name":"EnvironmentSid","in":"path","description":"The SID of the Environment used by the Deployment to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZE[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID that identifies the Deployment resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZD[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch a Deployment

```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 fetchDeployment() {
  const deployment = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments("ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(deployment.sid);
}

fetchDeployment();
```

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

deployment = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments("ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(deployment.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Environment;
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 deployment = await DeploymentResource.FetchAsync(
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.environment.Deployment;

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);
        Deployment deployment =
            Deployment.fetcher("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .fetch();

        System.out.println(deployment.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.ServerlessV1.FetchDeployment("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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);

$deployment = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->deployments("ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $deployment->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)

deployment = @client
             .serverless
             .v1
             .services('ServiceSid')
             .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .deployments('ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .fetch

puts deployment.sid
```

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

twilio api:serverless:v1:services:environments:deployments:fetch \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://serverless.twilio.com/v1/Services/ServiceSid/Environments/ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "ZDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "build_sid": "ZB00000000000000000000000000000000",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments/ZD00000000000000000000000000000000"
}
```

## Read multiple Deployment resources

`GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Deployments`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to read the Deployment resources from.","schema":{"type":"string"},"required":true},{"name":"EnvironmentSid","in":"path","description":"The SID of the Environment used by the Deployment resources to read.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZE[0-9a-fA-F]{32}$"},"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 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"}}]
```

List multiple Deployments

```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 listDeployment() {
  const deployments = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.list({ limit: 20 });

  deployments.forEach((d) => console.log(d.sid));
}

listDeployment();
```

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

deployments = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .deployments.list(limit=20)
)

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

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

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Environment;
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 deployments = await DeploymentResource.ReadAsync(
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            limit: 20);

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

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

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.environment.Deployment;
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<Deployment> deployments =
            Deployment.reader("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").limit(20).read();

        for (Deployment record : deployments) {
            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"
	serverless "github.com/twilio/twilio-go/rest/serverless/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 := &serverless.ListDeploymentParams{}
	params.SetLimit(20)

	resp, err := client.ServerlessV1.ListDeployment("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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);

$deployments = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->deployments->read(20);

foreach ($deployments 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)

deployments = @client
              .serverless
              .v1
              .services('ServiceSid')
              .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
              .deployments
              .list(limit: 20)

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

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

twilio api:serverless:v1:services:environments:deployments:list \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

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

```json
{
  "deployments": [],
  "meta": {
    "first_page_url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments?PageSize=50&Page=0",
    "key": "deployments",
    "next_page_url": null,
    "page": 0,
    "page_size": 50,
    "previous_page_url": null,
    "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments?PageSize=50&Page=0"
  }
}
```
