SMSWorld

DEVELOPER API

SMS API 一个密钥即可发送

通过 SMSWorld 短信 API,从你的应用、网店或预约系统发送短信。价格和规则与网页发送页面相同。

1,000每次请求号码数
120每分钟请求数
JSON请求和响应

QUICK START

快速开始

  1. 01在账户的 API 页面创建密钥(以 sw_ 开头)。
  2. 02每次请求都带上请求头 Authorization: Bearer <key>。
  3. 03用 POST /api/v1/quote 确认费用,再用 POST /api/v1/messages 发送。

基础 URL

https://smsworld.shop/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接收人。数组或换行文本,最多 1,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://smsworld.shop/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://smsworld.shop/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超过 1,000 个号码
bad_time400定时时间超出范围
low_balance402余额不足
unavailable503暂时无法发送(未扣费)
not_found404没有这次发送
not_scheduled409已发送或已取消

限制和规则

  • 每个密钥每分钟最多 120 次请求。
  • 金额是美元字符串("0.0047")。
  • 发送 ID 是 12 位代码,不是顺序编号。
  • 号码校验和退订名单与网页发送页面相同。
创建 API 密钥