เริ่มต้นใช้งาน
เอกสารอ้างอิง Bulk SMS API
BulkSMSAPI คือ API SMS แบบกลุ่มสำหรับนักพัฒนา: ส่งข้อความหนึ่งฉบับหรือชุดสูงสุด 10,000 หมายเลขต่อคำขอไปยัง 227 ประเทศผ่าน REST, ติดตามทุกข้อความด้วย webhooks ที่ลงนาม, และจ่ายต่อข้อความจากยอดเงินเติมล่วงหน้า เอกสารอ้างอิงนี้ครอบคลุมทุก endpoint, ฟิลด์, เหตุการณ์และข้อผิดพลาดที่ API มี ทุกหน้ายังมีให้ในรูปแบบ Markdown: เพิ่ม .md ที่ท้ายที่อยู่
URL ฐานและรูปแบบ
คำขอทั้งหมดไปที่ https://bulksmsapi.cc/v1 ผ่าน HTTPS เนื้อหาเป็น JSON (Content-Type: application/json, UTF-8) และทุกคำตอบเป็น JSON รวมถึงข้อผิดพลาด เวลาเป็น ISO 8601 ใน UTC เงินเป็นสตริงในดอลลาร์สหรัฐที่มีทศนิยมห้าตำแหน่ง ("0.00507") ดังนั้นราคาต่ำกว่าเซ็นต์จึงแม่นยำ
Endpoints
| เมธอดและเส้นทาง | สิ่งที่ทำ | Key |
|---|---|---|
| POST /v1/messages | ส่งข้อความหนึ่งฉบับไปยังหมายเลขหนึ่ง | Yes |
| POST /v1/batches | ส่งไปยังสูงสุด 10,000 หมายเลข ข้อความหนึ่งฉบับหรือหนึ่งฉบับต่อหมายเลข | Yes |
| GET /v1/messages/{id} | ข้อความหนึ่งฉบับพร้อมสถานะและราคา | Yes |
| GET /v1/messages | ข้อความ, เรียงจากใหม่สุด, กรองตาม batch หรือสถานะ | Yes |
| GET /v1/batches/{id} | หนึ่ง batch พร้อมจำนวนตามสถานะ | Yes |
| GET /v1/batches | Batches, เรียงจากใหม่สุด | Yes |
| POST /v1/batches/{id}/cancel | ยกเลิก batch ที่ถูกจัดตารางไว้, คืนเงินเต็มจำนวน | Yes |
| POST /v1/estimates | คำนวณราคาของคำขอโดยไม่ต้องส่ง | Yes |
| GET /v1/balance | ยอดเงินคงเหลือใน USD | Yes |
| GET /v1/pricing | ราคาต่อ segment สำหรับทุกประเทศ | No |
| GET /v1/pricing/{country} | ราคาสำหรับหนึ่งประเทศ (รหัส ISO) | No |
คำขอแรก
สร้าง API key ในคอนโซล, ส่งออก, และส่งข้อความ คำตอบคือ 202 พร้อมออบเจ็กต์ข้อความ: ค่าบริการจะถูกหักจากยอดเงินและข้อความจะถูกเข้าคิว
curl https://bulksmsapi.cc/v1/messages \
-H "Authorization: Bearer $BULKSMSAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+14155550123",
"text": "Your Northwind code is 482913. It expires in 10 minutes.",
"reference": "login-7781"
}'// Node.js 18 or newer (built-in fetch)
const res = await fetch("https://bulksmsapi.cc/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BULKSMSAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "+14155550123",
text: "Your Northwind code is 482913. It expires in 10 minutes.",
reference: "login-7781",
}),
});
const message = await res.json();
console.log(res.status, message.id, message.status, message.price);# Python 3, standard library only
import json, os, urllib.request
req = urllib.request.Request(
"https://bulksmsapi.cc/v1/messages",
data=json.dumps({
"to": "+14155550123",
"text": "Your Northwind code is 482913. It expires in 10 minutes.",
"reference": "login-7781",
}).encode(),
headers={
"Authorization": "Bearer " + os.environ["BULKSMSAPI_KEY"],
"Content-Type": "application/json",
"User-Agent": "northwind-app/1.0",
},
method="POST",
)
with urllib.request.urlopen(req) as res:
message = json.load(res)
print(res.status, message["id"], message["status"], message["price"])<?php
// PHP 7.4 or newer with the curl extension
$ch = curl_init("https://bulksmsapi.cc/v1/messages");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("BULKSMSAPI_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"to" => "+14155550123",
"text" => "Your Northwind code is 482913. It expires in 10 minutes.",
"reference" => "login-7781",
]),
]);
$message = json_decode(curl_exec($ch), true);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $message["id"], " ", $message["status"], "\n";// Go 1.20 or newer, standard library only
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"to": "+14155550123",
"text": "Your Northwind code is 482913. It expires in 10 minutes.",
"reference": "login-7781",
})
req, _ := http.NewRequest("POST", "https://bulksmsapi.cc/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("BULKSMSAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var message map[string]any
json.NewDecoder(res.Body).Decode(&message)
fmt.Println(res.StatusCode, message["id"], message["status"], message["price"])
}{
"id": "msg_8F3K2Q9TZ1MX",
"object": "message",
"batch_id": "bat_4M7Q1X0PK2RS",
"to": "+14155550123",
"country": "US",
"text": "Your Northwind code is 482913. It expires in 10 minutes.",
"segments": 1,
"price": "0.00507",
"currency": "USD",
"status": "queued",
"error": null,
"reference": "login-7781",
"created_at": "2026-11-07T09:30:12.418Z",
"sent_at": null,
"done_at": null
}การเคลื่อนที่ของข้อความ
ข้อความที่ได้รับการยอมรับจะถูก queued (หรือ scheduled เมื่อคำขอมี send_at) คิวจะส่งข้อความไปยังเครือข่ายทุกๆ สองวินาที, สูงสุด 1,200 ข้อความต่อนาทีต่อบัญชี, และข้อความจะกลายเป็น sent สถานะสุดท้ายคือ delivered หรือ failed; ข้อความที่ล้มเหลวจะถูกคืนเงินเข้าบัญชีทันที สถานะสุดท้ายแต่ละครั้งจะเรียก webhook ของคุณด้วยอีเวนต์ที่ลงลายเซ็น
ขีดจำกัดโดยสังเขป
| จำกัด | ค่า |
|---|---|
| ผู้รับต่อคำขอ API | 10,000 |
| ผู้รับต่อแคมเปญในคอนโซล | 50,000 |
| คำขอต่อนาทีต่อ key | 600 |
| ข้อความที่ส่งไปยังเครือข่ายต่อนาทีต่อบัญชี | 1,200 |
| ข้อความที่ยาวที่สุด | 10 segments (1,530 GSM-7 หรือ 670 UCS-2 ตัวอักษร) |
| ช่วงเวลาการกำหนดเวลา | ล่วงหน้า 2 นาทีถึง 45 วัน |
| ความพยายามเรียก webhook ต่ออีเวนต์ | 10 |
| ความจำของ Idempotency-Key | 24 ชั่วโมง |
| API keys ต่อบัญชี | 10 |
ไฟล์ที่เครื่องอ่านได้
- OpenAPI 3.1 spec สำหรับเครื่องมือสร้างโค้ดและไคลเอนต์ API
- llms-full.txt: คู่มือทั้งหมดนี้ในรูปแบบไฟล์ข้อความธรรมดา
- ทุกหน้าคู่มือในรูปแบบ Markdown, เช่น /en/docs/webhooks.md