# Asset Version

Asset Versions are specific instances of static files that you can host at a particular domain in an [Environment](/docs/serverless/api/resource/environment).

The steps to create Assets are as follows:

1. Create an [Asset](/docs/serverless/api/resource/asset)
2. [Create an Asset Version](#create-an-asset-version-resource) (this resource)

You will need the Asset Version SID that the create request returns to include this Asset in a [Build](/docs/serverless/api/resource/build).

## Asset Version properties

```json
{"type":"object","refName":"serverless.v1.service.asset.asset_version","modelName":"serverless_v1_service_asset_asset_version","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZN[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Asset Version 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 Asset Version 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 Asset Version resource is associated with."},"asset_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZH[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Asset resource that is the parent of the Asset Version."},"path":{"type":"string","nullable":true,"description":"The URL-friendly string by which the Asset Version can be referenced. It can be a maximum of 255 characters. All paths begin with a forward slash ('/'). If an Asset Version creation request is submitted with a path not containing a leading slash, the path will automatically be prepended with one.","x-twilio":{"pii":{"handling":"standard","deleteSla":7}}},"visibility":{"type":"string","enum":["public","private","protected"],"description":"The access control that determines how the Asset Version resource can be accessed. Can be:  `public`, `protected`, or `private`.","refName":"asset_version_enum_visibility","modelName":"asset_version_enum_visibility"},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Asset Version resource was created 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 Asset Version resource."}}}
```

## Create an Asset Version resource

Create an **Asset Version** resource to upload a file to an **Asset** resource. The Asset Version resource is created by making a `POST` request to a dedicated URL—a URL that is different from the URL used to read and fetch the resource.

`https://serverless-upload.twilio.com/v1/Services/ {ServiceSid}/Assets/{AssetSid}/Versions`

The following example creates an Asset Version resource using the language of your choice (or curl) and an external file, `my-asset.png`, which contains the Asset to upload.

Upload Asset

```js
const fs = require('fs');
// Before running this code, install "form-data" and "axios" using `npm install form-data axios`
const FormData = require('form-data');
const axios = require('axios');

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See https://twil.io/secure
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;

const serviceSid = 'ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const assetSid = 'ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const serviceUrl = `https://serverless-upload.twilio.com/v1/Services/${serviceSid}`;
const uploadUrl = `${serviceUrl}/Assets/${assetSid}/Versions`;

const form = new FormData();
form.append('Path', '/my-asset.png');
form.append('Visibility', 'public');
form.append('Content', fs.createReadStream('my-asset.png'), {
  contentType: 'image/png',
});

// Create a new Asset Version
axios
  .post(uploadUrl, form, {
    auth: {
      username: apiKey,
      password: apiSecret,
    },
    headers: form.getHeaders(),
  })
  .then((response) => {
    const newVersionSid = response.data.sid;
    console.log(newVersionSid);
  });
```

```py
import os
import json
import requests

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See https://twil.io/secure
api_key = os.environ['TWILIO_API_KEY']
api_secret = os.environ['TWILIO_API_SECRET']

service_sid = 'ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
asset_sid = 'ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

service_url = f'https://serverless-upload.twilio.com/v1/Services/{service_sid}'
upload_url = f'{service_url}/Assets/{asset_sid}/Versions'

file_contents = open('my-asset.png', 'rb')

# Create a new Asset Version
response = requests.post(
    upload_url,
    auth=(api_key, api_secret),
    files={
        'Content': ('my-asset.png', file_contents, 'image/png')
    },
    data={
        'Path': '/my-asset.png',
        'Visibility': 'public',
    },
)

new_version_sid = json.loads(response.text).get("sid")
print(new_version_sid)
```

```cs
using System.Text;
using System.Net.Http.Headers;

class Program
{
  static async Task Main(string[] args)
  {
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See https://twil.io/secure
    var apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
    var apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");

    var serviceSid = "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var assetSid = "ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    var serviceUrl = $"https://serverless-upload.twilio.com/v1/Services/{serviceSid}";
    var uploadUrl = $"{serviceUrl}/Assets/{assetSid}/Versions";

    var client = new HttpClient();
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
        scheme: "Basic",
        Convert.ToBase64String(Encoding.ASCII.GetBytes($"{apiKey}:{apiSecret}"))
    );

    var assetFileName = "my-asset.png";
    var assetPath = $"./{assetFileName}";
    var assetFile = System.IO.File.ReadAllBytes(assetPath);
    var assetFileBytes = new ByteArrayContent(assetFile);

    var boundary = Guid.NewGuid().ToString();
    var requestContent = new MultipartFormDataContent(boundary)
    {
        { assetFileBytes, "Content", assetFileName },
        { new StringContent($"/{assetFileName}"), "Path" },
        { new StringContent("public"), "Visibility" }
    };
    requestContent.Headers.Remove("Content-Type");
    requestContent.Headers.TryAddWithoutValidation("Content-Type", $"multipart/form-data; boundary={boundary}");

    var request = new HttpRequestMessage(HttpMethod.Post, uploadUrl)
    {
        Content = requestContent
    };
    var response = await client.SendAsync(request);

    Console.WriteLine(await response.Content.ReadAsStringAsync());
  }
}
```

```java
package com.example;

import java.io.File;

import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
import kong.unirest.Unirest;
import kong.unirest.json.JSONObject;

public class UploadAsset {
  public static void main(String[] args) {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See https://twil.io/secure
    String TWILIO_API_KEY = System.getenv("TWILIO_API_KEY");
    String TWILIO_API_SECRET = System.getenv("TWILIO_API_SECRET");

    String service_sid = "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String asset_sid = "ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    String service_url = "https://serverless-upload.twilio.com/v1/Services/" + service_sid;
    String upload_url = service_url + "/Assets/" + asset_sid + "/Versions";

    HttpResponse<JsonNode> response = Unirest.post(upload_url)
        .basicAuth(TWILIO_API_KEY, TWILIO_API_SECRET)
        .field("Content", new File("my-asset.png"), "image/png")
        .field("Path", "/my-asset.png")
        .field("Visibility", "public")
        .charset(null)
        .asJson();

    JSONObject asset_version = response.getBody().getObject();
    String asset_version_sid = asset_version.get("sid").toString();
    System.out.println(asset_version_sid);
  }
}
```

```php
<?php

# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See https://twil.io/secure
$api_key = getenv("TWILIO_API_KEY");
$api_secret = getenv("TWILIO_API_SECRET");

$service_sid = "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$asset_sid = "ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://serverless-upload.twilio.com/v1/Services/${service_sid}" .
    "/Assets/${asset_sid}/Versions",
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => array(
    'Content' => new CURLFile(
      'my-asset.png',
      'image/png',
      'my-asset.png'
    ),
    'Path' => '/my-asset.png',
    'Visibility' => 'public'
  ),
  CURLOPT_USERPWD => $api_key . ":" . $api_secret,
  CURLOPT_RETURNTRANSFER => true
));

# Create a new Asset Version
$response = curl_exec($curl);
curl_close($curl);

$data = json_decode($response);
echo $data->sid;
```

```rb
require 'uri'
require 'net/http'
require 'json'

# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See https://twil.io/secure
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']

service_sid = 'ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
asset_sid = 'ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

service_url = "https://serverless-upload.twilio.com/v1/Services/#{service_sid}"
upload_url = URI("#{service_url}/Assets/#{asset_sid}/Versions")

