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

Quickstart


In addition to the Console UI and the Serverless Toolkit, you have the option of directly using the Serverless API to create and manage your Services, Functions, and Assets. This empowers you to create custom build and deployment automations to suit your specific needs.

(warning)

Warning

Functions and Assets created via Functions(Classic) and Assets(Classic) are not available via the API. Similarly, Functions and Assets created via the API aren't available in the Functions(Classic) and Assets(Classic) interface.

Get an overview of the API and the Serverless Toolkit by watching our overview video from Twilio Signal 2019:

Great. Let's have a look at how to deploy a single Function via the API.


Deploying a single Function

deploying-a-single-function page anchor

Create a Service

create-a-service page anchor

First, we'll create a Service, which serves as our container for the environments we set up.

(warning)

Warning

The uniqueName will form part of your domain name, so choose carefully.

Create a Service

create-a-service-1 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
// 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 = require('twilio')(accountSid, authToken);
_14
_14
client.serverless.v1.services
_14
.create({
_14
includeCredentials: true,
_14
uniqueName: 'demo',
_14
friendlyName: 'testing'
_14
})
_14
.then(service => console.log(service.sid));

Output

_18
{
_18
"sid": "ZS00000000000000000000000000000000",
_18
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"friendly_name": "testing",
_18
"unique_name": "demo",
_18
"include_credentials": true,
_18
"ui_editable": false,
_18
"domain_base": "service-unique-1234",
_18
"date_created": "2018-11-10T20:00:00Z",
_18
"date_updated": "2018-11-10T20:00:00Z",
_18
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000",
_18
"links": {
_18
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
_18
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
_18
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
_18
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
_18
}
_18
}

We'll get back a Service SID, in the format ZSxxx.

Next, we'll use that Service SID to create a "dev" Environment.

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
// 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 = require('twilio')(accountSid, authToken);
_14
_14
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14
.environments
_14
.create({
_14
domainSuffix: 'dev',
_14
uniqueName: 'dev-environment'
_14
})
_14
.then(environment => console.log(environment.sid));

Output

_18
{
_18
"sid": "ZE00000000000000000000000000000000",
_18
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"build_sid": null,
_18
"unique_name": "dev-environment",
_18
"domain_suffix": "dev",
_18
"domain_name": "foobar-1234-stage.twil.io",
_18
"custom_domain_name": null,
_18
"date_created": "2018-11-10T20:00:00Z",
_18
"date_updated": "2018-11-10T20:00:00Z",
_18
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000",
_18
"links": {
_18
"variables": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables",
_18
"deployments": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Deployments",
_18
"logs": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Logs"
_18
}
_18
}

This will give us an empty environment, e.g. demo-X4HX-dev.twil.io. To see the domain name for your environment, you can fetch your environment using the ZExxx SID output from the prior code sample.

Fetch Environment Domain Name

fetch-environment-domain-name page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(environment => console.log(environment.domainName));

Output

_18
{
_18
"sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"build_sid": "ZB00000000000000000000000000000000",
_18
"unique_name": "testing-environment",
_18
"domain_suffix": "testing",
_18
"domain_name": "foobar-1234-testing.twil.io",
_18
"custom_domain_name": null,
_18
"date_created": "2018-11-10T20:00:00Z",
_18
"date_updated": "2018-11-10T20:00:00Z",
_18
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000",
_18
"links": {
_18
"variables": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables",
_18
"deployments": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Deployments",
_18
"logs": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Logs"
_18
}
_18
}

Now let's create our Function. We create the Function at the service level, not inside a particular environment (we'll deploy our Function to an environment later on). Also, we only set the name for the Function at this step. We'll choose a path, visibility, and upload the code for the Function in later steps.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.functions
_11
.create({friendlyName: 'firstfunc'})
_11
.then(function_ => console.log(function_.sid));

Output

_12
{
_12
"sid": "ZH00000000000000000000000000000000",
_12
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"friendly_name": "firstfunc",
_12
"date_created": "2018-11-10T20:00:00Z",
_12
"date_updated": "2018-11-10T20:00:00Z",
_12
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions/ZH00000000000000000000000000000000",
_12
"links": {
_12
"function_versions": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions/ZH00000000000000000000000000000000/Versions"
_12
}
_12
}

