Developers · REST API

เชื่อมต่อส่ง SMS และ OTP ผ่าน REST API

ยิงข้อความจากระบบของคุณได้โดยตรง ส่งถึงทุกเครือข่ายไทย ยืนยันตัวตนด้วย API Key เดียว ศึกษารายละเอียดได้เลยที่นี่ก่อนสมัคร

Base URL https://sepsms.com/api/v2
Quick start

เริ่มเชื่อมต่อใน 3 ขั้นตอน

1

รับ API Key

สมัครและสร้างคีย์จากหน้าแดชบอร์ดสำหรับนักพัฒนา คีย์มีรูปแบบ sk_sep_ แสดงครั้งเดียวตอนสร้าง

2

แนบ Header

ใส่คีย์ในทุกคำขอผ่าน header X-API-Key กำหนดสิทธิ์ (scope) และจำกัด IP ต่อคีย์ได้

3

เรียก Endpoint

ส่งคำขอแบบ JSON ไปยัง Base URL ผลลัพธ์เป็น JSON ทั้งหมด

POST/message/send
curl -X POST https://sepsms.com/api/v2/message/send \
  -H "X-API-Key: sk_sep_..." \
  -H "Content-Type: application/json" \
  -d '{
    "origin": "SEPSMS",
    "recipients": ["66812345678", "66898765432"],
    "message": "สวัสดีคุณลูกค้า รับส่วนลด 10% วันนี้",
    "scheduledTime": null
  }'
Authentication

ยืนยันตัวตนด้วย API Key

ทุกคำขอแนบ header X-API-Key ด้วยคีย์ sk_sep_ ของคุณ แต่ละคีย์กำหนดสิทธิ์ (scope) เฉพาะงาน, จำกัด IP, และตั้งลิมิตต่อนาทีแยกได้

Header
X-API-Key: sk_sep_3f9a...d21c
สิทธิ์ที่กำหนดต่อคีย์ได้ (scopes)
  • sms:sendส่ง SMS / ตั้งเวลา / ยกเลิก
  • sms:readอ่านประวัติและสถานะการนำส่ง
  • otp:sendส่งรหัส OTP
  • otp:verifyตรวจสอบรหัส OTP
  • credit:readอ่านยอดเครดิตคงเหลือ
  • webhooks:read / writeจัดการ webhook การแจ้งเตือน
Reference

Endpoints หลัก

endpoint ที่ใช้บ่อยที่สุดสำหรับการเชื่อมต่อ

POST /message/send sms:send

ส่ง SMS

ส่งข้อความถึงปลายทางหนึ่งหรือหลายเบอร์ในคำขอเดียว ใส่ตัวแปรรายคน (personalize) หรือตั้งเวลาส่งล่วงหน้าได้

originstringชื่อผู้ส่ง (Sender Name) ที่อนุมัติแล้ว
messagestringข้อความที่ต้องการส่ง
recipientsstring[]เบอร์ปลายทาง รูปแบบ 0xxxxxxxxx หรือ 66xxxxxxxxx
scheduledTimestring?เวลาส่งแบบ ISO 8601 (เว้นว่าง = ส่งทันที)
variablesobject?ค่าตัวแปรรายคนสำหรับ personalize
คำขอ
curl -X POST https://sepsms.com/api/v2/message/send \
  -H "X-API-Key: sk_sep_..." \
  -H "Content-Type: application/json" \
  -d '{
    "origin": "SEPSMS",
    "recipients": ["66812345678", "66898765432"],
    "message": "สวัสดีคุณลูกค้า รับส่วนลด 10% วันนี้",
    "scheduledTime": null
  }'
ผลลัพธ์
{
  "result": {
    "uuid": "9f8b2c1e-...",
    "refNo": "SP240115...",
    "totalMsisdn": 2,
    "totalCredit": 2,
    "blockedCount": 0,
    "status": "pending"
  }
}
POST /otp/send otp:send

ส่ง OTP

ส่งรหัสยืนยันแบบใช้ครั้งเดียวพร้อมรหัสอ้างอิง (reference) ระบบสร้างรหัสและส่งทาง SMS ให้ รหัสจะไม่ถูกส่งกลับมาในผลลัพธ์

destinationstringเบอร์ปลายทาง
originstringชื่อผู้ส่ง
templatestring?ข้อความ ต้องมี {code} (และใส่ {ref} ได้)
ttlSecondsnumber?อายุรหัส 60-600 วินาที (ค่าเริ่มต้น 300)
codeLengthnumber?ความยาวรหัส 4-8 หลัก
คำขอ
curl -X POST https://sepsms.com/api/v2/otp/send \
  -H "X-API-Key: sk_sep_..." \
  -H "Content-Type: application/json" \
  -d '{
    "destination": "66812345678",
    "origin": "SEPSMS",
    "template": "รหัสยืนยันของคุณคือ {code} (Ref: {ref})"
  }'
