ββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
WhatsApp OTP API is a high-performance, serverless-ready authentication system that delivers OTP codes directly through WhatsApp messages. Built with a custom Baileys fork (
noname089), sessions are securely stored on GitHub β making it cloud-native and infinitely scalable.
| π§© Feature | π Description |
|---|---|
| π Pairing API | Link WhatsApp accounts via pairing code |
| π¨ OTP Delivery | Send OTP with one-tap copy button |
| π¬ Custom Messages | Send any formatted text message |
| π€ Bot Management | Delete or check status of linked bots |
| βοΈ GitHub Sessions | Persistent sessions stored on GitHub |
| π Multi-Platform | Deploy on Vercel, VPS, or locally |
| π HTTPS Ready | Auto-generated self-signed certs for local dev |
| π§ Smart Reconnect | Auto-reconnects saved bots on startup |
graph LR
A["π Client"] -->|"HTTP Request"| B["β‘ Express Server"]
B -->|"/pair"| C["π² Pairing Engine"]
B -->|"/send"| D["π¬ Message Relay"]
B -->|"/manage"| E["π§ Bot Manager"]
B -->|"/health"| F["π Health Check"]
C --> G["π Baileys (noname089)"]
D --> G
G -->|"Session Sync"| H["π GitHub Storage"]
style A fill:#4000ff,color:#fff,stroke:#7c3aed
style B fill:#7c3aed,color:#fff,stroke:#4000ff
style G fill:#25D366,color:#fff,stroke:#128C7E
style H fill:#333,color:#fff,stroke:#666
π² 1. Request Pairing Code
GET /pair?number={phone_number}| Parameter | Type | Description |
|---|---|---|
number |
string |
Required. Phone number (digits only) |
β Success Response:
{
"status": "success",
"code": "WORK-CODE"
}{
"status": "already_authenticated",
"message": "This bot is already paired to api."
}π¬ 2. Send Message / OTP
GET /send?text={message}&botNumber={from}&receiver={to}| Parameter | Type | Description |
|---|---|---|
text or msg |
string |
Required. Message content |
botNumber |
string |
Required. Sender bot number |
receiver |
string |
Required. Destination number |
otp |
string |
Optional. OTP code β adds a π Copy OTP button |
β Success Response:
{
"status": "success",
"message": "Message sent"
}π‘ Pro Tip: When
otpis provided, the message is sent as an interactive view-once message with a native copy-code button!
π§ 3. Manage Bot
GET /manage?number={phone_number}&action=delete| Parameter | Type | Description |
|---|---|---|
number |
string |
Required. Bot phone number |
action |
string |
Required. Action to perform (delete) |
β Success Response:
{
"status": "success",
"message": "Bot {number} deleted."
}π 4. Health Check
GET /healthβ Response:
{
"status": "ok",
"bots": [
{
"number": "94710000000",
"status": "open",
"lastUpdate": "2026-03-24T14:00:00.000Z"
}
]
}π₯οΈ Local Development
# 1. Clone the repository
git clone https://github.com/udmodz0/auth-wa-api.git
cd auth-wa-api
# 2. Install dependencies
npm install
# 3. Configure environment
# Create config.env or .env with:
# GITHUB_REPO_URL=https://github.com/your-user/your-repo
# GITHUB_SECRET_KEY=ghp_your_personal_access_token
# 4. Start the server
npm startπ HTTPS Note: Local development uses a self-signed certificate. Click Advanced β Proceed to localhost in your browser to bypass the warning.
π£ Deploy to Vercel (Serverless)
- Connect your repository to Vercel
- Vercel auto-detects
vercel.json&api/index.js - Set Environment Variables in the Vercel dashboard:
| Variable | Value |
|---|---|
GITHUB_REPO_URL |
https://github.com/user/repo |
GITHUB_SECRET_KEY |
ghp_your_token |
NODE_ENV |
production |
- Deploy! π
β‘ Note: Vercel is serverless β bots connect on-demand when an API call is made.
βοΈ Deploy to VPS / Node.js Host
- Ensure Node.js 22+ is installed
- Clone the repository
- Set environment variables:
export GITHUB_REPO_URL="https://github.com/user/repo"
export GITHUB_SECRET_KEY="ghp_your_token"
export NODE_ENV="production"
export PORT=8080- Install & start:
npm install
npm start- The server auto-connects all saved bots from GitHub on startup β
auth-wa-api/
βββ π api/
β βββ index.js # π§ Core server β all routes & bot logic
βββ π vercel.json # β‘ Vercel serverless config
βββ π package.json # π¦ Dependencies & scripts
βββ π .gitignore # π« Ignores sessions, env files, node_modules
βββ π README.md # π You are here!
| Package | Purpose |
|---|---|
noname089 |
π Custom Baileys fork for WhatsApp Web API |
express |
β‘ Fast HTTP server framework |
@octokit/rest |
π GitHub API client for session storage |
cors |
π Cross-origin request handling |
dotenv |
π§ Environment variable management |
pino |
π Ultra-fast JSON logger |
selfsigned |
π Self-signed SSL certificate generation |
gradient-string |
π¨ Beautiful console gradients |
chalk |
ποΈ Terminal string styling |
axios |
π HTTP client |
adm-zip |
ποΈ ZIP file handling |
cheerio |
π HTML parser |
jimp |
πΌοΈ Image processing |
megajs |
βοΈ Mega cloud storage |
mongodb |
π MongoDB driver |
moment-timezone |
π Timezone-aware dates |
| Variable | Required | Description |
|---|---|---|
GITHUB_REPO_URL |
β | Full URL to your GitHub session storage repo |
GITHUB_SECRET_KEY |
β | GitHub Personal Access Token (PAT) with repo access |
NODE_ENV |
β | Set to production for HTTP mode (default: HTTPS with self-signed cert) |
PORT |
β | Server port (default: 8080) |
sequenceDiagram
participant C as π Client
participant S as β‘ Server
participant W as π± WhatsApp
participant G as π GitHub
Note over C,G: π Pairing Flow
C->>S: GET /pair?number=94710000000
S->>W: Request Pairing Code
W-->>S: Pairing Code
S->>G: Save Session
S-->>C: { code: "ABCD-EFGH" }
Note over C,G: π¨ Send OTP Flow
C->>S: GET /send?text=Your OTP: 1234&botNumber=...&receiver=...&otp=1234
S->>G: Load Session (if offline)
S->>W: Send Interactive Message with Copy Button
W-->>S: Delivery ACK
S-->>C: { status: "success" }
