Overview
Unifonic provides APIs that allow you to send WhatsApp messages, including templates with dynamic content, media attachments, product catalogs, and session messages. The API supports various types of messages such as text, templates, product lists, OTPs, and more.
Base URL
All endpoints are accessible via the following base URL:
arduinohttps://apis.unifonic.com/v1
Authentication
To interact with the API, you will need:
- PublicId: Your unique public ID for authentication.
- Secret: Your secret key used for signing requests.
You will need to pass these values in the request headers.
Headers
Each API request should include the following headers:
- PublicId: Your unique public ID.
- Secret: Your secret API key.
- Content-Type:
application/json
Example headers:
json{ "PublicId": "your-public-id", "Secret": "your-secret-key", "Content-Type": "application/json" }
Endpoints
1. Send Multi-Product Message
Sends a WhatsApp message with a product catalog, which includes a header, body, footer, and product sections.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "productList", "header": { "type": "text", "text": "Unifonic Demo T-Shirts" }, "body": "We have selected a few items that you might be interested in from the Unifonic catalog, you can view them below", "footer": { "text": "Unifonic Team" }, "catalogId": "{{catalogId}}", "sections": [ { "title": "Offers", "productItems": [ { "productRetailerId": "{{productId1}}" }, { "productRetailerId": "{{productId2}}" } ] }, { "title": "New Arrivals", "productItems": [ { "productRetailerId": "{{productId3}}" } ] } ] } }
2. Get Message Status
Retrieves the status of a sent message based on its messageId.
Endpoint:
bashGET /messages/status
Parameters:
messageIds: A comma-separated list of message IDs for which you want the status.
Request URL Example:
bashhttps://apis.unifonic.com/v1/messages/status?messageIds=6743a513-ece2-4d87-9c8c-599712f8e3c3
3. Send Template Message with Variables
Sends a template message with dynamic variables, such as names or amounts.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_account_update", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "Name" }, { "type": "text", "text": "Tester" }, { "type": "text", "text": "100 SAR" } ] } ] } }
4. Send Template Message with Image
Sends a template message that includes an image in the header.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_ticket_update", "language": { "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "image", "url": "https://www.unifonic.com/hubfs/PressRelease_CBM.png" } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "Spider Man" }, { "type": "text", "text": "1 Jan" }, { "type": "text", "text": "ABC Cinema" } ] } ] } }
5. Send Template Message with Quick Reply Buttons
Sends a template message with quick reply buttons (e.g., "Attending", "Not Attending").
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_appointment_update", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "Name" }, { "type": "text", "text": "1 Jan" }, { "type": "text", "text": "12:00 pm" } ] }, { "type": "options", "parameters": [ { "value": "Attending", "subType": "quickReply", "index": 0 }, { "value": "Not Attending", "subType": "quickReply", "index": 1 }, { "value": "Will Confirm later", "subType": "quickReply", "index": 2 } ] } ] } }
6. Send Template Message with PDF
Sends a template message with a PDF document in the header.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_reservation_update", "language": { "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "file", "fileName": "Sample.pdf", "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "Name" } ] } ] } }
7. Send Template Message with Call to Action
Sends a template message with a Call to Action (CTA).
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_shipping_update", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "Name" } ] } ] } }
8. Send OTP Template
Sends an OTP (One Time Password) template message.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "template", "name": "sandbox_otp", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "123456" } ] }, { "type": "options", "parameters": [ { "value": "123456", "subType": "url", "index": 0 } ] } ] } }
9. Send Session Message
Sends a simple WhatsApp message (e.g., a welcome message) within a session.
Endpoint:
bashPOST /messages
Request Body:
json{ "recipient": { "contact": "{{phoneNumber}}", "channel": "whatsapp" }, "content": { "type": "text", "text": "Welcome to Unifonic" } }
Variables
The following variables should be provided in the request body or set in Postman:
| Variable | Description |
|---|---|
PublicId | Your public API key. |
Secret | Your secret API key. |
phoneNumber | The recipient's phone number. |
catalogId | The ID of the product catalog. |
productId1 | The ID of the first product. |
productId2 | The ID of the second product. |
productId3 | The ID of the third product. |
urlFilePdf | URL for a PDF file. |
urlImagePng | URL for a PNG image. |
urlImageJpg | URL for a JPG image. |
urlVideoMp4 | URL for an MP4 video. |
urlAudioMp3 | URL for an MP3 audio file. |
mediaId | Media ID for a sent file. |
Error Handling
- 400 Bad Request: Invalid request data, missing required fields, or incorrect format.
- 401 Unauthorized: Invalid
PublicIdorSecret. - 404 Not Found: Endpoint not found.
- 500 Internal Server Error: Server-side issues.