給開發者
簡訊 API 透過 REST 發送群發簡訊與 OTP
把您的 App、網路商店或預約系統串接到 WorldText 簡訊平台。價格和發送規則與網頁發送畫面相同。
20,000每次請求最多號碼數
120每組金鑰每分鐘請求數
JSON請求與回應
快速開始
第一次請求
- 01前往帳戶的 API 頁面產生金鑰。金鑰以 wt_ 開頭。
- 02在每次請求加入標頭 Authorization: Bearer <金鑰>。
- 03用 POST /api/v1/quote 取得價格,再用 POST /api/v1/messages 發送。
基本網址
https://worldtext.world/api/v1
端點
端點列表
| 方法與路徑 | 用途 |
|---|---|
GET /api/v1/balance | 目前餘額,以美元計 |
GET /api/v1/countries | 支援的國家與每則價格(不需金鑰) |
POST /api/v1/quote | 價格、則數和被篩掉的號碼,不會發送 |
POST /api/v1/messages | 立即發送,設定 schedule_at 時為預約發送 |
GET /api/v1/messages | 最近的發送列表(limit, offset) |
GET /api/v1/messages/{id} | 單次發送及其各國結果 |
POST /api/v1/messages/{id}/cancel | 取消尚未發出的預約發送並全額退款 |
發送
發送簡訊
to 欄位可傳號碼陣列,或每行一個號碼的文字。沒有 + 的號碼,請將 country 欄位設為兩個字母的國碼,例如 us 或 tw。
| 欄位 | 說明 |
|---|---|
to | 收件人。陣列,或每行一個號碼,最多 20,000 個 |
text | 簡訊內容,不超過 10 則 |
country | 選填。沒有 + 的號碼所用的兩個字母國碼 |
schedule_at | 選填。含時區的 ISO 時間(例如 2026-12-01T09:00:00Z)或 Unix 秒數,需在 5 分鐘後到 30 天內 |
client_ref | 選填。您自己的參考值,最多 64 個字元 |
回應 · 201201 Created
{
"ok": true,
"campaign": {
"id": "K7Q2M9XD4TPA",
"status": "sending",
"recipients": 2,
"parts": 1,
"encoding": "GSM-7",
"cost": "0.0105",
"countries": [
{ "country": "US", "recipients": 1, "cost": "0.0041" },
{ "country": "GB", "recipients": 1, "cost": "0.0064" }
]
},
"rejected": [],
"duplicates": 0,
"opted_out": 0,
"balance": "48.9895"
}POST /api/v1/messages
curl -X POST https://worldtext.world/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": ["+14155550142", "+447400123456"],
"text": "Your order #A2847 has shipped."
}'POST /api/v1/quote
curl -X POST https://worldtext.world/api/v1/quote \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "to": ["+14155550142", "+819012345678"], "text": "Hello" }'回應 · 200200 OK
{
"ok": true,
"recipients": 2,
"parts": 1,
"encoding": "GSM-7",
"cost": "0.0131",
"balance": "49.00",
"countries": [
{ "country": "JP", "recipients": 1, "price": "0.009", "cost": "0.009" },
{ "country": "US", "recipients": 1, "price": "0.0041", "cost": "0.0041" }
],
"rejected": [],
"duplicates": 0,
"opted_out": 0
}錯誤
錯誤回應
| 代碼 | HTTP | 原因 |
|---|---|---|
unauthorized | 401 | 沒有金鑰,或金鑰無效 |
rate_limited | 429 | 這一分鐘內請求太多 |
bad_request | 400 | 無法解析請求內容 |
empty_text | 400 | 沒有簡訊內容 |
too_long | 400 | 內容超過 10 則 |
no_numbers | 400 | 沒有可發送的號碼 |
too_many | 400 | 一次請求超過 20,000 個號碼 |
bad_time | 400 | schedule_at 不在允許的範圍內 |
low_balance | 402 | 餘額不足以完成這次發送 |
unavailable | 503 | 目前暫停發送,未扣儲值金 |
not_found | 404 | 該發送 ID 不存在 |
not_scheduled | 409 | 該次發送已發出或已取消 |
限制
- 每組金鑰每分鐘最多 120 次請求。
- 金額以美元字串回傳,例如 "0.0047"。
- 發送 ID 是隨機的 12 字元代碼,不是流水號。
- 號碼篩選和拒收名單的運作方式與網頁發送畫面相同。