Build
Builds are packages of Functions and Assets that you bundle together for deployment. Builds contain Function Version SIDs, Asset Version SIDs, and Dependencies.
Dependencies are defined as JSON strings, for example:
_10'[{"name": "randomcolor","version":"0.5.4" },
_10 {"name": "util","version":"0.10.3" },
_10 {"name": "xmldom","version":"0.1.27" },
_10 {"name": "got","version":"6.7.1" },
_10 {"name": "fs","version":"0.0.1-security" },
_10 {"name": "lodash","version":"4.17.11" },
_10 {"name": "date-fns","version":"1.30.1" }]'
Builds take time to package, deploy, and be verified. After creating a Build, it is best to poll every second to check the Build's status. When a Build is verified, it is ready to be used in a Deployment.
Build status | Meaning |
---|
Building | Build request is being processed by the packager. |
Completed | We have run a health check on the uploaded package and verified it. |
Failed | Packaging has failed at any of the above steps. |
Resource properties
sid
type: SID<ZB>
The unique string that we created to identify the Build resource.
Pattern:
^ZB[0-9a-fA-F]{32}$
service_sid
type: SID<ZS>
The SID of the Service that the Build resource is associated with.
Pattern:
^ZS[0-9a-fA-F]{32}$
status
type: enum<string>
The status of the Build. Can be: building
, completed
, or failed
.
Possible values:
building
completed
failed
asset_versions
type: array
The list of Asset Version resource SIDs that are included in the Build.
function_versions
type: array
The list of Function Version resource SIDs that are included in the Build.
dependencies
type: array
A list of objects that describe the Dependencies included in the Build. Each object contains the name
and version
of the dependency.
runtime
type: enum<string>
The Runtime version that will be used to run the Build resource when it is deployed.
Possible values:
node8
node10
node12
node14
node16
node18
date_created
type: string<date-time>
date_updated
type: string<date-time>
url
type: string<uri>
The absolute URL of the Build resource.
links
type: object<uri-map>
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Builds
URI parameters
ServiceSid
type: string
The SID of the Service to create the Build resource under.
Request body parameters
AssetVersions
type: array[string]
The list of Asset Version resource SIDs to include in the Build.
FunctionVersions
type: array[string]
The list of the Function Version resource SIDs to include in the Build.
Dependencies
type: string
A list of objects that describe the Dependencies included in the Build. Each object contains the name
and version
of the dependency.
Runtime
type: string
The Runtime version that will be used to run the Build resource when it is deployed.
Info
You must specify all Function or Asset Versions when creating a Build. Builds only use the provided Versions, and do not reference the Versions used by previous Builds.
Warning
In order to create a Build successfully, your request must include at least one Function Version, Asset Version, or a combination of both.
If no Function or Asset Versions are indicated, you'll receive Error 20001:
At least one Function Version or Asset Version is required for Build
_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
_14const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14const authToken = process.env.TWILIO_AUTH_TOKEN;
_14const client = require('twilio')(accountSid, authToken);
_14client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14 functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'],
_14 assetVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']
_14 .then(build => console.log(build.sid));
_45 "sid": "ZB00000000000000000000000000000000",
_45 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45 "service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "function_versions": [
_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 "name": "@twilio/runtime-handler",
_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 "build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
_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
_14const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14const authToken = process.env.TWILIO_AUTH_TOKEN;
_14const client = require('twilio')(accountSid, authToken);
_14client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14 functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'],
_14 dependencies: `[{"name":"twilio","version":"3.71.2"},{"name":"@twilio/runtime-handler","version":"1.2.1"}]`
_14 .then(build => console.log(build.dependencies));
_45 "sid": "ZB00000000000000000000000000000000",
_45 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45 "service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "function_versions": [
_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 "name": "@twilio/runtime-handler",
_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 "build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
Primarily used when upgrading to a new version of Node.js. Only needs to be run once, and will apply to subsequent deploys
_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
_14const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14const authToken = process.env.TWILIO_AUTH_TOKEN;
_14const client = require('twilio')(accountSid, authToken);
_14client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14 functionVersions: ['ZNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'],
_14 .then(build => console.log(build.sid));
_45 "sid": "ZB00000000000000000000000000000000",
_45 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45 "service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "function_versions": [
_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 "name": "@twilio/runtime-handler",
_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 "build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Builds/{Sid}
URI parameters
ServiceSid
type: string
The SID of the Service to fetch the Build resource from.
Sid
type: SID<ZB>
The SID of the Build resource to fetch.
Pattern:
^ZB[0-9a-fA-F]{32}$
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .builds('ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(build => console.log(build.sid));
_45 "sid": "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45 "service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "function_versions": [
_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 "name": "@twilio/runtime-handler",
_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 "build_status": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZB00000000000000000000000000000000/Status"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Builds
URI parameters
ServiceSid
type: string
The SID of the Service to read the Build resources from.
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_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
_11const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11const authToken = process.env.TWILIO_AUTH_TOKEN;
_11const client = require('twilio')(accountSid, authToken);
_11client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(builds => builds.forEach(b => console.log(b.sid)));
_12 "first_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds?PageSize=50&Page=0",
_12 "next_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds?PageSize=50&Page=1",
_12 "previous_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds?PageSize=50&Page=0",
_12 "url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds?PageSize=50&Page=0"
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Builds/{Sid}
URI parameters
ServiceSid
type: string
The SID of the Service to delete the Build resource from.
Sid
type: SID<ZB>
The SID of the Build resource to delete.
Pattern:
^ZB[0-9a-fA-F]{32}$
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .builds('ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')