Idempotency & Conversion Events
This page covers several API-level behaviors that make your integration safe on retry and connected with conversion data: the Idempotency-Key header to prevent duplicate WhatsApp and SMS sends, the POST /v1/events/conversions endpoint to report conversion events back to Mahadata, the processing_strategy field that controls how a message is processed, and the 402 Payment Required response when balance, message quota, or budget plan is exhausted. This guide is intended for developers integrating directly with the Mahadata messaging API.
These features are API-only — there is no dedicated portal page; you enable them via HTTP request headers and body fields. Credentials are managed in Developer > API Key (lihat di portal).
Header Idempotency-Key
Section titled “Header Idempotency-Key”When you resend the same request (for example, after a connection timeout or transient error), the Idempotency-Key header ensures the message is sent and billed only once. This header is supported on the WhatsApp send (POST /v1/{phone_number_id}/messages), SMS send, and unified send endpoints.
| Field | Required | Default | Description |
|---|---|---|---|
Idempotency-Key (HTTP header) | No | — (WhatsApp) / Automatic content hash (SMS) | Any unique value you define per send (e.g. order_id or a UUID). |
How it works on WhatsApp Sends (POST /v1/{phone_number_id}/messages)
Section titled “How it works on WhatsApp Sends (POST /v1/{phone_number_id}/messages)”| Behavior | Explanation |
|---|---|
| 24-hour window | Sending the same key within 24 hours returns HTTP 202 Accepted with the first message_id (messages[0].id, formatted as msg_<uuid>) and the response header Idempotent-Replayed: true. |
| Not sent or billed again | Replayed requests are not sent again to the recipient and are not billed a second time. |
| Different key | A different key (or a request without the Idempotency-Key header) is treated as a new message. |
| Per-tenant scope | Keys are scoped per account (client_account_id). Identical keys across different tenants never collide. |
How it works on SMS & Unified Sends
Section titled “How it works on SMS & Unified Sends”| Behavior | Explanation |
|---|---|
| 24-hour window | The key is retained for 24 hours. Within this window, the same key will not send a second message. |
| Duplicate response | If the key has already been used, the API returns 200 OK with the original message_id (msg_<uuid>) from the first send instead of sending a new message. |
| Content hash fallback | Without the header on the SMS endpoint, the key is derived from the SHA-256 hash of destination number + sender + message body. |
Field processing_strategy
Section titled “Field processing_strategy”In the body of POST /v1/{phone_number_id}/messages, the optional processing_strategy field controls how a message is processed after it is accepted.
| Value | Default | Explanation |
|---|---|---|
broadcast | Yes | Optimized for high throughput (campaigns, blasts). This is the default value when the field is omitted. |
inbox | No | Integrates the message into the live conversation history (Inbox), suitable for 1-on-1 interactions that should appear in an agent’s chat. |
Conversion Events — POST /v1/events/conversions
Section titled “Conversion Events — POST /v1/events/conversions”This endpoint receives conversion events from your external systems (e.g. webhooks from an e-commerce platform) and attributes them to the relevant conversations. Mahadata matches the event to an open conversation based on the phone number and records it in conversion reporting.
Fields in the request body:
| Field | Required | Default | Description |
|---|---|---|---|
phone_number | Yes | — | The contact’s phone number (e.g. +6281234567890). Normalized (digits only) for matching to a conversation. |
event_name | Yes | — | The conversion event name, e.g. Purchase, Registration. |
currency | Yes | — | Currency code, e.g. IDR. |
value | Yes | — | Conversion value as a number, e.g. 150000.0. |
event_time | No | Time received | Unix epoch (seconds) when the event occurred, e.g. 1678900000. |
user_data | No | — | Additional key-value pairs about the user. |
custom_data | No | — | Key-value pairs of custom event metadata. |
A successful response is 200 OK with the body { "success": true, "message": "Conversion event ingested successfully" }.
HTTP 402 — Balance, Quota, or Budget Plan Exhausted
Section titled “HTTP 402 — Balance, Quota, or Budget Plan Exhausted”When the billing account balance, message quota, or budget plan is exhausted, POST /v1/{phone_number_id}/messages returns 402 Payment Required without sending the message and without deducting balance.
| Response field | Example value | Explanation |
|---|---|---|
code | 402 | HTTP status code. |
error | payment_required | Error category (lowercase, underscores). |
message | Payment required: Insufficient funds to send message. | Descriptive message: "Insufficient funds to send message.", "Message quota exhausted.", or "Budget plan exhausted for this category.". |