ผลลัพธ์
{
  "result": {
    "uuid": "1a2b...",
    "reference": "A3K9X2",
    "destination": "66812345678",
    "expiresAt": "2026-01-15T10:35:00.000Z",
    "ttlSeconds": 300
  }
}
POST /otp/verify otp:verify

ตรวจสอบ OTP

ตรวจสอบรหัสที่ผู้ใช้กรอก โดยอ้างอิงจาก reference ที่ได้ตอนส่ง

referencestringรหัสอ้างอิงที่ได้จากตอนส่ง OTP
pinstringรหัสที่ผู้ใช้กรอก
คำขอ
curl -X POST https://sepsms.com/api/v2/otp/verify \
  -H "X-API-Key: sk_sep_..." \
  -H "Content-Type: application/json" \
  -d '{ "reference": "A3K9X2", "pin": "123456" }'
ผลลัพธ์
{ "result": { "reference": "A3K9X2", "verified": true } }
GET /message/{uuid} sms:read

สถานะการนำส่ง

ดูสรุปสถานะการนำส่งของข้อความที่ส่งไป (ดูรายเบอร์ได้ที่ /message/{uuid}/recipients)

uuidpathuuid ที่ได้ตอนส่ง SMS
คำขอ
curl https://sepsms.com/api/v2/message/9f8b2c1e-... \
  -H "X-API-Key: sk_sep_..."
ผลลัพธ์
{
  "result": {
    "uuid": "9f8b2c1e-...",
    "origin": "SEPSMS",
    "status": "completed",
    "totalMsisdn": 2,
    "drSummary": [
      { "drStatus": "success", "count": 2 }
    ],
    "refundedCount": 0
  }
}
GET /message/credit/balance credit:read

ยอดเครดิตคงเหลือ

ตรวจสอบเครดิตคงเหลือในบัญชี

คำขอ
curl https://sepsms.com/api/v2/message/credit/balance \
  -H "X-API-Key: sk_sep_..."
ผลลัพธ์
{ "result": { "balance": 18420 } }
POST /webhooks webhooks:write

Webhook แจ้งเตือน

ลงทะเบียนและจัดการ URL ปลายทางจากแดชบอร์ดนักพัฒนา (ต้องเข้าสู่ระบบ ไม่รองรับการสร้างผ่าน API Key) เมื่อลงทะเบียนแล้ว ทุกเหตุการณ์ เช่น ส่งสำเร็จ/ล้มเหลว, ผลนำส่ง และเครดิตใกล้หมด จะถูกส่งไปที่ URL ของคุณ ทุก payload เซ็นด้วย HMAC-SHA256 (header X-Webhook-Signature)

urlstringปลายทาง HTTPS ที่จะรับ event
eventsstring[]รายการ event ที่ต้องการรับ
คำขอ
# Webhook endpoints are registered + managed in the
# developer dashboard (logged-in). Registration is not
# available to API keys. Registration payload:
{
  "url": "https://your-app.com/hooks/sepsms",
  "events": ["dr.success", "dr.failed"]
}
ผลลัพธ์
// POST sent to your URL. The event name, timestamp and
// signature travel in headers, not the body:
//   X-Webhook-Event: dr.success
//   X-Webhook-Timestamp: 1737020405
//   X-Webhook-Signature: t=1737020405,v1=<hmac-sha256>
{
  "smsUuid": "9f8b2c1e-...",
  "msisdn": "66812345678",
  "txId": "8f3a1c9d...",
  "status": "success"
}

Webhook events: sms.sentsms.failedsms.completeddr.successdr.failedotp.verifiedcredit.loworder.completed

Rate limits

ลิมิตการเรียก

เกินลิมิตจะได้สถานะ 429 พร้อม header RateLimit-Remaining และ Retry-After

ส่ง SMS120 ครั้ง / นาที
ส่ง OTP5 ครั้ง / นาที / IP
รวมทุก endpoint2,400 ครั้ง / นาที
Errors

รูปแบบข้อผิดพลาด

ข้อผิดพลาดทุกชนิดตอบกลับด้วยโครงสร้างเดียวกัน อ่าน error.code เพื่อจัดการในโค้ด

เช่น 401 Unauthorized
{
  "success": false,
  "error": {
    "code": "auth.invalid_credentials",
    "message": "API key is missing or invalid"
  }
}

พร้อมเชื่อมต่อแล้วหรือยัง?

สมัครฟรีและสร้าง API Key ได้ทันที เริ่มยิงข้อความจากระบบของคุณวันนี้

ใช้ระบบเดิม (sep2p) อยู่? endpoint v1 ที่ /api/sms และ /api/otp ยังรองรับการเชื่อมต่อแบบเดิมด้วย Bearer token