Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

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 nameTypePIIDescription
sidSID<ZH>
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

account_sidSID<AC>

The SID of the Account that created the Asset resource.

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

service_sidSID<ZS>

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

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

friendly_namestring
PII MTL: 7 days

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


date_updatedstring<date-time>

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>

The absolute URL of the Asset resource.


linksobject<uri-map>

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
ServiceSidstringrequired

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

Property nameTypeRequiredPIIDescription
FriendlyNamestringrequired

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

Create an Asset

create-an-asset page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const asset = await client.serverless.v1
_14
.services("ServiceSid")
_14
.assets.create({ friendlyName: "FriendlyName" });
_14
_14
console.log(asset.sid);

Output

_12
{
_12
"sid": "ZH00000000000000000000000000000000",
_12
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"service_sid": "ServiceSid",
_12
"friendly_name": "FriendlyName",
_12
"date_created": "2018-11-10T20:00:00Z",
_12
"date_updated": "2018-11-10T20:00:00Z",
_12
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
_12
"links": {
_12
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
_12
}
_12
}


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

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

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
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
import twilio from "twilio";
_15
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = twilio(accountSid, authToken);
_15
_15
const asset = await client.serverless.v1
_15
.services("ServiceSid")
_15
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_15
.fetch();
_15
_15
console.log(asset.sid);

Output

_12
{
_12
"sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"service_sid": "ServiceSid",
_12
"friendly_name": "test-asset",
_12
"date_created": "2018-11-10T20:00:00Z",
_12
"date_updated": "2018-11-10T20:00:00Z",
_12
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
_12
"links": {
_12
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
_12
}
_12
}


Read multiple Asset resources

read-multiple-asset-resources page anchor
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

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

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const assets = await client.serverless.v1
_14
.services("ServiceSid")
_14
.assets.list({ limit: 20 });
_14
_14
assets.forEach((a) => console.log(a.sid));

Output

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


Update an Asset resource

update-an-asset-resource page anchor
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

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
Property nameTypeRequiredPIIDescription
FriendlyNamestringrequired

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

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
import twilio from "twilio";
_15
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = twilio(accountSid, authToken);
_15
_15
const asset = await client.serverless.v1
_15
.services("ServiceSid")
_15
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_15
.update({ friendlyName: "FriendlyName" });
_15
_15
console.log(asset.sid);

Output

_12
{
_12
"sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"service_sid": "ServiceSid",
_12
"friendly_name": "FriendlyName",
_12
"date_created": "2018-11-10T20:00:00Z",
_12
"date_updated": "2018-11-10T20:00:00Z",
_12
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000",
_12
"links": {
_12
"asset_versions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets/ZH00000000000000000000000000000000/Versions"
_12
}
_12
}


Delete an Asset resource

delete-an-asset-resource page anchor
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

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
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
import twilio from "twilio";
_13
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = twilio(accountSid, authToken);
_13
_13
await client.serverless.v1
_13
.services("ServiceSid")
_13
.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_13
.remove();


Rate this page: