短信API

短信群发 API 用于验证码、通知和营销的 REST 短信网关

通过 HTTP 请求和 JSON,从您的应用、网店或预约系统发送短信。价格、号码检查和退订名单与网页发送界面完全相同。

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

快速开始

三步发出第一个请求

  1. 01

    创建密钥

    进入账户的 API 页面创建密钥。密钥以 as_ 开头,只显示一次。

  2. 02

    添加请求头

    在每个请求中添加请求头 Authorization: Bearer <key>。

  3. 03

    先询价,再发送

    调用 POST /api/v1/quote 查看费用。确认无误后,把同样的请求体发送到 POST /api/v1/messages。

基础 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 密钥