AvenPing HTTP API v2 reference
This is the main API reference hub for AvenPing v2: authentication, plan rules,
phoneNumberIdownership, and JSON error codes. Endpoint details live on focused pages linked below.
Endpoint details are split into focused pages so the table of contents stays usable.
Prerequisites
- An API token from Settings → API Settings (Authentication)
- Premium or Enterprise with an active plan
- A linked WhatsApp Business account (except for public health/version routes)
Step-by-step
Send the auth header
UseAuthorization: Bearer YOUR_TOKENorX-API-Token: YOUR_TOKENon every protected request. Missing or invalid tokens return401 UNAUTHORIZED.Pick a phoneNumberId from GET /v2/me
Call GET /v2/me and copy a MetaphoneNumberIdfromphoneNumbers(ordefaultPhoneNumberIdwhen set). Ownership is checked against every linked WABA.Call the resource
Usehttps://api.avenping.complus the/v2/...path for the group you need. JSON bodies requireContent-Type: application/jsonand are limited to 2 MB.Read success and error envelopes
Success is{ "success": true, "data": ... }. Zod schema failures return400 VALIDATION_ERRORwithdetailsset to the issue list. A blocked contact returns403 FORBIDDEN. Meta Graph 4xx (other than 401/403/404) is mapped toVALIDATION_ERRORwith the Graph payload indetails.
| Topic | Page |
|---|---|
| Root URL, health, version (no token) | Public & meta |
| Current user, WABA id, phone number IDs | Account |
| Message templates | Templates |
| Flows (Meta) + DB search | Forms (flows) |
| Download media by Meta media id | Media |
Send messages (text, media, interactive, smart /send) | Messages |
| Outbound webhook URL (dashboard parity) | Webhooks |
For setup and your first calls, see Authentication & requirements. For Postman, see Postman collection.
Conventions
- Replace
https://api.avenping.comwith your environment’s base URL if different. - Replace
YOUR_TOKENwith your API token (Settings → API Settings). datafrom WhatsApp Graph (messages, templates list, flows from Meta, etc.) is largely a pass-through of Meta’s Cloud API. Exact fields vary by API version and resource; examples on each page are illustrative.
Base path: all v2 routes are under /v2.
Content-Type: use application/json for request bodies (when applicable).
Body size limit: 2 MB per JSON body.
Authentication
Send the same secret you see in the AvenPing app under Settings → API Settings (API access token).
| Method | How |
|---|---|
| Bearer | Header Authorization: Bearer <token> |
| Header | X-API-Token: <token> |
If the token is missing or invalid, the API responds with 401 and code UNAUTHORIZED.
Example (Bearer):
bash
curl -sS "https://api.avenping.com/v2/me" \
-H "Authorization: Bearer YOUR_TOKEN"More detail: Authentication & requirements.
Access rules (after auth)
Middleware order matters:
requireAuthToken— valid user, linked WhatsApp account with MetaaccessToken. If the user has no WhatsApp account configured, you may see404NOT_FOUNDwith message WhatsApp account not found.requireActivePlan— primary (non–add-on) plan must not be past its end date. Otherwise403PLAN_EXPIRED.requirePremiumOrEnterprise— primary plan name must be Premium or Enterprise. Otherwise403DEVELOPER_PLAN_REQUIRED.
These apply to every /v2/* route except the routes on Public & meta (GET /v2/health, GET /v2/version).
Phone number ownership
These routes require a JSON body field phoneNumberId (Meta Phone number ID). The server checks that this ID belongs to any WhatsApp account linked to your token (not only the default WABA on GET /v2/me):
- All routes under
/v2/messages/* POST /v2/templates/sendPOST /v2/templates/:name/test-sendPOST /v2/media/upload(form field orX-Phone-Number-Idheader)
Optional query phoneNumberId or accountId on list routes (GET /v2/templates, GET /v2/forms, media download) selects which linked WABA to use.
Use GET /v2/me to list valid phoneNumberId values for your token.
If phoneNumberId is missing: 400 VALIDATION_ERROR.
If it is not linked to your account: 403 FORBIDDEN (phoneNumberId does not belong to this account).
Success response shape
Most JSON endpoints return:
json
{
"success": true,
"data": {}
}The data object (or array) is endpoint-specific. Message send and template send endpoints usually return Meta’s send-message response inside data (e.g. messaging_product, contacts, messages with id / WAMID). See Messages for a typical send payload.
Error response shape
Structured errors use:
json
{
"success": false,
"error": "ERROR_CODE",
"message": "Human-readable message",
"details": null
}details is omitted when empty; some errors may attach structured details.
Example (401):
json
{
"success": false,
"error": "UNAUTHORIZED",
"message": "Missing API token"
}Error codes (application)
| HTTP | error | Typical cause |
|---|---|---|
| 401 | UNAUTHORIZED | Missing/invalid token, deleted user |
| 403 | FORBIDDEN | phoneNumberId / accountId not owned, or contact is blocked on the line |
| 403 | PLAN_EXPIRED | Subscription ended |
| 403 | DEVELOPER_PLAN_REQUIRED | Plan is not Premium/Enterprise |
| 400 | VALIDATION_ERROR | Bad input, missing required fields, Zod parse failure, or Meta 4xx |
| 404 | NOT_FOUND | Resource missing (template, media URL, unknown route) |
| 500 | INTERNAL_ERROR | Unexpected failure, upstream/Graph failure surfaced as generic error |
| 502 | INTERNAL_ERROR | Media download proxy failed (message: Failed to download media) |
Note: Zod schema failures return 400 VALIDATION_ERROR with details set to the issue list. Malformed JSON (not parsed into an object) still fails as 500 INTERNAL_ERROR from the body parser in some cases.
FAQ
Which routes skip authentication?
Only GET /v2/health and GET /v2/version (plus the non-versioned GET / landing). Every other /v2/* route needs a valid token, an active plan, and Premium or Enterprise.
When is phoneNumberId required?
JSON body phoneNumberId is required on all /v2/messages/*, POST /v2/templates/send, POST /v2/templates/:name/test-send, and POST /v2/media/upload. List routes accept optional phoneNumberId or accountId to pick a linked WABA. Missing id: 400 VALIDATION_ERROR. Not owned: 403 FORBIDDEN.
How are Zod and Graph errors returned?
Zod schema failures return 400 VALIDATION_ERROR with details set to the issue list. Malformed JSON (not parsed into an object) can still fail as 500 INTERNAL_ERROR from the body parser. Meta Graph 401/403/404 keep those statuses; other Graph 4xx map to VALIDATION_ERROR with the Graph payload in details.
What does 403 FORBIDDEN mean on a send?
Either phoneNumberId / accountId is not linked to your token, or the WhatsApp contact is blocked on that line (Contact is blocked on this WhatsApp line). Blocked sends do not call Meta.