參考
冪等請求
網絡可能故障。若發送請求超時,您無法確認是否成功。請在 POST /v1/messages 和 POST /v1/batches 請求中加入 Idempotency-Key 標頭,並以相同金鑰重試。
curl https://bulksmsapi.cc/v1/messages \
-H "Authorization: Bearer $BULKSMSAPI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-55102-shipped" \
-d '{"to": "+14155550123", "text": "Order 55102 has shipped."}'規則
- 金鑰可為最多 255 字符的任何字串。建議使用事件標識(如訂單 ID 加步驟)或首次嘗試前生成的 UUID。
- 已接受的請求 (202) 會保留 24 小時。相同金鑰與內容將返回原始回應(標頭含
Idempotent-Replayed: true)且不會重複發送。 - 相同金鑰但不同內容將返回
409 idempotency_conflict。 - 錯誤請求不會被記錄,您可修正問題後以相同金鑰重試。