
短信API
短信群发 API 用于验证码、通知和营销的 REST 短信网关
通过 HTTP 请求和 JSON,从您的应用、网店或预约系统发送短信。价格、号码检查和退订名单与网页发送界面完全相同。
20,000每次请求号码数
120每分钟请求数
JSON请求和响应格式
快速开始
三步发出第一个请求
- 01
创建密钥
进入账户的 API 页面创建密钥。密钥以 as_ 开头,只显示一次。
- 02
添加请求头
在每个请求中添加请求头 Authorization: Bearer <key>。
- 03
先询价,再发送
调用 POST /api/v1/quote 查看费用。确认无误后,把同样的请求体发送到 POST /api/v1/messages。
基础 URL
https:/ / allsms.store/ api/ v1接口
全部接口
七个接口涵盖从询价到取消的全部操作。只有国家列表无需密钥。
- GET
/余额(美元)api/ v1/ balance - GET
/各国每条单价,无需密钥api/ v1/ countries - POST
/不发送,只返回费用、条数和被删除的号码api/ v1/ quote - POST
/立即发送,设置 schedule_at 时按该时间发送api/ v1/ messages - GET
/最近的发送,用 limit 和 offset 分页api/ v1/ messages - 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 | 含义 |
|---|---|---|
unauthorized | 401 | 缺少密钥或密钥无效 |
rate_limited | 429 | 超过每分钟请求次数限制 |
bad_request | 400 | 无法解析请求体 |
empty_text | 400 | 短信内容为空 |
too_long | 400 | 内容超过 10 条 |
no_numbers | 400 | 没有可发送的有效号码 |
too_many | 400 | 超过 20,000 个号码 |
bad_time | 400 | schedule_at 超出允许范围 |
low_balance | 402 | 余额不足 |
unavailable | 503 | 发送已暂停,未扣费 |
not_found | 404 | 不存在该 id 的发送 |
not_scheduled | 409 | 该次发送已发出或已取消 |