Serverless API
The Serverless API lets you deploy Twilio Functions and Assets programmatically.
To deploy Functions and Assets, use the Serverless Toolkit, which gives you an installable development Environment from which to build and deploy everything you need.
To test out the API, see the Quickstart guide.
The API includes the following resources:
- Service
- Function
- Function Version
- Function Version Content
- Asset
- Asset Version
- Variable
- Build
- Build Status
- Environment
- Deployment
- Logs
The following animation shows the relationship and purpose for each resource:

The API gives you control over the domains that serve your Functions and Assets after deployment. The domain structure is as follows:
https://[service unique name]-[random characters]-[optional domain suffix].twil.io/
For example, a Service with the unique name thanos can create the following domains by specifying a domain suffix (or leaving it blank) when creating an Environment:
1https://thanos-3432.twil.io/ // Environment domain suffix left blank2https://thanos-3432-dev.twil.io/ // Environment domain suffix = dev3https://thanos-3432-test.twil.io/ // Environment domain suffix = test4https://thanos-3432-stage.twil.io/ // Environment domain suffix = stage
The following entities are retained for up to 7 days and then deleted:
- Functions that have no Function Versions.
- Assets that have no Asset Versions.
- Function versions or Asset Versions that aren't part of a build or of an active deployment.
The following entities are retained for up to 30 days and then deleted:
- Logs, including those generated by the
console.log(),console.info(),console.warn(), andconsole.error()methods
Retention policy for API-generated entities
This policy doesn't affect active Deployments. It only applies to users working with the API, Serverless Toolkit, or the UI editor. It does not apply to Functions (Classic) and Assets (Classic).
Data generated by the underlying Twilio products that you invoke using Functions, such as SMS or Voice calls, is retained or deleted according to each product's data-retention policy. For details, refer to the individual product documentation, such as the SMS developer quickstart and call resource retention for Voice.
- Functions and Assets created by the API are not reflected in the Classic UI for those products. You cannot use the API to read Functions or Assets created with the Classic UI. The two systems are separate.
- There is no
GEToperation for Asset Versions. You cannot retrieve the asset file content itself through the API. GETrequests to functions that include a body are rejected with a403status code.
- An account can have up to 50 Services.
- A Service can have up to 25 Environments.
- A Build can contain up to 100 Function Versions.
- A Build can contain up to 1,000 public or protected Asset Versions.
- A Build can contain up to 50 private Asset Versions.
- A Build can have up to 512 MB of dependencies. If you hit this limit, remove non-essential libraries if using the Console UI, or mark development-only dependencies as
devDependencieswhen using the Serverless Toolkit. - An account can start up to 100 Builds per hour.
- Builds without an active deployment are deleted after 7 days.
- Function Versions that are not part of any Build and are older than 7 days are deleted.
- Asset Versions that are not part of any Build and are older than 7 days are deleted.
- Functions that do not have any Function Versions and are older than 7 days are deleted.
- Assets that do not have any Asset Versions and are older than 7 days are deleted.
- Function execution time is limited to 10 seconds.
- An account can execute up to 30 Functions concurrently. If you regularly reach this concurrency limit, contact Twilio Support to request an increase.
Maximum file size per asset when using the API:
| Asset type | Maximum size |
|---|---|
| Public | 25MB |
| Protected | 25MB |
| Private | 10MB |