Skip to content

udmodz0/whatsapp-auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Node.js Express WhatsApp Vercel

Version License Status


β–ˆβ–ˆβ•—β–‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β•
β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–‘β•šβ•β•β–‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β–‘β–‘β–‘β–‘β–‘β•šβ•β•β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•

Β About

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

Β Architecture

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
Loading

Β API Endpoints

πŸ“² 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"
}

⚠️ Already Paired:

{
  "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 otp is 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"
    }
  ]
}

βš™οΈ Tech Stack

Node.js
Node.js
β‰₯ 22
Express
Express
v4.18
GitHub
Octokit
Session Store
Vercel
Vercel
Serverless

πŸš€ Deployment

πŸ–₯️ 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)
  1. Connect your repository to Vercel
  2. Vercel auto-detects vercel.json & api/index.js
  3. 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
  1. Deploy! πŸš€

⚑ Note: Vercel is serverless β€” bots connect on-demand when an API call is made.

☁️ Deploy to VPS / Node.js Host
  1. Ensure Node.js 22+ is installed
  2. Clone the repository
  3. 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
  1. Install & start:
npm install
npm start
  1. The server auto-connects all saved bots from GitHub on startup βœ…

πŸ“ Project Structure

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!

πŸ“¦ Dependencies

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

⚠️ Environment Variables

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)

πŸ” How It Works

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" }
Loading

πŸ‘¨β€πŸ’» Creator

UDMODZ
GitHub



⭐ Star this repo if you found it useful!


🚫 This is a FREE API β€” Do NOT sell it.

Made with πŸ’œ by UDMODZ



About

A simple nodejs based whatsapp api for otp verfication by UDMODZ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors