Authentication
All EmacronAI CRM API requests are authenticated using a Bearer token in the HTTP Authorization header. Your API key is the token.
Getting your API key
- 1Create an account, then choose a package and review its current terms
- 2Go to Settings → API Keys
- 3Click Create API Key, give it a name, and copy it
- 4Store it in your environment as
OUTREACHAGENT_API_KEY
Using your API key
Include the Authorization header in every request:
Authorization: Bearer YOUR_API_KEYcURL
curl https://api.crm.emacronai.com/api/v1/whatsapp/otp/send \
-H "Authorization: Bearer $OUTREACHAGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone": "+919876543210"}'Node.js (SDK)
import { createClient } from '@emacrontechnologies/outreachagent';
// Reads process.env.OUTREACHAGENT_API_KEY automatically
const oa = createClient(process.env.OUTREACHAGENT_API_KEY);Environment best practices
✓Store key in environment variable: OUTREACHAGENT_API_KEY=...
✓Add .env to .gitignore to prevent accidental commits
✓Use separate keys for development and production
✕Never hardcode keys in source code
✕Never commit keys to git or expose in client-side JS
✕Never share keys in Slack, email, or screenshots
API key scopes
| Scope | Allows |
|---|---|
| whatsapp:send | Send approved WhatsApp template messages |
| whatsapp:otp | Send and verify OTPs for the assigned project and template |
| whatsapp:otpless | Create and poll OTPless sessions for the assigned project |
| whatsapp:templates:manage | List, create, and delete WhatsApp templates on the assigned senders |
| contacts:write | Create and update contacts (no delete — contacts are not removed via the API) |
| contacts:read | Read contact data |
| conversations:read | Read conversation threads and message history |
| leads:read | Read leads and pipeline stages |
| campaigns:read | Read campaign data |
| pipelines:read | Read pipelines and deal boards |
Webhook management (register, list, delete /api/v1/webhooks) is authorized by any valid API key — it does not use a separate scope. OTP and OTPless keys additionally restrict sends to their assigned project and template.
Authentication errors
| Code | Name | Cause | Fix |
|---|---|---|---|
| 401 | Unauthorized | Missing or invalid API key | Check Authorization header is present and formatted as "Bearer API_KEY" |
| 403 | Forbidden | Key has insufficient permissions | Check key scopes in Settings → API Keys |
| 429 | Too Many Requests | Rate limit exceeded | Respect Retry-After header; implement exponential backoff |