簡訊 API

簡訊群發 API 用於驗證碼、通知和行銷的 REST 閘道

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

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 或 tw。

欄位說明
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 金鑰