Skip to content
API integration guide

API Quickstart

This guide covers the API calls for requesting and verifying an OTP. Live sending also requires an eligible package, a connected WhatsApp Business Account, an approved authentication template, and a reachable recipient; provider approval and delivery times vary.

1

Get your API key

  1. 1. Create an account, then choose a package and review its current terms
  2. 2. Go to Settings → API Keys
  3. 3. Click Create API Key and copy it
Keep your API key secret. Never commit it to source code. Use environment variables.
2

Install the SDK (optional)

If using Node.js, install the official SDK. Otherwise skip to step 3 and use cURL or fetch directly.

npm install @emacrontechnologies/outreachagent
3

Send your first OTP

Replace YOUR_API_KEY and YOUR_PHONE with your values.

Node.js

import { createClient } from '@emacrontechnologies/outreachagent';

const oa = createClient('YOUR_API_KEY');

const { request_id } = await oa.otp.send({
  phone: '+919876543210',   // E.164 format with country code
});

console.log('OTP sent! request_id:', request_id);

cURL

curl -X POST https://api.crm.emacronai.com/api/v1/whatsapp/otp/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone": "+919876543210"}'

Expected response

{
  "request_id": "7f6b2c24-9e1a-4a3e-b2a1-4c1d5e6f7a8b",
  "expires_in": 600,
  "channel": "whatsapp",
  "provider": "meta",
  "masked_phone": "+91*****43210",
  "delivery_status": "accepted"
}
4

Verify the OTP

After the user enters the OTP, call oa.otp.verify with the request_id from step 3.

// Node.js SDK — a failed verification throws; it does not resolve with valid:false
try {
  const { valid } = await oa.otp.verify(request_id, userEnteredOtp);
  // ✅ valid === true — phone number confirmed, log the user in
} catch (error) {
  // ❌ Wrong / expired OTP or too many attempts — show error to the user
}

What to explore next