รหัสข้อผิดพลาด
API แต่ละกลุ่มตอบ error คนละรูปแบบ (เพื่อให้เข้ากันได้กับระบบเดิม) หน้านี้รวมรูปแบบและข้อความทั้งหมดไว้ที่เดียว
รูปแบบ error
| # | ใช้กับ | HTTP status | รูปแบบ body |
|---|---|---|---|
| A | การยืนยันตัวตน, Idempotency-Key | ตาม error (401/403/400/409/500) | {"error": "ข้อความ"} |
| B | /sms/*, rate limit | ตาม error | {"error": {"statusCode": "...", "description": "...", "message": "..."}} |
| C | /OTP/* | ตาม error (บางกรณีเป็น 200 — ดูด้านล่าง) | {"error": {"code": "...", "message": "...", "description": "..."}} |
| D | /Person, /Tag, /Blacklist, /Consent, /line | 200 เสมอ | {"status": <ตัวเลข>, "description": "..."} |
| E | /shorten/* | ตาม error | {"status": <ตัวเลข>, "description": "..."} |
WARNING
กลุ่ม D ตอบ HTTP 200 แม้เกิดข้อผิดพลาด ให้ตรวจ status ใน body เสมอ (200 = สำเร็จ)
HTTP status ที่ใช้
| HTTP | ความหมาย |
|---|---|
| 200 | สำเร็จ (กลุ่ม D และบางกรณีของ OTP ต้องตรวจ body เพิ่ม) |
| 302 | redirect ของลิงก์สั้น /s/:code |
| 400 | request ไม่ถูกต้อง |
| 401 | ยืนยันตัวตนไม่ผ่าน |
| 402 | เครดิตไม่พอ (บัญชีแบบเติมเงินล่วงหน้า) |
| 403 | ไม่มีสิทธิ์: IP ไม่อนุญาต, บัญชีถูกระงับ, บริการไม่เปิด, ชื่อผู้ส่งไม่ได้รับอนุมัติ |
| 404 | ไม่พบข้อมูล |
| 409 | request ที่ใช้ Idempotency-Key เดียวกันยังทำงานอยู่ |
| 429 | เกิน rate limit |
| 500 | ระบบขัดข้อง — ลองใหม่ได้ |
การยืนยันตัวตน (รูปแบบ A)
ดูตารางเต็มที่ การยืนยันตัวตน ตัวอย่าง:
json
{ "error": "invalid api key" }Rate limit (รูปแบบ B)
| HTTP | statusCode | message | description |
|---|---|---|---|
| 429 | 429 | TOO_MANY_REQUESTS | rate limit exceeded: max <N> requests per second per <IP|account|API key> |
มี header Retry-After: 1 มาด้วย
Idempotency-Key (รูปแบบ A)
| HTTP | error |
|---|---|
| 400 | invalid Idempotency-Key |
| 409 | request with this Idempotency-Key is in progress |
ส่ง SMS — /sms/send, /sms/preview (รูปแบบ B)
ตรวจข้อมูล (HTTP 400, message = BAD_REQUEST)
description | สาเหตุ |
|---|---|
Invalid request body | JSON ไม่ถูกต้อง หรือขาดฟิลด์บังคับ (messages, from, destinations, to, text) |
Messages not found | messages ว่าง |
Destinations not found | destinations ว่าง หรือมี to ว่าง |
Text not found | text ว่าง |
sender not found | from ว่าง |
sendAt must be in RFC3339 format (e.g. 2026-04-10T09:00:00+07:00) | sendAt ผิดรูปแบบ |
Text too long: <n> characters (max 1600) | ข้อความยาวเกิน 1,600 ตัวอักษร (เฉพาะ /sms/send) |
Too many destinations: <n> (max 1000 per request) | ปลายทางรวมเกิน 1,000 เบอร์ (เฉพาะ /sms/send) |
ตรวจบัญชี เครดิต และผู้ส่ง (/sms/send)
| HTTP | statusCode | message | description |
|---|---|---|---|
| 403 | 403 | ACCOUNT_INACTIVE | account is inactive |
| 403 | 403 | ACCOUNT_HELD | account is on credit hold |
| 403 | 403 | SERVICE_NOT_ALLOWED | API sending is not enabled for this account |
| 402 | 402 | INSUFFICIENT_CREDIT | insufficient credit: required <x>, available <y> |
| 403 | 101 | INVALID_SENDER | sender '<from>' not authorized for this account |
| 403 | 102 | INVALID_DOMAIN | shorten URL domain '<domain>' not authorized for this account |
| 500 | 500 | INTERNAL_ERROR | Failed to validate send request |
| 500 | 500 | INTERNAL_ERROR | Failed to validate shorten URL domain |
| 500 | 500 | QUEUE_PUBLISH_FAILED | Failed to enqueue SMS for delivery — ข้อความยังไม่ถูกรับ ลองใหม่ได้ (แนะนำใช้ Idempotency-Key) |
INSUFFICIENT_CREDIT เกิดกับบัญชีแบบเติมเงินล่วงหน้าเท่านั้น เครดิตที่ต้องใช้คิดจากเบอร์ที่ส่งได้จริง
สถานะรายเบอร์ใน details[].status
request ที่สำเร็จ (HTTP 200) อาจมีบางเบอร์ถูกปฏิเสธ — เบอร์ที่ REJECTED จะไม่ถูกส่งและไม่ถูกคิดเครดิต
code | name | description |
|---|---|---|
101 | PENDING | Pending -Message has been accepted by the system |
402 | REJECTED | Invalid number - phone number formatted incorrectly |
403 | REJECTED | Number is blacklisted |
SUPPRESSED | REJECTED | Recipient has opted out of non-OTP SMS |
NO_CONSENT | REJECTED | No consent from recipient for this account |
SMS อื่น ๆ — /sms/senderlist, /sms/loginfo (รูปแบบ B)
| HTTP | statusCode | message | description |
|---|---|---|---|
| 401 | 401 | UNAUTHORIZED | Invalid account |
| 404 | 404 | NOT_FOUND | Account not found |
| 500 | 500 | INTERNAL_ERROR | Failed to load sender list / Failed to query SMS logs |
OTP — /OTP/* (รูปแบบ C)
| HTTP | code | message | description |
|---|---|---|---|
| 400 | 400 | BAD_REQUEST | Invalid request body |
| 403 | 403 | ACCOUNT_INACTIVE | account is inactive |
| 403 | 403 | ACCOUNT_HELD | account is on credit hold |
| 403 | 403 | SERVICE_NOT_ALLOWED | OTP is not enabled for this account |
| 402 | 402 | INSUFFICIENT_CREDIT | insufficient credit: required 1.00, available <y> |
| 404 | 404 | OTP_CONFIG_NOT_FOUND | OTP config not found for this account |
| 404 | 404 | OTP_NOT_FOUND | OTP not found for this account |
| 500 | 500 | INTERNAL_SERVER_ERROR | Failed to validate OTP request / Failed to verify OTP |
| 200 | 500 | INTERNAL_SERVER_ERROR | Failed to process OTP request |
| 200 | 500 | SMS_SEND_FAILED | Failed to send OTP SMS |
| 200 | 400 | RESEND_FAILED | Failed to resend OTP |
WARNING
3 แถวสุดท้ายตอบ HTTP 200 แต่มี error ใน body — ให้ตรวจว่ามีฟิลด์ error หรือ success เสมอ
ผลการตรวจรหัส (/OTP/verifyotp) ตอบ HTTP 200 และบอกผลใน status
status.code | status.message | ความหมาย |
|---|---|---|
200 | VERIFIED | รหัสถูกต้อง |
410 | EXPIRED | รหัสหมดอายุ |
429 | MAX_ATTEMPTS | ใส่ผิดครบจำนวนครั้งแล้ว |
401 | INVALID_CODE | รหัสไม่ถูกต้อง (description บอกจำนวนครั้งที่เหลือ) |
รายชื่อ แท็ก Blacklist Consent LINE (รูปแบบ D — HTTP 200 เสมอ)
status | ความหมาย | ตัวอย่าง description |
|---|---|---|
200 | สำเร็จ | Person deleted., Tag assigned. |
400 | ข้อมูลไม่ครบหรือไม่ถูกต้อง | firstName is required., personId is required., mobile is required., Invalid mobile number., mobile, consentType, and granted are required., tokenId and message are required. |
401 | ไม่พบบัญชีจาก credential | Unauthorized. |
403 | LINE token ถูกปิด | LINE token is inactive. |
404 | ไม่พบข้อมูล | Person not found., Tag not found., Destination not found., No consent record found., LINE token not found. |
500 | ระบบขัดข้อง | Failed to create person., Failed to query tags. ฯลฯ |
501 | ฟีเจอร์ยังไม่เปิดให้ใช้ | <feature> is not yet available on this API. |
503 | ระบบ LINE ยังไม่พร้อมใช้งาน | LINE gateway not configured. |
ย่อลิงก์ — /shorten/* (รูปแบบ E)
| HTTP | description |
|---|---|
| 400 | invalid request body |
| 400 | URL must use http or https scheme |
| 400 | page and pageSize must be positive integers |
| 404 | short URL not found |
| 500 | failed to create short URL / failed to query URLs |
แนวทางจัดการ error
| กรณี | ควรทำ |
|---|---|
| 400, 401, 402, 403, 404 | แก้ request หรือการตั้งค่าบัญชีก่อน — retry ซ้ำจะได้ผลเดิม |
| 409 | รอ 1–2 วินาทีแล้ว retry ด้วย Idempotency-Key เดิม |
| 429 | รอตาม Retry-After แล้ว retry |
| 500 | retry แบบเว้นระยะ (exponential backoff) — สำหรับการส่งให้ใช้ Idempotency-Key ป้องกันส่งซ้ำ |