You will get back a Function SID in the format ZHxxx. Save this Function SID for the next step, where we'll create a Version for this Function.

With a Function created, we're ready to create our first Version. Versions of Functions or Assets are where you add the path, visibility (public, protected or private), and the file content itself.

First, we need some code upload. Let's write a simple Function that decides the fate of the universe:


_10
exports.handler = (context, event, callback) => {
_10
const sparedByThanos = Math.random() > 0.5;
_10
_10
callback(null, {
_10
sparedByThanos,
_10
quote: 'You should have gone for the head.'
_10
});
_10
};

Now we have a Function worth uploading. Save this as a file on your computer named firstfunc.js.

Now we can upload that file. The create API action is not currently represented in the helper libraries, so you have to do a manual file upload in the language of your choice. See an example below using Node.js.

Remember to replace ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX with your Service SID, and ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX with the SID of the newly created Function (from this step).

Node.js
Python
Java
PHP
Ruby
curl

_36
const fs = require('fs');
_36
// Before running this code, install "form-data" and "axios" using `npm install form-data axios`
_36
const FormData = require('form-data');
_36
const axios = require('axios');
_36
_36
// Provision API Keys at twilio.com/console/runtime/api-keys
_36
// and set the environment variables. See http://twil.io/secure
_36
const apiKey = process.env.TWILIO_API_KEY;
_36
const apiSecret = process.env.TWILIO_API_SECRET;
_36
_36
const serviceSid = 'ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
_36
const functionSid = 'ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
_36
_36
const serviceUrl = `https://serverless-upload.twilio.com/v1/Services/${serviceSid}`;
_36
const uploadUrl = `${serviceUrl}/Functions/${functionSid}/Versions`;
_36
_36
const form = new FormData();
_36
form.append('Path', '/thanos');
_36
form.append('Visibility', 'public');
_36
form.append('Content', fs.createReadStream('firstfunc.js'), {
_36
contentType: 'application/javascript',
_36
});
_36
_36
// Create a new Function Version
_36
axios
_36
.post(uploadUrl, form, {
_36
auth: {
_36
username: apiKey,
_36
password: apiSecret,
_36
},
_36
headers: form.getHeaders(),
_36
})
_36
.then((response) => {
_36
const newVersionSid = response.data.sid;
_36
console.log(newVersionSid);
_36
});

With the upload complete, you will see a SID logged to your terminal. Save this Version SID for the next step.

Now, we need to create a Build. A Build will compile Function and Asset Versions into a single, deployable package. This build will live in the Twilio cloud, so you just need the Build SID to reference it — there are no files to keep track of.

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
// 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 = require('twilio')(accountSid, authToken);
_13
_13
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.builds
_13
.create({
_13
functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']
_13
})
_13
.then(build => console.log(build.sid));

Output

_45
{
_45
"sid": "ZB00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"asset_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"asset_sid": "ZH00000000000000000000000000000000",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/asset-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"function_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000001",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"function_sid": "ZH00000000000000000000000000000001",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/function-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"dependencies": [
_45
{
_45
"name": "twilio",
_45
"version": "3.29.2"
_45
},
_45
{
_45
"name": "@twilio/runtime-handler",
_45
"version": "1.0.1"
_45
}
_45
],
_45
"runtime": "node18",
_45
"status": "building",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"date_updated": "2018-11-10T20:00:00Z",
_45
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000",
_45
"links": {
_45
"build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
_45
}
_45
}

You'll receive a result straight away, but note the status property. We need to wait until the status returns completed before continuing. The best way to handle the status changes is to poll every second or two. Here is some sample code to get the current status of a Build:

Fetch a Build to check its status

