# RunOTP - Complete Developer & AI Integration Specification (llms.txt) > What is RunOTP? > RunOTP (https://runotp.com) is a Dual-Channel Reverse / Inbound WhatsApp & Telegram OTP + 2-Way WhatsApp Gateway. > Instead of sending outbound SMS (expensive and vulnerable to SMS pumping fraud), the end-user verifies their phone by sending one pre-filled WhatsApp message OR tapping Share Phone Number in RunOTP's official Telegram bot (both built into Flash Start and REST API). > Pricing is prepaid pay-as-you-go in USD (flat $0.01 per unique verified WhatsApp or Telegram OTP; $1.00 free trial credit on signup; $9.00/30 days optional Dedicated VIP WhatsApp number; $0.02 outbound VIP media/PDF). --- ## 0. Canonical Base URLs & Global Rules (READ FIRST) - REST API v1 Base URL: https://api.runotp.com/v1 (all responses & webhooks include header X-RunOTP-API-Version: 1.0) - POST /v1/links (Generate WhatsApp & Telegram verification links + QR) - POST /v1/messages (Dedicated VIP outbound WhatsApp text/media/PDF) - POST /v1/flash/verify (Verify & atomically burn Flash Start one-time token) - POST /v1/flash/config (1-click Flash Start auto-configuration) - Hosted Flash Start UI Base URL: https://runotp.com - Official Plugins & Starter Kits: https://runotp.com/Integrations.aspx - WooCommerce 1-Click Auto-Setup Plugin: https://runotp.com/download/runotp-woocommerce.zip - Shopify / Salla / Zid / EasyOrders Free Worker Kit: https://runotp.com/download/runotp-shopify-kit.zip - Laravel Kit: https://runotp.com/download/runotp-laravel.zip - Node.js / Express Kit: https://runotp.com/download/runotp-nodejs.zip - Native PHP / OpenCart Kit: https://runotp.com/download/runotp-php.zip - Phone Number Format (everywhere): International digits ONLY - no "+", no spaces, no leading "00". - Example: Egypt 201012345678, Saudi Arabia 966501234567, UAE 971501234567, USA 14155550199. - Always normalize stored local numbers (e.g. 010... -> 2010...) before comparing with sender / phone. - Security Rule: NEVER expose apiSecret in browser/frontend JavaScript, mobile apps, or public Git repos. Use apiSecret strictly on your backend server. --- ## 1. Choose the Right Integration Path - Path A - Flash Start (RECOMMENDED - 3 Minutes - Zero UI - Zero Webhooks - Works on localhost) - Best for web apps, e-commerce checkouts, WordPress/WooCommerce, Shopify, Laravel, Next.js, and high-concurrency signups. - Supports Dual-Channel verification out of the box: WhatsApp + 1-tap Telegram bot (configurable as both, whatsapp, or telegram in FlashStart.aspx). - You redirect the user to https://runotp.com/Go.aspx, RunOTP handles QR/WhatsApp/Telegram/polling/Arabic RTL UI, and redirects back to your flash_redirect_url?token=...&client_ref=... - Your backend calls POST https://api.runotp.com/v1/flash/verify once to burn the token and get the verified phone number and channel. - Path B - Custom REST API & Webhooks (Full Native UI Control) - Best for native mobile apps or custom-built OTP screens. - Your backend calls POST https://api.runotp.com/v1/links, shows the returned url/qr, polls your own backend status endpoint from the frontend, and receives verification via your HTTPS Webhook. - Path C - Dedicated VIP Outbound Messaging (Optional Add-On) - Requires connecting your own WhatsApp number in https://runotp.com/Settings.aspx#dedicated. - Enables POST https://api.runotp.com/v1/messages (text, images, videos, audio, PDFs) and optional Catch-All inbound replies. --- ## 2. Path A: Flash Start (3-Minute Hosted Flow) ### Step A1 - Configure via Dashboard OR Programmatically (1-Click Auto-Setup) Option 1 (Manual): Go to https://runotp.com/FlashStart.aspx and save your Success Redirect URL, brand name, logo, and theme. Option 2 (Programmatic Auto-Setup for Plugins & Apps): Endpoint: POST https://api.runotp.com/v1/flash/config Headers: ``` Content-Type: application/json x-api-secret: YOUR_API_SECRET ``` JSON Body: ```json { "apiKey": "YOUR_API_KEY", "apiSecret": "YOUR_API_SECRET", "redirectUrl": "https://yourstore.com/verify/callback", "brandName": "My Store", "theme": "auto", "brandColor": "#D4AF37", "isDark": true, "channels": "both" } ``` Options: - `channels`: `"both"` (WhatsApp + Telegram fallback, default), `"whatsapp"`, or `"telegram"`. - `theme`: Pass `"auto"` with optional `"brandColor"` (hex) and `"isDark"` (`true`/`false`), or lock any explicit theme: dark_emerald, clean_light, royal_blue, light_blue, luxury_gold, modern_purple, sunset_orange, crimson_red, mint_fresh, slate_minimal. (Pass `"action": "status"` to check balance and current config without modifying anything.) ### Step A2 - Redirect User to Hosted Verification Page Send the user to: ``` https://runotp.com/Go.aspx?key=YOUR_API_KEY&ref=YOUR_CLIENT_REF&lang=en&channel=both ``` Query parameters: - key (required): Your apiKey. - ref (optional): Any internal ID (e.g. ORDER_9021 or USER_42) echoed back after verification. - lang (optional): en (default LTR) or ar (full Arabic RTL UI; users can also toggle live). - channel (optional): both (default), whatsapp, or telegram (overrides dashboard default per session). When the user completes WhatsApp or Telegram verification, RunOTP automatically redirects them to: ``` YOUR_REDIRECT_URL?token=ONE_TIME_TOKEN&client_ref=YOUR_CLIENT_REF ``` ### Step A3 - Verify & Burn Token on Your Backend Endpoint: POST https://api.runotp.com/v1/flash/verify Headers: ``` Content-Type: application/json x-api-secret: YOUR_API_SECRET ``` JSON Body: ```json { "token": "ONE_TIME_TOKEN" } ``` Success Response (HTTP 200): ```json { "verified": true, "phone": "201012345678", "client_ref": "YOUR_CLIENT_REF", "verified_channel": "whatsapp" } ``` (`verified_channel` is `"whatsapp"` or `"telegram"`.) Failure / Replay Response: ```json { "verified": false, "message": "Invalid, burned, or expired token" } ``` CRITICAL PITFALL (Burn-on-First-Read): - POST /v1/flash/verify atomically burns the token on the very first valid call (valid for 24h UTC). - NEVER call POST /v1/flash/verify from client-side React useEffect (React StrictMode fires twice -> 2nd call returns verified: false). - Always verify inside a server route/controller, immediately save verified_phone in your user session or DB, and redirect to a clean URL without ?token=... so browser refreshes do not re-verify a burned token. --- ## 3. Path B: Custom REST API & Webhooks ### Step B1 - Generate Dynamic WhatsApp / Telegram Link & QR Code Endpoint: POST https://api.runotp.com/v1/links JSON Body: ```json { "apiKey": "YOUR_API_KEY", "apiSecret": "YOUR_API_SECRET", "msg": "Please (YOUR_API_KEY) verify my account with code (482910)", "channel": "both", "lang": "en" } ``` - `channel` (optional): `"both"` (default — populates both WhatsApp `url`/`qr` and Telegram `telegramUrl`/`telegramQr`), `"whatsapp"` (populates `url`/`qr`; Telegram fields return `""`), or `"telegram"` (populates `telegramUrl`/`telegramQr`; WhatsApp fields return `""`). - `lang` (optional): `"en"` (default) or `"ar"` — controls the Telegram bot prompt language only (does not translate your WhatsApp `msg`). Success Response (HTTP 200 — always returns all 6 fields consistently): ```json { "url": "https://wa.me/201099999999?text=Please%20(YOUR_API_KEY)%20verify...", "qr": "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=...", "telegramUrl": "https://t.me/RunOtpVerifyBot?start=tg_...", "telegramQr": "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=...", "channel": "both", "notes": "Success" } ``` CRITICAL PITFALLS for POST /v1/links: 1. Strict Brackets Rule: RunOTP parses the 1st parentheses pair as apiKey and the 2nd parentheses pair as otp, and automatically appends ", Ref#". NEVER place extra parentheses (...) before (YOUR_API_KEY) or between (YOUR_API_KEY) and (OTP). - GOOD: "Please (MyApp) verify my login with code (482910)" - BAD: "Welcome (VIP) to (MyApp) code (482910)" -> fails with 403 API Key mismatch! 2. Rate Limit: Authenticated POST /v1/links allows up to 60 requests per minute per API Key (multi-user backend servers supported). Hosted Go.aspx enforces 1 request / 20s per end-user browser IP. Invalid API keys are blocked after 15 failed attempts / 5 min per IP. 3. Store OTP with TTL: Generate a random 6-digit OTP and store it in your DB/cache with a 5-minute TTL before displaying the link. ### Step B2 - Receive Inbound Webhook on Your Server Configure your HTTPS Webhook URL in https://runotp.com/Settings.aspx (Tab 2: Webhook & Testing). Golden Webhook Delivery Rules (CRITICAL): 1. NO HTTP Redirects (AllowAutoRedirect = False): Use the exact final canonical URL! If https://site.com/webhook redirects (301/302) to https://www.site.com/webhook or adds/removes trailing "/", delivery FAILS. 2. Respond within 5 Seconds: RunOTP enforces a 5000ms timeout. Verify signature, persist to DB/queue, and return HTTP 200 immediately. 3. Valid Public HTTPS SSL: Self-signed or expired certificates fail with 526. Private/localhost IPs are blocked. 4. Automatic Retries: Transient 5xx, 408, 429, and network errors are retried up to 3 attempts (immediate, +1.5s, +4.5s). Permanent 4xx stops immediately. Deduplicate using X-Idempotency-Key. Incoming HTTP Headers: - Content-Type: application/json; charset=utf-8 - X-RunOTP-Timestamp: Unix timestamp in UTC seconds. - X-RunOTP-Signature: sha256= = HMAC_SHA256("{X-RunOTP-Timestamp}.{rawBody}", apiSecret). - X-Idempotency-Key: Unique message reference ID. - X-Retry-Attempt: 1, 2, or 3. Decrypted JSON Payload: ```json { "event": "otp_received", "channel": "whatsapp", "key": "YOUR_API_KEY", "sender": "201012345678", "otp": "482910", "message": "Please (YOUR_API_KEY) verify my account with code (482910), Ref#1796050000000", "message_id": "1796050000000", "media_url": "", "balance": 14.85, "timezone": "+02:00", "timestamp": "2026-12-02 15:30:00" } ``` (`channel` is `"whatsapp"` or `"telegram"`.) Required HTTP 200 Response: ```json { "code": "200", "status": "success" } ``` ### Step B4 - HMAC Verification & AES-256-CBC Decryption (EXACT SPEC) CRITICAL PITFALL (AES-256 + Content-Type: application/json): If Payload Encryption (AES-256) is enabled in Settings, RunOTP sends the HTTP body as a raw Base64 string (NOT JSON) while still sending Content-Type: application/json; charset=utf-8! - Node.js / Express: Use express.text({ type: '*/*' }) on the webhook route instead of express.json(). - FastAPI (Python): Use raw_body = (await request.body()).decode("utf-8"). - Laravel: Use $rawBody = $request->getContent();. Exact AES-256-CBC Format (SimpleCrypto): - Key: SHA-256(UTF8_NoBOM(apiSecret)) -> 32 raw bytes. - Wire format: Base64( IV[16 bytes] || AES_256_CBC_PKCS7_Ciphertext ). - X-RunOTP-Signature is ALWAYS computed over the exact transmitted rawBody (before decryption). ```javascript const express = require('express'); const crypto = require('crypto'); const app = express(); const API_SECRET = process.env.RUNOTP_API_SECRET; function verifyRunOtpSignature(rawBody, timestamp, signature, secret) { if (!timestamp || !signature) return false; if (Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp)) > 300) return false; const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex'); const a = Buffer.from(expected, 'utf8'); const b = Buffer.from(signature, 'utf8'); return a.length === b.length && crypto.timingSafeEqual(a, b); } function decryptRunOtpPayload(base64Body, secret) { const raw = Buffer.from(base64Body.trim(), 'base64'); const iv = raw.subarray(0, 16); const encrypted = raw.subarray(16); const key = crypto.createHash('sha256').update(secret, 'utf8').digest(); const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv); return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8'); } app.post('/runotp/webhook', express.text({ type: '*/*' }), async (req, res) => { const rawBody = typeof req.body === 'string' ? req.body : ''; if (!verifyRunOtpSignature(rawBody, req.header('X-RunOTP-Timestamp'), req.header('X-RunOTP-Signature'), API_SECRET)) { return res.status(401).json({ code: '401', status: 'invalid_signature' }); } const jsonText = rawBody.trim().startsWith('{') ? rawBody : decryptRunOtpPayload(rawBody, API_SECRET); const data = JSON.parse(jsonText); return res.status(200).json({ code: '200', status: 'success' }); }); ``` --- ## 4. Path C: Dedicated VIP Outbound Messaging API Requires an active Dedicated VIP WhatsApp session paired in https://runotp.com/Settings.aspx#dedicated. Endpoint: POST https://api.runotp.com/v1/messages JSON Body: ```json { "apiKey": "YOUR_API_KEY", "apiSecret": "YOUR_API_SECRET", "destinationNumber": "201012345678", "message": "Your order #9021 has been confirmed!", "mediaUrl": "", "clientRef": "ORD_9021", "typingDelay": 2000 } ``` - `typingDelay` (optional): Simulated typing indicator duration in **milliseconds** (e.g. `2000` = 2 seconds; default `2000`, max `10000`). - `mediaUrl` (optional): Public HTTPS URL to image, video, audio, or PDF (<= 10MB). Billed at $0.02 (text is $0.01) in addition to the $9.00/30-day Dedicated VIP subscription. - If your dedicated WhatsApp device is disconnected, RunOTP returns HTTP 503 (never falls back to shared numbers). - Send outbound messages only to users who messaged you first (within 24h) and always follow Meta's latest WhatsApp policies. --- ## 5. Quick HTTP Status Code Reference - 200 OK: Success (or safe duplicate acknowledgement). - 400 Bad Request: Missing field, invalid (ApiKey)(OTP) brackets, or blocked SSRF URL. - 401 / 403: Invalid apiKey / apiSecret, mismatched key, suspended account, or burned/expired Flash token. - 402 Payment Required: Insufficient wallet balance. Top up at https://runotp.com/TopUp.aspx. - 429 Too Many Requests: Rate limit exceeded (POST /v1/links: 60 req/min per API Key; hosted Go.aspx: 1 req/20s per end-user IP; FlashVerify: 60 req/min; FlashConfig: 20 req/min). - 503 Service Unavailable: Dedicated VIP WhatsApp session disconnected - re-pair via QR at https://runotp.com/Settings.aspx#dedicated.