Assets are static files that you can host at a particular domain in an Environment.
The steps to create Assets are as follows:
We will need the Asset Version SID to include this Asset in a Build.
The unique string that we created to identify the Asset resource.
^ZH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Asset resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service that the Asset resource is associated with.
^ZS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The string that you assigned to describe the Asset resource. It can be a maximum of 255 characters.
The date and time in GMT when the Asset resource was created specified in ISO 8601 format.
The date and time in GMT when the Asset resource was last updated specified in ISO 8601 format.
The URLs of the Asset resource's nested resources.
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets
The SID of the Service to create the Asset resource under.
application/x-www-form-urlencoded
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createAsset() {11const asset = await client.serverless.v112.services("ServiceSid")13.assets.create({ friendlyName: "FriendlyName" });1415console.log(asset.sid);16}1718createAsset();
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}
The SID that identifies the Asset resource to fetch.
^ZH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchAsset() {11const asset = await client.serverless.v112.services("ServiceSid")13.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.fetch();1516console.log(asset.sid);17}1819fetchAsset();
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}
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets
The SID of the Service to read the Asset resources from.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listAsset() {11const assets = await client.serverless.v112.services("ServiceSid")13.assets.list({ limit: 20 });1415assets.forEach((a) => console.log(a.sid));16}1718listAsset();
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}
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}
application/x-www-form-urlencoded
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateAsset() {11const asset = await client.serverless.v112.services("ServiceSid")13.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.update({ friendlyName: "FriendlyName" });1516console.log(asset.sid);17}1819updateAsset();
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 https://serverless.twilio.com/v1/Services/{ServiceSid}/Assets/{Sid}
The SID that identifies the Asset resource to delete.
^ZH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteAsset() {11await client.serverless.v112.services("ServiceSid")13.assets("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.remove();15}1617deleteAsset();