https = Net::HTTP.new(upload_url.host, upload_url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(upload_url)
request.basic_auth api_key, api_secret

form_data = [
  ['Content',
   File.open('my-asset.png'),
   { content_type: 'image/png', filename: 'my-asset.png' }],
  ['Path', '/my-asset.png'],
  %w[Visibility public]
]

request.set_form form_data, 'multipart/form-data'
# Create a new Asset Version
response = https.request(request)
data = JSON.parse(response.read_body)

puts data['sid']
```

```bash
curl -X POST "https://serverless-upload.twilio.com/v1/Services/ZSxxx/Assets/ZHxxx/Versions" \
-F "Content=@my-asset.png; type=image/png" \
-F "Path=/my-asset.png" \
-F "Visibility=public" \
-u "TWILIO_API_KEY:TWILIO_API_SECRET"
```

> \[!WARNING]
>
> Note that the Serverless upload endpoint is on a different subdomain from the rest of the Serverless API (`serverless-upload.twilio.com` instead of `serverless.twilio.com`), and is not supported by the Twilio SDKs at this time.

The `create` action accepts these parameters:

| **Parameter** | **Description**                                                                                           |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| `Content`     | The asset to upload.                                                                                      |
| `AssetSid`    | The SID of the Asset resource to upload this asset to.                                                    |
| `Path`        | The path to assign the asset. Must be URL Friendly, without fragments, and ;,?:@+&$()' " are disallowed). |
| `ServiceSid`  | The SID of the Asset's Service.                                                                           |
| `Visibility`  | The visibility of the asset. Can be `public`, `protected`, or `private`.                                  |

## Fetch an AssetVersion resource

`GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{AssetSid}/Versions/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to fetch the Asset Version resource from.","schema":{"type":"string"},"required":true},{"name":"AssetSid","in":"path","description":"The SID of the Asset resource that is the parent of the Asset Version resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZH[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Asset Version resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZN[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch an Asset Version 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 fetchAssetVersion() {
  const assetVersion = await client.serverless.v1
    .services("ServiceSid")
    .assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .assetVersions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(assetVersion.sid);
}

fetchAssetVersion();
```

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

asset_version = (
    client.serverless.v1.services("ServiceSid")
    .assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .asset_versions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(asset_version.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Asset;
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 assetVersion = await AssetVersionResource.FetchAsync(
            pathServiceSid: "ServiceSid",
            pathAssetSid: "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.asset.AssetVersion;

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);
        AssetVersion assetVersion =
            AssetVersion
                .fetcher("ServiceSid", "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .fetch();

        System.out.println(assetVersion.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.FetchAssetVersion("ServiceSid",
		"ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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);

$asset_version = $twilio->serverless->v1
    ->services("ServiceSid")
    ->assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->assetVersions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

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

asset_version = @client
                .serverless
                .v1
                .services('ServiceSid')
                .assets('ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                .asset_versions('ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                .fetch

puts asset_version.sid
```

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

twilio api:serverless:v1:services:assets:versions:fetch \
   --service-sid ServiceSid \
   --asset-sid ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://serverless.twilio.com/v1/Services/ServiceSid/Assets/ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Versions/ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "asset_sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "path": "/test-path",
  "visibility": "public",
  "date_created": "2018-11-10T20:00:00Z",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions/ZN00000000000000000000000000000000"
}
```

## Read multiple AssetVersion resources

`GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{AssetSid}/Versions`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to read the Asset Version resource from.","schema":{"type":"string"},"required":true},{"name":"AssetSid","in":"path","description":"The SID of the Asset resource that is the parent of the Asset Version resources to read.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZH[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"}}]
```

Read multiple Asset Version 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 listAssetVersion() {
  const assetVersions = await client.serverless.v1
    .services("ServiceSid")
    .assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .assetVersions.list({ limit: 20 });

  assetVersions.forEach((a) => console.log(a.sid));
}

listAssetVersion();
```

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

asset_versions = (
    client.serverless.v1.services("ServiceSid")
    .assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .asset_versions.list(limit=20)
)

for record in asset_versions:
    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.Asset;
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 assetVersions = await AssetVersionResource.ReadAsync(
            pathServiceSid: "ServiceSid",
            pathAssetSid: "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            limit: 20);

        foreach (var record in assetVersions) {
            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.asset.AssetVersion;
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<AssetVersion> assetVersions =
            AssetVersion.reader("ServiceSid", "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").limit(20).read();

        for (AssetVersion record : assetVersions) {
            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.ListAssetVersionParams{}
	params.SetLimit(20)

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

$assetVersions = $twilio->serverless->v1
    ->services("ServiceSid")
    ->assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->assetVersions->read(20);

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

asset_versions = @client
                 .serverless
                 .v1
                 .services('ServiceSid')
                 .assets('ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                 .asset_versions
                 .list(limit: 20)

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

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

twilio api:serverless:v1:services:assets:versions:list \
   --service-sid ServiceSid \
   --asset-sid ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

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

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