> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Evolution API (WhatsApp API)

> Evolution API on Square Cloud: host this WhatsApp API with a managed PostgreSQL database, run its migrations, set port 80, a global API key and Redis cache.

export const RecommendedPlan = ({lang, plan, tier, cpu, appType, min}) => {
  const t = {
    'en': {
      q: <>Which plan should you choose for {appType}?</>,
      rec: p => <>We recommend the {p} plan: its <b>{tier} GB</b> of RAM and <b>{cpu} vCPU</b> handle most projects of this kind, with headroom for traffic spikes.</>,
      min: m => <> Lighter projects also run on the {m} plan.</>,
      pro: p => <> For larger projects, the {p} plan adds more RAM and CPU.</>
    },
    'pt-br': {
      q: <>Qual plano escolher para {appType}?</>,
      rec: p => <>Recomendamos o plano {p}: seus <b>{tier} GB</b> de RAM e <b>{cpu} vCPU</b> atendem a maioria dos projetos desse tipo, com folga para picos de tráfego.</>,
      min: m => <> Projetos mais leves também rodam no plano {m}.</>,
      pro: p => <> Para projetos maiores, o plano {p} oferece mais RAM e CPU.</>
    },
    'es': {
      q: <>¿Qué plan elegir para {appType}?</>,
      rec: p => <>Te recomendamos el plan {p}: sus <b>{tier} GB</b> de RAM y <b>{cpu} vCPU</b> cubren la mayoría de los proyectos de este tipo, con margen para picos de tráfico.</>,
      min: m => <> Los proyectos más ligeros también funcionan en el plan {m}.</>,
      pro: p => <> Para proyectos más grandes, el plan {p} ofrece más RAM y CPU.</>
    },
    'fr': {
      q: <>Quel plan choisir pour héberger {appType} ?</>,
      rec: p => <>Nous recommandons le plan {p} : ses <b>{tier} Go</b> de RAM et <b>{cpu} vCPU</b> suffisent pour la plupart des projets de ce type, avec une marge pour les pics de trafic.</>,
      min: m => <> Les projets plus légers fonctionnent aussi avec le plan {m}.</>,
      pro: p => <> Pour les projets plus importants, le plan {p} offre davantage de RAM et de CPU.</>
    },
    'de': {
      q: <>Welcher Plan eignet sich für {appType}?</>,
      rec: p => <>Wir empfehlen den {p}-Plan: <b>{tier} GB</b> RAM und <b>{cpu} vCPU</b> reichen für die meisten Projekte dieser Art, mit Reserven für Lastspitzen.</>,
      min: m => <> Kleinere Projekte laufen auch mit dem {m}-Plan.</>,
      pro: p => <> Für größere Projekte bietet der {p}-Plan mehr RAM und CPU.</>
    },
    'it': {
      q: <>Quale piano scegliere per {appType}?</>,
      rec: p => <>Ti consigliamo il piano {p}: i suoi <b>{tier}GB</b> di RAM e <b>{cpu}vCPU</b> bastano per la maggior parte dei progetti di questo tipo, con margine per i picchi di traffico.</>,
      min: m => <> I progetti più leggeri funzionano anche con il piano {m}.</>,
      pro: p => <> Per progetti più grandi, il piano {p} offre più RAM e CPU.</>
    },
    'ja': {
      q: <>{appType}にはどのプランを選べばよいですか？</>,
      rec: p => <>{p}プランをおすすめします。<b>{tier}GB</b>のRAMと<b>{cpu}vCPU</b>があれば、この種のプロジェクトの多くをトラフィックのピークにも余裕を持って動かせます。</>,
      min: m => <>軽量なプロジェクトは{m}プランでも動作します。</>,
      pro: p => <>より大規模なプロジェクトには、RAMとCPUが増える{p}プランをご検討ください。</>
    },
    'zh': {
      q: <>托管{appType}应该选择哪个套餐？</>,
      rec: p => <>我们推荐 {p} 套餐：<b>{tier}GB</b> RAM 和 <b>{cpu}vCPU</b> 足以运行大多数此类项目，并能从容应对流量高峰。</>,
      min: m => <>较轻量的项目也可以在 {m} 套餐上运行。</>,
      pro: p => <>对于更大的项目，{p} 套餐提供更多 RAM 和 CPU。</>
    }
  };
  const siteLang = t[lang] ? lang : 'en';
  const c = t[siteLang];
  const pay = (name, query) => <a href={`https://squarecloud.app/${siteLang}/pay?${query}`}>{name}</a>;
  const isPro = plan.toLowerCase() === 'pro';
  return <Note>
      <b>{c.q}</b><br />
      {c.rec(pay(plan, `plan=${plan.toLowerCase()}&tier=${tier}`))}
      {min ? c.min(pay(min, `plan=${min.toLowerCase()}`)) : null}
      {isPro ? null : c.pro(pay('Pro', 'plan=pro'))}
    </Note>;
};

