Whatsapp Number verification

WhatsApp Number Verification API

Verify if a phone number is active on WhatsApp — Single or Bulk.

This endpoint is part of the Baileys REST Mongo API and is secured using Hybrid Authentication, meaning it supports both API Keys and JWT tokens.

Internally, this API uses the Baileys function:

sock.onWhatsApp(jid)

to check whether a number exists on WhatsApp and automatically logs verification history into the database (VerifiedNumber model).


🔗 Endpoints

1️⃣ Verify Single Number

POST https://api.walytic.com/api/verify/:sessionId/verify-single

2️⃣ Bulk Number Verification (Excel / CSV Upload)

POST https://api.walytic.com/api/verify/:sessionId/bulk-verify

3️⃣ Fetch Verification History

GET https://api.walytic.com/api/verify/history

4️⃣ Export Verification History (CSV / XLSX)

GET https://api.walytic.com/api/verify/export?format=csv

5️⃣ Clear Verification History

DELETE https://api.walytic.com/api/verify/clear

🔐 Required Headers

Header

Type

Required

Description

x-api-key

String

✅ Yes

Your API key

Authorization

String

Optional

Bearer JWT token

Content-Type

String

Required for single verify

application/json

Content-Type

Multipart

Required for bulk verify

multipart/form-data


📤 Single Number Verification

POST /verify/:sessionId/verify-single

Request Body

Field

Type

Description

number

String

Phone number with country code (e.g., "919876543210")

Example Request (Node.js)

const axios = require("axios");

async function verifyNumber() {
  const res = await axios.post(
    "https://api.walytic.com/api/verify/session-919876543210/verify-single",
    {
      number: "919812345678"
    },
    {
      headers: {
        "x-api-key": "YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log(res.data);
}

verifyNumber();

📦 Success Response

{
  "number": "919812345678",
  "status": "Valid"
}

Error Response

{
  "error": "Number is required"
}

📥 Bulk Verification (Excel / CSV File)

POST /verify/:sessionId/bulk-verify

Upload a .xlsx or .csv file containing a column of phone numbers.

Form Data

Key

Type

Required

file

File

Yes

📤 Example (cURL)

$curl -X POST https://api.walytic.com/api/verify/session-919876543210/bulk-verify \
-H "x-api-key: YOUR_API_KEY" \
-F "file=@numbers.xlsx"

📦 Sample Response

{
  "results": [
    { "number": "919812345678", "status": "Valid" },
    { "number": "918888888888", "status": "Invalid" },
    { "number": "12345", "status": "Error" }
  ]
}

📊 Verification History API

GET /verify/history

Query

Description

session

Optional filter by sessionId

Example Response

[
  {
    "_id": "67123kd91",
    "sessionId": "session-919876543210",
    "number": "919812345678",
    "status": "Valid",
    "timestamp": "2024-01-10T12:44:22.123Z"
  }
]

📤 Export Verification Log (CSV / XLSX)

GET /verify/export?session=ID&format=csv

Supported formats:

  • csv

  • xlsx

Example:

https://api.walytic.com/api/verify/export?session=session-919876543210&format=xlsx

🗑️ Clear Verification History

DELETE /verify/clear?session=session-919876543210

Response

{
  "success": true,
  "message": "Cleared history for session session-919876543210",
  "deletedCount": 20
}

🧠 Internal Workflow (For Developers)

When a number is verified:

  1. The route calls:
    getSession(sessionId)

  2. Extracts the active WhatsApp socket:

    const sock = session?.sock;
    
  3. Formats JID:

    const jid = `${number.replace(/\D/g, '')}@s.whatsapp.net`;
    
  4. Baileys checks:

    const exists = await sock.onWhatsApp(jid);
    
  5. Result saved into DB:
    VerifiedNumber.create({ sessionId, number, status })

  6. Response returned to client.


🔒 Authentication Flow

  • External apps → use x-api-key

  • Dashboard users → use JWT

  • Middleware:
    hybridAuth validates automatically
    (supports both methods)


⚙️ Notes

  • WhatsApp session must be connected.

  • Works with multi-device sessions.

  • Bulk verification supports:

    • .csv

    • .xlsx

    • column-based input

  • Maximum performance depends on Baileys rate limits.