DEVELOPER API

SMS API 一組金鑰就能發送

透過 SMSOnline,從你的 App、網店或預約系統發送簡訊。價格和規則與網頁發送畫面相同。

20,000每次請求號碼數
120每分鐘請求數
JSON收發格式

QUICK START

開始使用

  1. 01在帳號裡的 API 頁面建立金鑰(以 so_ 開頭)。
  2. 02每次請求都要帶上標頭 Authorization: Bearer <key>。
  3. 03先用 POST /api/v1/quote 確認費用,再用 POST /api/v1/messages 發送。

Base URL

https://smsonline.blog/api/v1

ENDPOINTS

端點

請求功能
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發送前取消預約,全額退款

SEND

發送

to 是號碼陣列,或以換行分隔的文字。要使用沒有 + 的號碼時,請把 country 設為預設國家代碼(例如 us 或 kr)。

欄位說明
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.012",
    "countries": [
      { "country": "US", "recipients": 1, "cost": "0.0047" },
      { "country": "GB", "recipients": 1, "cost": "0.0073" }
    ]
  },
  "rejected": [],
  "duplicates": 0,
  "opted_out": 0,
  "balance": "48.988"
}
POST /api/v1/messages
curl -X POST https://smsonline.blog/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://smsonline.blog/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.0147",
  "balance": "49.00",
  "countries": [
    { "country": "JP", "recipients": 1, "price": "0.01", "cost": "0.01" },
    { "country": "US", "recipients": 1, "price": "0.0047", "cost": "0.0047" }
  ],
  "rejected": [],
  "duplicates": 0,
  "opted_out": 0
}

ERRORS

錯誤代碼

代碼HTTP說明
unauthorized401缺少金鑰或金鑰錯誤
rate_limited429超過每分鐘限制
bad_request400無法讀取請求內容
empty_text400內容是空的
too_long400內容超過 10 則
no_numbers400沒有可發送的號碼
too_many400超過 20,000 個號碼
bad_time400預約時間超出範圍
low_balance402餘額不足
unavailable503目前暫停發送(未扣款)
not_found404找不到這筆發送
not_scheduled409已發送或已取消

限制與規則

  • 每組金鑰每分鐘最多 120 次請求。
  • 金額為美元字串("0.0047")。
  • 發送 ID 是 12 字元的代碼,不是流水號。
  • 號碼檢查和拒收名單與網頁發送畫面相同。
建立 API 金鑰