BlueMedia 开发者文档 —— 接入 WhatsApp Business Platform 所需的全部接口与指南。
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 的原始错误表。