Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM

On this page
Looking for more inspiration?Visit the

Asset


Assets are static files that you can host at a particular domain in an Environment.

The steps to create Assets are as follows:

  1. Create an Asset (this resource)
  2. Create an Asset Version

We will need the Asset Version SID to include this Asset in a Build.


Asset Properties

asset-properties page anchor
Property nameTypeRequiredPIIDescriptionChild properties
sidSID<ZH>

Optional

Not PII

The unique string that we created to identify the Asset resource.

Pattern: ^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34

accountSidSID<AC>

Optional

The SID of the Account that created the Asset resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

serviceSidSID<ZS>

Optional

The SID of the Service that the Asset resource is associated with.

Pattern: ^ZS[0-9a-fA-F]{32}$Min length: 34Max length: 34

friendlyNamestring

Optional

PII MTL: 7 days

The string that you assigned to describe the Asset resource. It can be a maximum of 255 characters.


dateUpdatedstring<date-time>

Optional

The date and time in GMT when the Asset resource was last updated specified in ISO 8601(link takes you to an external page) format.


urlstring<uri>

Optional

The absolute URL of the Asset resource.


linksobject<uri-map>

Optional

The URLs of the Asset resource's nested resources.


Create an Asset resource

create-an-asset-resource page anchor

POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
serviceSidstring
required

The SID of the Service to create the Asset resource under.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredPIIDescriptionChild properties
friendlyNamestring
required

A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.

Create a new Asset resourceLink to code sample: Create a new Asset resource
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createAsset() {
11
const asset = await client.serverless.v1
12
.services("ServiceSid")
13
.assets.create({ friendlyName: "FriendlyName" });
14
15
console.log(asset.sid);
16
}
17
18
createAsset();

Response

Note about this response
1
{
2
"sid": "ZH00000000000000000000000000000000",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "ServiceSid",
5
"friendly_name": "FriendlyName",
6
"date_created": "2018-11-10T20:00:00Z",
7
"date_updated": "2018-11-10T20:00:00Z",
8
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
9
"links": {
10
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
11
}
12
}

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

Property nameTypeRequiredPIIDescription
serviceSidstring
required

The SID of the Service to fetch the Asset resource from.


sidSID<ZH>
required

The SID that identifies the Asset resource to fetch.

Pattern: ^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchAsset() {
11
const asset = await client.serverless.v1
12
.services("ServiceSid")
13
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.fetch();
15
16
console.log(asset.sid);
17
}
18
19
fetchAsset();

Response

Note about this response
1
{
2
"sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "ServiceSid",
5
"friendly_name": "test-asset",
6
"date_created": "2018-11-10T20:00:00Z",
7
"date_updated": "2018-11-10T20:00:00Z",
8
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
9
"links": {
10
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
11
}
12
}

Read multiple Asset resources

read-multiple-asset-resources page anchor

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

Property nameTypeRequiredPIIDescription
serviceSidstring
required

The SID of the Service to read the Asset resources from.

Property nameTypeRequiredPIIDescription
pageSizeinteger<int64>

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

pageTokenstring

Optional

The page token. This is provided by the API.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listAsset() {
11
const assets = await client.serverless.v1
12
.services("ServiceSid")
13
.assets.list({ limit: 20 });
14
15
assets.forEach((a) => console.log(a.sid));
16
}
17
18
listAsset();

Response

Note about this response
1
{
2
"assets": [],
3
"meta": {
4
"first_page_url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets?PageSize=50&Page=0",
5
"key": "assets",
6
"next_page_url": null,
7
"page": 0,
8
"page_size": 50,
9
"previous_page_url": null,
10
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets?PageSize=50&Page=0"
11
}
12
}

Update an Asset resource

update-an-asset-resource page anchor

POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}

Property nameTypeRequiredPIIDescription
serviceSidstring
required

The SID of the Service to update the Asset resource from.


sidSID<ZH>
required

The SID that identifies the Asset resource to update.

Pattern: ^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredPIIDescriptionChild properties
friendlyNamestring
required

A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateAsset() {
11
const asset = await client.serverless.v1
12
.services("ServiceSid")
13
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.update({ friendlyName: "FriendlyName" });
15
16
console.log(asset.sid);
17
}
18
19
updateAsset();

Response

Note about this response
1
{
2
"sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "ServiceSid",
5
"friendly_name": "FriendlyName",
6
"date_created": "2018-11-10T20:00:00Z",
7
"date_updated": "2018-11-10T20:00:00Z",
8
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
9
"links": {
10
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
11
}
12
}

Delete an Asset resource

delete-an-asset-resource page anchor

DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}

Property nameTypeRequiredPIIDescription
serviceSidstring
required

The SID of the Service to delete the Asset resource from.


sidSID<ZH>
required

The SID that identifies the Asset resource to delete.

Pattern: ^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteAsset() {
11
await client.serverless.v1
12
.services("ServiceSid")
13
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.remove();
15
}
16
17
deleteAsset();