ΩOmegaAPIFreelancer Developers API Documentation v1 ← Panel

📖 OmegaAPI — Documentation

Base URL: https://omegaapi.in/api/v1

1. Authentication

Har request me apni API key header me bhejo (panel → API Key section se milegi):

X-API-Key: wag_xxxxxxxxxxxxxxxxxxxxxxxx

Alternative: Authorization: Bearer wag_...

2. Endpoints

GET/api/v1/me

Apna account info — balance, agent limit.

{
  "email": "client@website.com",
  "balance": -1,          // -1 = unlimited, 0+ = remaining SMS credits
  "allowed_agents": 2,
  "created_at": "..."
}

GET/api/v1/agents

Sabhi aapke agents ki list aur unka live status.

{
  "agents": [
    { "id": 1, "label": "OTP Agent", "phone": "919876543210", "status": "live", "connected": true }
  ]
}

POST/api/v1/send-text

Message bhejna. Balance 1 SMS credit katata hai (agar unlimited nahi).

POST /api/v1/send-text
{
  "agentId": 1,               // aapka agent ID (GET /agents se milega)
  "to": "919876543210",       // receiver number (country code ke saath, no +)
  "message": "Hello! Your booking is confirmed ✅"
}

Response: { "ok": true, "agentId": 1, "to": "919876543210" }

GET/api/v1/messages

Chat records (received + sent messages). OTP body me hota hai, encrypted DB me.

GET /api/v1/messages?agentId=1&limit=50

{
  "messages": [
    { "id": 42, "agentId": 1, "chat": "919876543210@s.whatsapp.net",
      "sender": "9198...", "senderName": "John", "body": "Your code is 4821",
      "fromMe": false, "hasOtp": true, "timestamp": "..." }
  ]
}

GET/api/v1/otp

⚡ Main endpoint: latest incoming OTP (auto-extracted, decrypted on-the-fly). Poll karte raho ya webhook use karo.

GET /api/v1/otp?agentId=1

{
  "id": 42, "agentId": 1, "chat": "919876543210@s.whatsapp.net",
  "sender": "9198...", "otp": "4821",
  "body": "Your code is 4821. Do not share.", "timestamp": "..."
}

OTP abhi nahi aaya → 404. Tip: OTP naye aane pe hi chahiye to apne side pe last OTP id yaad rakho, naya id aaye to process karo.

POST/api/v1/webhook

Apna webhook URL set karo — har incoming message (aur OTP) real-time wahan POST hoga:

POST /api/v1/webhook
{ "url": "https://your-website.com/wa-webhook" }

3. Webhook Payload & Verification

POST https://your-website.com/wa-webhook
Headers:
  Content-Type: application/json
  X-Event: message
  X-Signature: sha256=<HMAC-SHA256(webhook_secret, raw_body)>

Body:
{
  "event": "message",
  "agentId": 1,
  "chat": "919876543210@s.whatsapp.net",
  "sender": "919876543210",
  "senderName": "John",
  "body": "Your code is 4821",
  "otp": "4821",            // agar OTP detect hua (warna null)
  "timestamp": "2026-11-12T..."
}

Security: signature verify karo taaki sirf gateway se aaye request:

// Node.js example
const expected = 'sha256=' + crypto.createHmac('sha256', WEBHOOK_SECRET).update(rawBody).digest('hex');
if (expected !== req.headers['x-signature']) return res.status(401).end();

4. Quick Start (customer website integration)

// 1. Agent live karo (panel se QR scan)
// 2. Test:
curl -X POST https://omegaapi.in/api/v1/send-text \
  -H "X-API-Key: wag_..." \
  -H "Content-Type: application/json" \
  -d '{"agentId":1,"to":"919876543210","message":"Hi from my website!"}'

// 3. OTP poll:
curl https://omegaapi.in/api/v1/otp?agentId=1 -H "X-API-Key: wag_..."

5. Rules & Notes

6. Error Codes

CodeMeaning
401Invalid/missing API key
402Balance khatam (top-up admin se)
403Account suspended
404Agent/OTP not found
409Agent not live (QR scan karo)