Menu

Expand
Rate this page:

Serverless API

The new Serverless API empowers you to deploy Twilio Functions & Assets programmatically.

Getting started

To deploy Functions and Assets right away, we suggest you look into the Serverless Toolkit, which gives you an installable development environment from which to build and deploy everything you need.

To play with the API itself, head over to our Quickstart.

API reference

The API comprises the following resources:

The animation below shows the relationship and purpose for each resource:

Serverless API resource overview animation

Understanding domains

The new API gives you more control over the domains you serve your Functions and Assets from once deployed. Your domain structure looks like this:

https://[service unique name]-[random characters]-[optional domain suffix].twil.io/

So that means 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:

https://thanos-3432.twil.io/       // Environment domain suffix left blank
https://thanos-3432-dev.twil.io/   // Environment domain suffix = dev
https://thanos-3432-test.twil.io/  // Environment domain suffix = test
https://thanos-3432-stage.twil.io/ // Environment domain suffix = stage

Retention policy

The following entities will be retained for up to 30 days and then deleted:

This policy will not affect any active deployments at any point. It will only apply to users working with the API, Serverless Toolkit or the new UI editor. It does not apply to Functions (Classic) and Assets (Classic).

Data generated by the underlying products used via Functions, such as SMS or voice calls, is retained/deleted in line with those products’s own data-retention policies. You can find details of individual product data-retention policies in the specific product documentation, such as this page for SMS and this page for voice calls.

Limitations and limits

Limitations

  • 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 GET for Asset Versions. You cannot retrieve the Asset file content itself via the API.

Limits

  • An account can have 50 Services.
  • A Service can have up to 25 Environments.
  • A Build can contain up to 50 Function Versions.
  • A Build can contain up to 1000 public/protected Asset Versions.
  • A Build can contain up to 50 private Asset Versions.
  • A Build can have up to 512MB of Dependencies. Consider removing non-essential libraries if using the Console UI, or setting development-only Dependencies as devDependencies instead of dependencies if using the Serverless Toolkit.
  • An account can do up to 100 Builds per hour.
  • Builds without an active deployment are deleted after 24 hours.
  • Function Versions that are not part of any Builds and are older than 30 days will be deleted.
  • Asset Versions that are not part of any Build and are older than 30 days will be deleted.
  • Functions that don’t have any Function Versions and are older than 30 days will be deleted.
  • Assets that don’t have any Asset Versions and are older than 30 days will be deleted.
  • Function execution time is limited to 10 seconds.
  • An account can execute up to 30 functions concurrently.

Both public and private Assets have limitations on the maximum file size of each when using APIs:

Asset Type Maximum Size
Public and protected 25MB
Private 10MB
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more