BlueMedia 開發者文件 —— 串接 WhatsApp Business Platform 所需的全部 API 與指南。
POST /v1/messagescurl -X POST https://api.bluehola.com/v1/messages \
-H "Authorization: Bearer $BSP_API_KEY" \
-H "Idempotency-Key: order-8821-notify" \
-H "Content-Type: application/json" \
-d '{
"phoneNumberId": "pn_01923abc",
"to": "8613800138000",
"type": "text",
"text": { "body": "您好,您的訂單已出貨。" }
}'
const res = await fetch("https://api.bluehola.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BSP_API_KEY}`,
"Idempotency-Key": "order-8821-notify",
"Content-Type": "application/json",
},
body: JSON.stringify({
phoneNumberId: "pn_01923abc",
to: "8613800138000",
type: "text",
text: { body: "您好,您的訂單已出貨。" },
}),
});
// 202 僅代表已受理,實際狀態需輪詢訊息詳情或串接 Webhook
const { id, status } = await res.json();
import os, requests
res = requests.post(
"https://api.bluehola.com/v1/messages",
headers={
"Authorization": f"Bearer {os.environ['BSP_API_KEY']}",
"Idempotency-Key": "order-8821-notify",
},
json={
"phoneNumberId": "pn_01923abc",
"to": "8613800138000",
"type": "text",
"text": {"body": "您好,您的訂單已出貨。"},
},
timeout=10,
)
# 202 僅代表已受理,實際狀態需輪詢訊息詳情或串接 Webhook
message = res.json()
payload := []byte(`{
"phoneNumberId": "pn_01923abc",
"to": "8613800138000",
"type": "text",
"text": { "body": "您好,您的訂單已出貨。" }
}`)
req, _ := http.NewRequest(http.MethodPost,
"https://api.bluehola.com/v1/messages", bytes.NewReader(payload))
req.Header.Set("Authorization", "Bearer "+os.Getenv("BSP_API_KEY"))
req.Header.Set("Idempotency-Key", "order-8821-notify")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
// 202 僅代表已受理,實際狀態需輪詢訊息詳情或串接 Webhook
var payload = """
{
"phoneNumberId": "pn_01923abc",
"to": "8613800138000",
"type": "text",
"text": { "body": "您好,您的訂單已出貨。" }
}""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.bluehola.com/v1/messages"))
.header("Authorization", "Bearer " + System.getenv("BSP_API_KEY"))
.header("Idempotency-Key", "order-8821-notify")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
var res = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
// 202 僅代表已受理,實際狀態需輪詢訊息詳情或串接 Webhook
<?php
$ch = curl_init('https://api.bluehola.com/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('BSP_API_KEY'),
'Idempotency-Key: order-8821-notify',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'phoneNumberId' => 'pn_01923abc',
'to' => '8613800138000',
'type' => 'text',
'text' => ['body' => '您好,您的訂單已出貨。'],
], JSON_UNESCAPED_UNICODE),
]);
$response = curl_exec($ch);
// 202 僅代表已受理,實際狀態需輪詢訊息詳情或串接 Webhook
{ "id": "msg_01923abc", "status": "accepted" }X-Webhook-Event由 BlueMedia 核發,並為你設定好授權範圍。
呼叫 GET /whoami,確認 Key 有效並核對授權範圍。
選一個已註冊號碼的 pn_… ID 作為傳送方。
202 只代表已受理,送達結果透過 Webhook 追蹤。
從客戶授權、號碼註冊到訊息傳遞與計費,每一步都有落地儲存的狀態與可復原的重試機制,不必用猜的。
24 小時視窗、冪等鍵、預留與沖銷、Meta 端的限流──該提醒的地方都提醒了,而不只是條列欄位。
每個失敗代碼都標示了能不能重試、該由呼叫端修還是平台修,不必再逐條去對照 Meta 的原始錯誤表。