SMS API

短訊群發 API 用於驗證碼、通知及推廣的 REST 閘道

透過 HTTP 請求及 JSON,從你的應用程式、網店或預約系統發送短訊。價格、號碼檢查及拒收名單的運作與網頁發送畫面相同。

20,000每次請求號碼數
120每分鐘請求數
JSON請求及回應格式

快速開始

3 個步驟發出第一個請求

  1. 01

    建立金鑰

    到帳戶的 API 頁面建立金鑰。金鑰以 as_ 開頭,只會顯示一次。

  2. 02

    加入標頭

    在每個請求加入標頭 Authorization: Bearer <key>。

  3. 03

    先報價,再發送

    呼叫 POST /api/v1/quote 查看費用。確認無誤後,把相同內容發送到 POST /api/v1/messages。

Base URLhttps://allsms.store/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 或 kr。

欄位說明
to收件人:陣列或按行分隔的字串,最多 20,000 個
text短訊內容,最多 10 條
country選填。沒有 + 號號碼的國家代碼
schedule_at選填。發送時間:附時區的 ISO 8601(2026-12-01T09:00:00Z)或 Unix 秒數,5 分鐘後至 30 天內
client_ref選填。你自己的參考編號,最多 64 個字元
回應 · POST /api/v1/messages201
{
  "ok": true,
  "campaign": {
    "id": "K7Q2M9XD4TPA",
    "status": "sending",
    "recipients": 2,
    "parts": 1,
    "encoding": "GSM-7",
    "cost": "0.011",
    "refunded": "0.00",
    "sent": 0,
    "failed": 0,
    "queued": 2,
    "test": false,
    "client_ref": null,
    "scheduled_at": null,
    "created_at": "2026-11-25T09:00:00.000Z",
    "finished_at": null,
    "countries": [
      { "country": "US", "recipients": 1, "cost": "0.0043",
        "sent": 0, "failed": 0, "queued": 1 },
      { "country": "GB", "recipients": 1, "cost": "0.0067",
        "sent": 0, "failed": 0, "queued": 1 }
    ]
  },
  "rejected": [],
  "duplicates": 0,
  "opted_out": 0,
  "balance": "48.989"
}
POST /api/v1/messages
curl -X POST https://allsms.store/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://allsms.store/api/v1/quote \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "to": ["+14155550142", "+819012345678"], "text": "Hello" }'
回應 · POST /api/v1/quote200
{
  "ok": true,
  "recipients": 2,
  "parts": 1,
  "encoding": "GSM-7",
  "characters": 5,
  "too_long": false,
  "too_many": false,
  "cost": "0.0139",
  "balance": "49.00",
  "countries": [
    { "country": "JP", "recipients": 1, "price": "0.0096", "cost": "0.0096" },
    { "country": "US", "recipients": 1, "price": "0.0043", "cost": "0.0043" }
  ],
  "rejected": [],
  "duplicates": 0,
  "opted_out": 0
}

錯誤

錯誤代碼

代碼HTTP意思
unauthorized401金鑰缺少或無效
rate_limited429已達每分鐘請求上限
bad_request400無法讀取請求內容
empty_text400短訊內容是空白的
too_long400內容超過 10 條
no_numbers400沒有可發送的有效號碼
too_many400超過 20,000 個號碼
bad_time400schedule_at 超出允許範圍
low_balance402餘額不足
unavailable503發送已暫停,未有收費
not_found404沒有此 id 的發送
not_scheduled409該次發送已發出或已取消

限制及規則

  • 每條金鑰每分鐘可發出 120 個請求。
  • 金額以美元字串傳回,例如 "0.0047"。
  • 發送 id 是隨機的 12 位代碼,不是流水號。
  • 號碼檢查及拒收規則與網頁發送畫面相同。
建立 API 金鑰