# Using Serverless Toolkit with multiple Twilio Projects

Generally we recommend using Twilio Functions' "Environments" feature to deal with multiple deployments of your Functions project — for example, to verify your changes in a development or staging environment.

However, if you are using Functions in combination with Flex, for example, the chances are high that you are using independent Twilio projects with separate Account SIDs for each environment. The following guide shows you how you can make the most of this scenario.

> \[!WARNING]
>
> This guide expects you to have a minimum `@twilio-labs/plugin-serverless` version of 2.0.0 or `twilio-run` version of 3.0.0.
>
> You can find your `plugin-serverless` version by running `twilio plugins`.
>
> You can find your `twilio-run` version by running `npx twilio-run --version` inside your project directory.

While some of the following steps can be achieved with `twilio-run`, we recommend using the [Twilio CLI](/docs/twilio-cli/general-usage) and `@twilio-labs/plugin-serverless` when working with multiple projects. An exception is making deployments using a Continuous Delivery (CD) system. If you are doing that, please [check out this guide instead](/docs/labs/serverless-toolkit/guides/continous-deployment).

## Prerequisites

### Twilio CLI Setup

The Twilio CLI supports using several authentication profiles. You can see which profiles you currently have by running:

```bash
twilio profiles:list
```

Create one for each of the Twilio Projects/Accounts that you want to deploy to by running:

```bash
twilio profiles:create
```

You'll be asked to provide a name for your profile. You can use that name later on in any Twilio CLI command to tell the CLI to use those credentials by using the `-p <YOUR_PROFILE_NAME>` option.

We'll use `my-profile` and `team-profile` as examples.

### Setup your Twilio Serverless project

If you don't already have an existing project using the Serverless Toolkit, go ahead and [create one by following the instructions in our Getting Started guide](/docs/labs/serverless-toolkit/getting-started). Otherwise, keep reading.

## Deploying to multiple accounts

Once you have set up your project and your profiles, you can deploy to the respective profiles by running:

```bash
twilio serverless:deploy -p <YOUR_PROFILE_NAME>
```

For example, I would run:

```bash
twilio serverless:deploy -p my-profile
```

You'll see a file in your project called `.twiliodeployinfo` that gets updated after each deployment. This file makes sure that switching between different accounts is effortless. By default this file is added to your `.gitignore` file to prevent it from being tracked in your version control system.

If you are working alone on your project and you don't want different environment variables or similar configuration between the different accounts, you are set.

## Configuration for multiple accounts and team members

If you are sharing your project with other developers and you all deploy to the same accounts and/or Function services, you should configure the following settings.

Start by creating a `.twilioserverlessrc` file at the root of your project — if you don't have one in your project already — and add this to it:

```javascript
{
  "projects": {

  }
}
```

Inside the `projects` key you'll place configuration objects specific to an individual Account SID. This is where we can specify the respective Service SIDs that map to our Account SIDs.

> \[!NOTE]
>
> You can actually copy the information from your `.twiliodeployinfo` file. Copy the file once you are done deploying for the first time, rename the copy `.twilioserverlessrc`, and delete the `lastBuildSid` rows.

Your `.twilioserverlessrc` file should look something like this:

```javascript
{
  "projects": {
    "AC11111111111111111111111111111111": {
      "serviceSid": "ZS11111111111111111111111111111111"
    }, 
    "AC22222222222222222222222222222222": {
      "serviceSid": "ZS22222222222222222222222222222222"
    }
  }
}
```

Whenever you run any `twilio serverless:` command it will look up the Account SID here and apply the configuration you specified for that Account.

### Match environment variables to accounts

You might want to configure the use of different environment variables for each Account SID. You can do that by creating a configuration similar to this:

```javascript
{
  "projects": {
    "AC11111111111111111111111111111111": {
      "serviceSid": "ZS11111111111111111111111111111111",
      "env": ".env.dev"
    }, 
    "AC22222222222222222222222222222222": {
      "serviceSid": "ZS22222222222222222222222222222222",
      "env": ".env.production"
    }
  }
}
```

In this case if I deploy using `twilio serverless:deploy -p my-profile`, which maps to `AC11111111111111111111111111111111`, it will use the `.env.dev` file. When I run `twilio serverless:deploy -p team-profile` instead, it will use my `.env.production` file.

There are many things you can configure here. In general you can specify in the configuration anything that you can pass as a flag to the CLI. Check out our [Configuration and Meta Files](/docs/labs/serverless-toolkit/configuration) documentation to learn more about it.