export const appType_0 = "Evolution API"

## Introduction

To develop and host {appType_0} on Square Cloud, it's essential to follow a structured sequence of configurations and prerequisites. This technical guide will cover the entire process, from initial setup to production deployment.

### Prerequisites

* **Square Cloud Account**: Register through the [signup page](https://squarecloud.app/en/signup) using your email.
* **Active plan**: Ensures dedicated resources and optimized performance for your application. Check our [available plans](https://squarecloud.app/en/pricing) and choose the most suitable for your needs.

<RecommendedPlan appType="Evolution API" plan="Standard" tier="4" cpu="4" lang="en" />

Evolution API is an open-source API for WhatsApp. It manages several WhatsApp instances in one place, through its web manager or its REST API, and connects them to tools like n8n, Chatwoot and Typebot. This guide runs on the [Node.js runtime](/en/articles/getting-started-with-nodejs).

## Get the project

Download the project from [our evolutionapi-web releases](https://github.com/squarecloud-education/evolutionapi-web/releases), which already has the files needed to deploy on Square Cloud, or from the [official repository](https://github.com/EvolutionAPI/evolution-api).

<Note>The official repository lists `typescript` in `devDependencies`. Square Cloud installs dependencies in production mode, without `devDependencies`, so the `npm run build` step fails. Our release already moves it to `dependencies`; with the official repository, move it yourself.</Note>

## Configure Evolution API

Evolution API reads a `.env` file at the root of the project when it starts, so this file goes in your ZIP. Start from the `.env` in our release (or from `.env.example` in the official repository) and edit the variables below. Variables set in the dashboard's **Environment Variables** take precedence over the `.env` file, which makes the dashboard the better place for secrets such as `AUTHENTICATION_API_KEY` and `DATABASE_CONNECTION_URI`. See [Environment variables](/en/platform/environment-variables).

### Database

Evolution API needs a PostgreSQL database. You can host one on Square Cloud with the Standard plan or higher: see [how to create and connect a managed database](/en/tutorials/how-to-deploy-your-database).
After creating it, set its URL in the `.env` as `DATABASE_CONNECTION_URI`, together with the client certificate for the PostgreSQL connection. Here's an example of the configuration needed:

```systemd .env theme={"system"}
DATABASE_PROVIDER=postgresql
DATABASE_CONNECTION_URI='postgresql://squarecloud:password@host:port/database?sslmode=require&sslidentity=path/to/client-identity.p12&sslpassword=p12password'
DATABASE_CONNECTION_CLIENT_NAME='evolution_exchange'
DATABASE_SAVE_DATA_INSTANCE=true
DATABASE_SAVE_DATA_NEW_MESSAGE=true
DATABASE_SAVE_MESSAGE_UPDATE=true
DATABASE_SAVE_DATA_CONTACTS=true
DATABASE_SAVE_DATA_CHATS=true
DATABASE_SAVE_DATA_LABELS=true
DATABASE_SAVE_DATA_HISTORIC=true
DATABASE_SAVE_IS_ON_WHATSAPP=true
DATABASE_SAVE_IS_ON_WHATSAPP_DAYS=7
DATABASE_DELETE_MESSAGE=true
```

Evolution API connects through Prisma, which expects the client certificate as a `.p12` file. Download the certificate files (`.crt` and `.key`) from the database's page in the dashboard, convert them, and put the `.p12` in your project:

```bash theme={"system"}
openssl pkcs12 -export -out client-identity.p12 -inkey <certificate>.key -in <certificate>.crt
```

The export password you choose is the `sslpassword` of the URL, and `sslidentity` is the path to the `.p12` file. Keep the `.p12` in your ZIP, since the application reads it from disk.

### Apply the migrations

With the environment variable and certificate set, apply the migrations to your database. From the project folder on your computer, install the dependencies with `npm install` (it needs the `runWithProvider.js` file) and run the following command:

<Tabs>
  <Tab title="Windows">
    ```bash theme={"system"}
    npm run db:deploy:win
    ```
  </Tab>

  <Tab title="Linux">
    ```bash theme={"system"}
    npm run db:deploy
    ```
  </Tab>
</Tabs>

Updating from an earlier version? Run the same command again before uploading the new files, since new versions can bring new migrations.

### Server

As shown in the `.env.example` file of the repository, set the server variables: `SERVER_TYPE`, `SERVER_PORT`, `SERVER_URL` and the language.

```systemd .env theme={"system"}
SERVER_NAME=evolution
SERVER_TYPE=http
SERVER_PORT=80
# Your application's URL: https://<subdomain>.squareweb.app, or your custom domain
SERVER_URL="https://my-evolution-api.squareweb.app"
LANGUAGE=en
# Other variables below...
```

Evolution API reads its port from `SERVER_PORT` (not from `PORT`) and falls back to `8080` without it, so keep `SERVER_PORT=80`.

### Global API key

It is important to configure a secure global API key to avoid unauthorized access. Replace it with a long random value of your own: the key in example files is public.

```systemd .env theme={"system"}
# Other variables...
AUTHENTICATION_API_KEY=MySuperSecureAPIKEY
```

### Redis cache (optional)

You can configure a cache system in Evolution API. To do so, you will need a Redis database, which you can also host on Square Cloud.\
To configure it, you will also need to download the certificate and set the URL to connect. Note the `rediss://` scheme: Square Cloud databases only accept TLS connections.

```systemd .env theme={"system"}
CACHE_REDIS_ENABLED=true
CACHE_REDIS_URI="rediss://default:MySecurePassword@square-cloud-db-ID.squareweb.app:7170"
CACHE_REDIS_TTL=604800
# Prefix serves to differentiate data from one installation to another that are using the same redis
CACHE_REDIS_PREFIX_KEY=evolution
# Enabling this variable will save the connection information in Redis and not in the database.
CACHE_REDIS_SAVE_INSTANCES=false
```

## Configure Square Cloud

Create a `squarecloud.app` file at the root of the project. The `START` command generates the Prisma client, builds the project and starts it; installing and building needs about 3072 MB of RAM:

```systemd squarecloud.app theme={"system"}
DISPLAY_NAME=Evolution API
RUNTIME=nodejs
START=npx prisma generate --schema prisma/postgresql-schema.prisma && npm run build && npm run start:prod
MEMORY=3072
VERSION=recommended
SUBDOMAIN=my-evolution-api
AUTORESTART=true
```

`SUBDOMAIN` must match the address in `SERVER_URL`. When uploading from the dashboard, select "Web Publication", set the same subdomain and paste the `START` command as the startup command.

## What goes in the ZIP

* The whole project folder: `package.json`, `runWithProvider.js`, `src/`, `prisma/` and the other files of the release or the repository.
* `.env`, with the variables above.
* The `.p12` client certificate.
* `squarecloud.app`.

Leave out `node_modules/`, which `npm install` created for the migrations: Square Cloud installs the dependencies on the server.

## Deploy and verify

### Via dashboard

<Steps>
  <Step title="Access the Upload Page">
    Access the [upload page](https://squarecloud.app/en/dashboard/new) and upload your project zip file.
  </Step>

  <Step title="Configure Your Environment">
    After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.\
    If you are uploading a web project, make sure to select "Web Publication" and set a subdomain to your project.
  </Step>

  <Step title="Deploy Your Project">
    Finally, click on the "Deploy" button to host your project on Square Cloud.\
    After deployment, you can monitor your project's status and logs from the dashboard.

    <Frame>
      <img src="https://cdn.squarecloud.app/docs/articles/dashboard/uploading.gif" alt="Uploading application to Square Cloud" style={{ borderRadius: "0.2rem" }} />
    </Frame>
  </Step>

  <Step title="Confirm Your App Is Live">
    Your first deploy usually takes less than a minute. In the [dashboard](https://squarecloud.app/en/dashboard), wait for your application status to show as running and check the logs for any startup errors.\
    If you deployed a website or API, open `https://<your-subdomain>.squareweb.app` in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
    <Tip>App not starting? See the [Troubleshooting guide](/en/platform/troubleshooting/app-wont-start) for the most common causes and fixes.</Tip>
  </Step>
</Steps>

### Via CLI

To use this method, your project needs a configuration file named `squarecloud.app` at its root. It tells Square Cloud how to run your application.

<Card title="Configuration file guide" icon="link" href="/en/getting-started/config-file">
  Learn how to create the `squarecloud.app` configuration file that defines your application's environment.
</Card>

<Steps>
  <Step title="Install the CLI">
    Install the [Square Cloud CLI](/en/cli-reference/installation). If you already have it, run the same command to update it:

    <CodeGroup>
      ```bash macOS, Linux, and WSL theme={"system"} theme={"system"}
      curl -fsSL https://cli.squarecloud.app/install | bash
      ```

      ```bash Windows with npm theme={"system"} theme={"system"}
      npm install -g @squarecloud/cli@latest
      ```
    </CodeGroup>
  </Step>

  <Step title="Log In">
    Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see [CLI authentication](/en/cli-reference/authentication).

    ```bash theme={"system"} theme={"system"}
    squarecloud auth login
    ```
  </Step>

  <Step title="Upload Your Project">
    From your project folder, run the command below. The CLI zips the current folder, leaving out what [`squarecloud.ignore`](/en/getting-started/squarecloud-ignore) lists, and uploads it:

    ```bash theme={"system"} theme={"system"}
    squarecloud upload
    ```

    To upload a zip you created yourself, pass it with `--file`:

    ```bash theme={"system"} theme={"system"}
    squarecloud upload --file <path/to/zip>
    ```
  </Step>

  <Step title="Confirm Your App Is Live">
    Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:

    ```bash theme={"system"} theme={"system"}
    squarecloud app status
    squarecloud app logs
    ```

    If you deployed a website or API, open `https://<your-subdomain>.squareweb.app` in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
    <Tip>App not starting? See the [Troubleshooting guide](/en/platform/troubleshooting/app-wont-start) for the most common causes and fixes.</Tip>
  </Step>
</Steps>

### Lower the RAM after the first run

After the first run, you can reduce the RAM to 1536MB or 2048MB and set the startup command to only:

```bash theme={"system"}
npm run start:prod
```

## First access

Open `https://my-evolution-api.squareweb.app/manager` to reach the web manager. Log in with your `SERVER_URL` as the server URL and your `AUTHENTICATION_API_KEY` as the global API key, then create your first WhatsApp instance.

## Common errors

<CardGroup cols={1}>
  ### Custom domain

  <Card horizontal>
    To use a custom domain (e.g., `mysite.com`) instead of the default URL `mysite.squareweb.app`, you need the **Standard plan or higher**. The default URL comes from the **SUBDOMAIN** field in the configuration file. To connect your domain, follow [how to set up your own domain](https://help.squarecloud.app/en-us/article/how-to-set-up-your-own-domain-cnamedns-1fzbrgh/).
  </Card>

  ### Minimum RAM requirements

  <Card horizontal>
    **Minimum: 512MB RAM** for websites and APIs, enough for a static build on the static runtime. For apps that render pages on a server (Next.js, Nuxt, Angular SSR and similar), we recommend **at least 1GB RAM**. For larger applications, allocate more RAM to prevent the application from running out of memory and crashing.
  </Card>

  ### Could not find this site.

  <Card horizontal>
    Check if the **subdomain/domain** matches what's configured in the **SUBDOMAIN** field or in the **custom domain settings**. If you just uploaded the site, wait up to **60 seconds** for Square to enable **first access**.
  </Card>

  ### Site took too long to respond...

  <Card horizontal>
    Your server must listen on **port 80** and **host 0.0.0.0**. Square Cloud sets the **PORT** (`80`) and **HOST** (`0.0.0.0`) environment variables in your application: read them in your code instead of hardcoding other values. A server that listens only on `localhost` or `127.0.0.1` never receives requests.
  </Card>
</CardGroup>

### Evolution API can't connect to the database

Check that `sslidentity` points to the `.p12` file inside your ZIP and that `sslpassword` is the export password you chose. For other SSL/TLS errors, see [database connection errors](/en/platform/troubleshooting/database-connection-errors).

## Next steps

<CardGroup cols={3}>
  <Card title="Managed database" icon="database" href="/en/tutorials/how-to-deploy-your-database">
    Create the PostgreSQL database Evolution API needs.
  </Card>

  <Card title="Database connection errors" icon="triangle-exclamation" href="/en/platform/troubleshooting/database-connection-errors">
    Fix SSL/TLS and connection errors.
  </Card>

  <Card title="WhatsApp bot" icon="whatsapp" href="/en/tutorials/bots/whatsapp">
    Build a single WhatsApp bot with whatsapp-web.js or Baileys.
  </Card>
</CardGroup>

## Contact us

If you continue facing **technical difficulties**, our **specialized support team** is available to assist you. [**Contact us**](https://squarecloud.app/en/support) and we'll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud [**4.9/5 across 402 reviews**](https://www.trustpilot.com/review/squarecloud.app) on Google and Trustpilot.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.