# Variable

Variables are key/value pairs that you can add to a specific [Environment](/docs/serverless/api/resource/environment). Use these for storing configuration like API keys rather than hardcoding them into your [Functions](/docs/serverless/api/resource/function). Environment Variables are encrypted, so they are the preferred way to store API keys, passwords, and any other secrets that your Function needs to use.

## Variable Properties

```json
{"type":"object","refName":"serverless.v1.service.environment.variable","modelName":"serverless_v1_service_environment_variable","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZV[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Variable 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 Variable 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 Variable 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 in which the Variable exists."},"key":{"type":"string","nullable":true,"description":"A string by which the Variable resource can be referenced.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}},"value":{"type":"string","nullable":true,"description":"A string that contains the actual value of the Variable.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Variable 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 Variable 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 Variable resource."}}}
```

## Create a Variable resource

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

### Path parameters

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

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateVariableRequest","required":["Key","Value"],"properties":{"Key":{"type":"string","description":"A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}},"Value":{"type":"string","description":"A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Key\": \"new-key\",\n  \"Value\": \"new-value\"\n}","meta":"","code":"{\n  \"Key\": \"new-key\",\n  \"Value\": \"new-value\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Key\"","#7EE787"],[":","#C9D1D9"]," ",["\"new-key\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Value\"","#7EE787"],[":","#C9D1D9"]," ",["\"new-value\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a Variable

```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 createVariable() {
  const variable = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables.create({
      key: "Key",
      value: "Value",
    });

  console.log(variable.sid);
}

createVariable();
```

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

variable = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables.create(key="Key", value="Value")
)

print(variable.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 variable = await VariableResource.CreateAsync(
            key: "Key",
            value: "Value",
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(variable.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.Variable;

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);
        Variable variable =
            Variable.creator("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Key", "Value").create();

        System.out.println(variable.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.CreateVariableParams{}
	params.SetKey("Key")
	params.SetValue("Value")

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

$variable = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->variables->create(
        "Key", // Key
        "Value" // Value
    );

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

variable = @client
           .serverless
           .v1
           .services('ServiceSid')
           .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
           .variables
           .create(
             key: 'Key',
             value: 'Value'
           )

puts variable.sid
```

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

twilio api:serverless:v1:services:environments:variables:create \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --key Key \
   --value Value
```

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

```json
{
  "sid": "ZV00000000000000000000000000000000",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "key": "Key",
  "value": "Value",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
}
```

## Fetch a Variable resource

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

### Path parameters

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

Fetch a Variable

```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 fetchVariable() {
  const variable = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(variable.sid);
}

fetchVariable();
```

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

variable = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(variable.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 variable = await VariableResource.FetchAsync(
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(variable.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.Variable;

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);
        Variable variable =
            Variable.fetcher("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .fetch();

        System.out.println(variable.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.FetchVariable("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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);

$variable = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

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

variable = @client
           .serverless
           .v1
           .services('ServiceSid')
           .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
           .variables('ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
           .fetch

puts variable.sid
```

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

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

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

```json
{
  "sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "key": "test-key",
  "value": "test-value",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
}
```

## Read multiple Variable resources

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

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to read the Variable resources from.","schema":{"type":"string"},"required":true},{"name":"EnvironmentSid","in":"path","description":"The SID of the Environment with the Variable 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 Variables

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

  variables.forEach((v) => console.log(v.sid));
}

listVariable();
```

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

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

for record in variables:
    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 variables = await VariableResource.ReadAsync(
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            limit: 20);

        foreach (var record in variables) {
            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.Variable;
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<Variable> variables =
            Variable.reader("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").limit(20).read();

        for (Variable record : variables) {
            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.ListVariableParams{}
	params.SetLimit(20)

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

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

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

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

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

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

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

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

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

## Update a Variable resource

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

### Path parameters

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

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateVariableRequest","properties":{"Key":{"type":"string","description":"A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}},"Value":{"type":"string","description":"A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Key\": \"update-key\",\n  \"Value\": \"update-value\"\n}","meta":"","code":"{\n  \"Key\": \"update-key\",\n  \"Value\": \"update-value\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Key\"","#7EE787"],[":","#C9D1D9"]," ",["\"update-key\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Value\"","#7EE787"],[":","#C9D1D9"]," ",["\"update-value\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a Variable

```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 updateVariable() {
  const variable = await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update({ key: "Key" });

  console.log(variable.sid);
}

updateVariable();
```

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

variable = (
    client.serverless.v1.services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update(key="Key")
)

print(variable.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 variable = await VariableResource.UpdateAsync(
            key: "Key",
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(variable.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.Variable;

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);
        Variable variable =
            Variable.updater("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .setKey("Key")
                .update();

        System.out.println(variable.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.UpdateVariableParams{}
	params.SetKey("Key")

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

$variable = $twilio->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->update(["key" => "Key"]);

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

variable = @client
           .serverless
           .v1
           .services('ServiceSid')
           .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
           .variables('ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
           .update(key: 'Key')

puts variable.sid
```

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

twilio api:serverless:v1:services:environments:variables:update \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --key Key
```

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

```json
{
  "sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "key": "Key",
  "value": "update-value",
  "date_created": "2018-11-10T20:00:00Z",
  "date_updated": "2018-11-11T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
}
```

## Delete a Variable resource

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

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to delete the Variable resource from.","schema":{"type":"string"},"required":true},{"name":"EnvironmentSid","in":"path","description":"The SID of the Environment with the Variables to delete.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZE[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Variable resource to delete.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZV[0-9a-fA-F]{32}$"},"required":true}]
```

Delete a Variable

```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 deleteVariable() {
  await client.serverless.v1
    .services("ServiceSid")
    .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .remove();
}

deleteVariable();
```

```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.serverless.v1.services("ServiceSid").environments(
    "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete()
```

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

        await VariableResource.DeleteAsync(
            pathServiceSid: "ServiceSid",
            pathEnvironmentSid: "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

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

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);
        Variable.deleter("ServiceSid", "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
            .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.ServerlessV1.DeleteVariable("ServiceSid",
		"ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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->serverless->v1
    ->services("ServiceSid")
    ->environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->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
  .serverless
  .v1
  .services('ServiceSid')
  .environments('ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .variables('ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:serverless:v1:services:environments:variables:remove \
   --service-sid ServiceSid \
   --environment-sid ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

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