fetch-a-build-to-check-its-status page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.builds('ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(build => console.log(build.status));

Output

_45
{
_45
"sid": "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"asset_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"asset_sid": "ZH00000000000000000000000000000000",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/asset-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"function_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000001",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"function_sid": "ZH00000000000000000000000000000001",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/function-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"dependencies": [
_45
{
_45
"name": "twilio",
_45
"version": "3.29.2"
_45
},
_45
{
_45
"name": "@twilio/runtime-handler",
_45
"version": "1.0.1"
_45
}
_45
],
_45
"runtime": "node18",
_45
"status": "building",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"date_updated": "2018-11-10T20:00:00Z",
_45
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000",
_45
"links": {
_45
"build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
_45
}
_45
}

When the build is completed, we're ready to deploy!

For the final step, you must associate the Build we just created with the Environment we created earlier in this tutorial. (Remember the Environment SID!) This is called a Deployment.

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

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.deployments
_12
.create()
_12
.then(deployment => console.log(deployment.sid));

Output

_10
{
_10
"sid": "ZD00000000000000000000000000000000",
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"environment_sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"build_sid": "ZB00000000000000000000000000000000",
_10
"date_created": "2018-11-10T20:00:00Z",
_10
"date_updated": "2018-11-10T20:00:00Z",
_10
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Deployments/ZD00000000000000000000000000000000"
_10
}

Your Function will now be live and accessible via URL! You can test it out by going to its URL, such as https://demo-X4HX-dev.twil.io/thanos (be sure to replace demo-X4HX-dev.twil.io with the unique domain name for your Environment, which you fetched earlier).


When creating a build, you can also specify any dependencies that your code may have.

To do so, include the dependencies property, which must be a JSON stringified array of package names and versions.

Create a Build with dependencies

create-a-build-with-dependencies 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
// 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 = require('twilio')(accountSid, authToken);
_14
_14
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14
.builds
_14
.create({
_14
functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'],
_14
dependencies: `[{"name": "randomcolor", "version": "0.5.4"}]`
_14
})
_14
.then(build => console.log(build.sid));

Output

_45
{
_45
"sid": "ZB00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"asset_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"asset_sid": "ZH00000000000000000000000000000000",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/asset-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"function_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000001",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"function_sid": "ZH00000000000000000000000000000001",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/function-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"dependencies": [
_45
{
_45
"name": "twilio",
_45
"version": "3.29.2"
_45
},
_45
{
_45
"name": "@twilio/runtime-handler",
_45
"version": "1.0.1"
_45
}
_45
],
_45
"runtime": "node18",
_45
"status": "building",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"date_updated": "2018-11-10T20:00:00Z",
_45
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000",
_45
"links": {
_45
"build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
_45
}
_45
}


The pattern we used above for uploading Functions is exactly the same as it for Assets.

  1. Create an Asset
  2. Create the Asset Version via a POST request to the serverless-uploads.twilio.com domain
  3. Include the AssetVersion SID(s) we want to be a part of the Build, alongside any functionVersions and dependencies we might need.

Create a Build with a Function and an Asset

create-a-build-with-a-function-and-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
// 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 = require('twilio')(accountSid, authToken);
_14
_14
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14
.builds
_14
.create({
_14
functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'],
_14
assetVersions: ['ZNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY']
_14
})
_14
.then(build => console.log(build.sid));

Output

_45
{
_45
"sid": "ZB00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"asset_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000000",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"asset_sid": "ZH00000000000000000000000000000000",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/asset-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"function_versions": [
_45
{
_45
"sid": "ZN00000000000000000000000000000001",
_45
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"service_sid": "ZS00000000000000000000000000000000",
_45
"function_sid": "ZH00000000000000000000000000000001",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"path": "/function-path",
_45
"visibility": "PUBLIC"
_45
}
_45
],
_45
"dependencies": [
_45
{
_45
"name": "twilio",
_45
"version": "3.29.2"
_45
},
_45
{
_45
"name": "@twilio/runtime-handler",
_45
"version": "1.0.1"
_45
}
_45
],
_45
"runtime": "node18",
_45
"status": "building",
_45
"date_created": "2018-11-10T20:00:00Z",
_45
"date_updated": "2018-11-10T20:00:00Z",
_45
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000",
_45
"links": {
_45
"build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
_45
}
_45
}


Definitely take a look at the API reference section for all of the API resources below. You might be particularly interested in Variables to allow setting Environment Variables for a given Environment.


Rate this page: