Send Message API Documentation
Overview
The /v2/send endpoint allows you to send messages through various channels, supporting both direct messages and template-based messages. It supports attachments, variable substitution via templates, and advanced message customization.
Note:
Each successful call to /v2/send will return a unique message key for the sent message. Any updates regarding the status or delivery of that message (such as delivered, failed, read, etc.) will be sent asynchronously to your webhook endpoint.
See Webhook Documentation for details on webhook payloads and message status updates.
Endpoint
- Method: POST
- Path:
/v2/send - Content-Type:
multipart/form-data
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
| message | string | No* | Message text. Required unless using tempMsgID with template auto-fill |
| messageType | string | Yes | Type of message (e.g., "whatsapp", etc.) |
| tempMsgID | string | No | Template message ID. If provided, can auto-fill json and message |
| username | string | No | Username of the sender |
| json | string | No* | JSON payload for advanced/template messages. Required unless using tempMsgID |
| params | string | No | Comma-separated values to substitute template variables ({{N}}) in json/message |
| attachmentList | file[] | No | One or more files to attach to the message |
* Either message or json must be provided unless tempMsgID is used to auto-fill them.
Validation & Business Rules
- If
tempMsgIDis present and bothjsonandmessageare missing, the handler will retrieve them from the template. - If the template contains variables (
{{N}}), theparamsfield must be provided. The number of params must match the number of unique variables in the template. - Each
{{N}}in the template will be replaced by the corresponding value fromparams(in order). - If the number of params does not match the number of variables, the request will be rejected.
- Attachments are supported via the
attachmentListfield (multiple files allowed). messageOutKeyis auto-generated for each message.- All form fields are sent as part of a
multipart/form-datarequest.
Example Requests
1. Simple Direct Message - WhatsApp
Form Data:
- message:
Hello, this is a direct message! - messageType:
whatsapp - username:
966500000000
2. Template Message with Variable Substitution - WhatsApp
Form Data:
- tempMsgID:
TEMPLATE_ID - params:
John,ORD-12345 - messageType:
whatsapp - username:
966500000000
Behavior: The handler will fetch the template by tempMsgID, substitute {{1}} with "John" and {{2}} with "ORD-12345" in the template's JSON/message, and send the result.
3. Message with Attachments - WhatsApp
Form Data:
- message:
Here is your document. - messageType:
whatsapp - username:
966500000000 - attachmentList:
[file1.pdf, file2.jpg]
4. direct Message For instagram
Form Data:
- message:
Hello, this is a direct message! - messageType:
instagram - username:
instagram_user - attachmentList:
[image1.jpg, video1.mp4]
Error Handling
- 400 Bad Request:
- Failed to parse multipart form data
- Params count does not match number of variables in template
- 500 Internal Server Error:
- Failed to retrieve template by
tempMsgID - Failed to marshal or process data
- Failed to retrieve template by
- 502 Bad Gateway:
- Failed to call upstream service