# Serverless API

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

## Getting started

To deploy Functions and Assets right away, we suggest you look into the [Serverless Toolkit](/docs/labs/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](/docs/serverless/api/quickstart).

## API reference

The API comprises the following resources:

* [Service](/docs/serverless/api/resource/service)
* [Function](/docs/serverless/api/resource/function)
* [Function Version](/docs/serverless/api/resource/function-version)
* [Function Version Content](/docs/serverless/api/resource/function-version/content)
* [Asset](/docs/serverless/api/resource/asset)
* [Asset Version](/docs/serverless/api/resource/asset-version)
* [Variable](/docs/serverless/api/resource/variable)
* [Build](/docs/serverless/api/resource/build)
* [Build Status](/docs/serverless/api/resource/build/build-status)
* [Environment](/docs/serverless/api/resource/environment)
* [Deployment](/docs/serverless/api/resource/deployment)
* [Logs](/docs/serverless/api/resource/logs)

The animation below shows the relationship and purpose for each resource:&#x20;

![Animation showing serverless API services as containers for functions and assets.](https://docs-resources.prod.twilio.com/c5bc8be9c26ae60858dd4aa79fa8ed5695fc8f6bd0c95bbe6b114f7e184c735d.gif)

## 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:

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

So that means a [Service](/docs/serverless/api/resource/service) with the unique name `thanos` can create the following domains by specifying a domain suffix (or leaving it blank) when creating an [Environment](/docs/serverless/api/resource/environment):

```javascript
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 7 days and then deleted:

* [Functions](/docs/serverless/api/resource/function) with no [Function Versions](/docs/serverless/api/resource/function-version).
* [Assets](/docs/serverless/functions-assets/assets) with no [Asset Versions](/docs/serverless/api/resource/asset-version).
* [Function Versions](/docs/serverless/api/resource/function-version) or [Asset Versions](/docs/serverless/api/resource/asset-version) that are not part of a [Build](/docs/serverless/api/resource/build) or of an active [Deployment](/docs/serverless/api/resource/deployment).

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

* Logs, including those generated by the `console.log()`, `console.info()`, `console.warn()`, and `console.error()` methods

> \[!NOTE]
>
> 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' 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](/docs/messaging/quickstart) and [this page for voice calls](/docs/voice/api/call-resource#call-resource-retention).

## 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.
* `GET` requests to Functions that include a body are now rejected with a `403` status code. Previously, these requests were accepted with a `200` status code, and the body would have been ignored.

### Limits

* An account can have 50 [Services](/docs/serverless/api/resource/service).
* A Service can have up to 25 [Environments](/docs/serverless/api/resource/environment).
* A [Build](/docs/serverless/api/resource/build) can contain up to 100 [Function Versions](/docs/serverless/api/resource/function-version).
* A Build can contain up to 1000 public/protected [Asset Versions](/docs/serverless/api/resource/asset-version).
* A Build can contain up to 50 private Asset Versions.
* A Build can have up to 512MB of [Dependencies](/docs/serverless/functions-assets/functions/dependencies). Consider removing non-essential libraries if using the Console UI, or [setting development-only Dependencies](/docs/labs/serverless-toolkit/guides/front-end-framework-serverless#installing-dependencies) as `devDependencies` instead of `dependencies` if using the [Serverless Toolkit](/docs/labs/serverless-toolkit).
* An account can do up to 100 Builds per hour.
* Builds without an active deployment are deleted after 7 days.
* Function Versions that are not part of any Builds and are older than 7 days will be deleted.
* Asset Versions that are not part of any Build and are older than 7 days will be deleted.
* Functions that don't have any Function Versions and are older than 7 days will be deleted.
* Assets that don't have any Asset Versions and are older than 7 days will be deleted.
* Function execution time is limited to 10 seconds.
* An account can execute up to 30 Functions concurrently. In case your account is reaching these concurrency limits, you can reach out to support to request a limit increase.

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         |
