---
title: "Deploy wacli API (Self-Hosted)"
description: "Self-host wacli with a FastAPI API, token auth and persistent sessions."
category: "Automation"
url: https://railway.com/deploy/wacli-api-self-hosted
---

# Deploy wacli API (Self-Hosted)

Self-host wacli with a FastAPI API, token auth and persistent sessions.

**[Deploy wacli API (Self-Hosted) on Railway](https://railway.com/template/wacli-api-self-hosted)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/wacli-api-self-hosted/manifest.json

- **Creator:** Hosmel Quintana's Projects
- **Category:** Automation
- **Total deploys:** 2

## Template content

### wacli https://wacli.sh/favicon.svg

- **Image:** ghcr.io/hosmelq/railway-wacli-api-template:latest
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host wacli API (Self-Hosted) on Railway

wacli API adds a FastAPI HTTP API to the wacli WhatsApp client. This template includes token authentication, a public HTTPS domain, persistent session storage, and continuous sync after you link your phone.

## About Hosting wacli API (Self-Hosted)

The template deploys one service with FastAPI and wacli, plus a persistent `/data` volume. Your linked-device session and synced messages survive redeployments. The API and sync worker run together, so no separate database or API service is required.

## Common Use Cases

- Send WhatsApp text messages from a Laravel application.
- Connect your own backend to a WhatsApp account through HTTP.
- Check whether the linked WhatsApp session is authenticated.

## Dependencies for wacli API (Self-Hosted) Hosting

- Persistent storage and a public HTTPS domain, included in this template.
- A WhatsApp account and access to its primary phone.
- Railway Console access to pair the phone.

### Deployment Dependencies

- https://wacli.sh
- https://fastapi.tiangolo.com

### Implementation Details

After deployment, open the service’s Console tab and run `wacli-pair`. On your phone, open WhatsApp → Linked devices → Link a device and scan the QR code. You can also run `wacli-pair --phone +15551234567` to link using a phone-number code. Once pairing and the initial sync finish, the worker starts continuous sync.

Copy `API_TOKEN` from Railway’s Variables tab. Send it as `Authorization: Bearer YOUR_API_TOKEN` when calling `GET /session` or `POST /messages`. To send a text message, post a JSON object with `message` and `to`, using an international phone number such as `+15551234567`. Open `/docs` on the public domain for interactive API documentation.

A successful send returns HTTP `202` and a message ID. This means WhatsApp accepted the send, not that the recipient received it. The API never automatically retries a send. Keep one replica per volume, and link a phone separately for each deployment.

See the [source repository](https://github.com/hosmelq/railway-wacli-api-template) for the Laravel example, variables, and API responses. wacli uses the WhatsApp Web protocol and is not affiliated with WhatsApp or Meta.

## Why Deploy wacli API (Self-Hosted) on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying wacli API (Self-Hosted) on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — Automate WhatsApp workflows with Evolution API, n8n, and Postgres.
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

Open this page in a browser: https://railway.com/deploy/wacli-api-self-hosted
