Send a WhatsApp message or mark inbound as read
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.kirimdev.com/v1/106540352242922/messages"
payload := strings.NewReader("{ \"messaging_product\": \"whatsapp\", \"recipient_type\": \"individual\", \"to\": \"628123456789\", \"recipient\": \"US.13491208655302741918\", \"context\": { \"message_id\": \"wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUA\" }, \"type\": \"text\", \"text\": { \"body\": \"example\", \"preview_url\": true } }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.kirimdev.com/v1/106540352242922/messages';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"messaging_product":"whatsapp","recipient_type":"individual","to":"628123456789","recipient":"US.13491208655302741918","context":{"message_id":"wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUA"},"type":"text","text":{"body":"example","preview_url":true}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.kirimdev.com/v1/106540352242922/messages";
let payload = json!({ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "628123456789", "recipient": "US.13491208655302741918", "context": json!({"message_id": "wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUA"}), "type": "text", "text": json!({ "body": "example", "preview_url": true }) });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.kirimdev.com/v1/106540352242922/messages \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "628123456789", "recipient": "US.13491208655302741918", "context": { "message_id": "wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUA" }, "type": "text", "text": { "body": "example", "preview_url": true } }'Meta-style messages endpoint. Two operations share the same path, distinguished by the request body:
Outbound send — body has a type field (text, image, document, video, audio, template, interactive). Body shape mirrors the Meta WhatsApp Cloud API; media variants accept either link (hosted URL) or id (Meta uploaded media). Optional top-level context: { message_id } creates a contextual reply — pass the inbound wamid from your webhook (messages[0].id), not a Kirim msg_* id. The sender is the WhatsApp account identified by phone_number_id in the URL path; there is no from field in the body. Pass Idempotency-Key to safely retry on network failure.
Read receipt — body has status: "read" + message_id (the inbound wamid from your webhook). Sends a read receipt back to the sender so the double-tick turns blue on their phone. Optional typing_indicator: { type: "text" } shows a typing bubble alongside the receipt; Meta auto-dismisses after ~25 seconds or on first outbound message.
Pre-send validation — the API performs compliance checks before queuing the send. A 422 response with error.code set to marketing_opted_out indicates the recipient has stopped marketing messages from your business (the customer did this via the WhatsApp app menu — webhook user_preferences notifies you of the change). account_restricted indicates Meta has restricted your WhatsApp account; check the account status via the dashboard. consent_required indicates the recipient has not opted in. customer_suspended indicates the operator has suspended (or archived) the customer that owns this WhatsApp account; sends are blocked until the customer is unsuspended via the dashboard. upstream_error indicates the WhatsApp account is disconnected. None of these are retryable until the underlying condition changes.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Meta WhatsApp Business phone_number_id of the connected account that should send / own this resource. Discoverable via GET /v1/accounts (returned as phone_number_id on each row).
Example
106540352242922Meta WhatsApp Business phone_number_id of the connected account that should send / own this resource. Discoverable via GET /v1/accounts (returned as phone_number_id on each row).
Header Parameters
Section titled “Header Parameters ”Optional idempotency token. See /docs/idempotency.
Optional idempotency token. See /docs/idempotency.
Request Body
Section titled “Request Body ”object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
object
object
object
Recipient’s WhatsApp phone number in E.164 (e.g. 628123456789). Either to or recipient is required; if both are supplied, Meta uses to (documented precedence).
Example
628123456789Recipient’s Business-Scoped User ID (e.g. US.13491208655302741918) or parent BSUID. Alternative to to. Auth OTP templates (one-tap / zero-tap / copy-code) do NOT support BSUID recipients — Meta rejects with error 131062.
Example
US.13491208655302741918object
Meta WhatsApp message id (wamid) of the message to reply to. From the inbound webhook — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAobject
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
Meta WhatsApp message id (wamid) of the inbound message to mark as read. Get it from the inbound webhook payload — NOT a Kirim msg_* external id.
Example
wamid.HBgNNjI4MTIzNDU2Nzg5FQIAEhggMUE5MDM1QzVDMUYxQTAyRkVCNzZDQjVDMjFFRDQzNTUAOptional. When present, Meta also shows a typing indicator to the recipient that auto-dismisses on response or after ~25 seconds. Only include if you intend to respond — leaving the indicator hanging produces a poor UX.
object
Responses
Section titled “ Responses ”Message accepted for delivery, or read receipt sent.
object
object
Recipient’s phone number in E.164 (with leading +). NULL when the message targeted a Business-Scoped User ID (BSUID) recipient and the contact has no known phone number. See docs/meta-docs/bsuid.md.
Recipient contact’s Business-Scoped User ID. Present when the contact has been enriched with a BSUID from a Meta webhook (or from a BSUID-first send). NULL for phone-only contacts.
Parent BSUID for managed businesses with linked business portfolios. NULL for regular accounts.
Recipient contact’s WhatsApp username (case-insensitive comparison; case-preserving in storage). NULL when the contact has not adopted the WhatsApp username feature.
ISO-8601 timestamp when the recipient first played an outbound voice note. Populated from Meta’s played status webhook; omitted on non-voice messages and until playback occurs.
object
Stable Kirim error code. Known values include outside_24h_window, marketing_opted_out, marketing_blocked_by_user, recipient_unavailable, unsupported_message_type, account_restricted, account_locked, consent_required, customer_suspended, permission_revoked, auth_expired, app_rate_limited, account_rate_limited, template_not_found, template_paused, template_policy_violation, flow_blocked, media_upload_failed, media_download_failed, undeliverable, policy_violation, upstream_error.
Example
{ "data": { "id": "msg_01HXYZABCDEFGHJKMNPQRSTVWX", "object": "message", "to": "+628123456789", "bsuid": "US.13491208655302741918", "parent_bsuid": "US.ENT.11815799212886844830", "username": "pablomorales", "status": "queued" }}Validation failure
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Authentication failure
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Resource not found
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Semantic failure (e.g. idempotency key reuse, pre-send compliance guard, media not found)
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Rate limit exceeded
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Upstream WhatsApp error
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Service unavailable
object
object
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}