Skip to content

รหัสข้อผิดพลาด ​

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, /line200 เสมอ{"status": <ตัวเลข>, "description": "..."}
E/shorten/*ตาม error{"status": <ตัวเลข>, "description": "..."}

WARNING

กลุ่ม D ตอบ HTTP 200 แม้เกิดข้อผิดพลาด ให้ตรวจ status ใน body เสมอ (200 = สำเร็จ)

HTTP status ที่ใช้ ​

HTTPความหมาย
200สำเร็จ (กลุ่ม D และบางกรณีของ OTP ต้องตรวจ body เพิ่ม)
302redirect ของลิงก์สั้น /s/:code
400request ไม่ถูกต้อง
401ยืนยันตัวตนไม่ผ่าน
402เครดิตไม่พอ (บัญชีแบบเติมเงินล่วงหน้า)
403ไม่มีสิทธิ์: IP ไม่อนุญาต, บัญชีถูกระงับ, บริการไม่เปิด, ชื่อผู้ส่งไม่ได้รับอนุมัติ
404ไม่พบข้อมูล
409request ที่ใช้ Idempotency-Key เดียวกันยังทำงานอยู่
429เกิน rate limit
500ระบบขัดข้อง — ลองใหม่ได้

การยืนยันตัวตน (รูปแบบ A) ​

ดูตารางเต็มที่ การยืนยันตัวตน ตัวอย่าง:

json
{ "error": "invalid api key" }

Rate limit (รูปแบบ B) ​

HTTPstatusCodemessagedescription
429429TOO_MANY_REQUESTSrate limit exceeded: max <N> requests per second per <IP|account|API key>

มี header Retry-After: 1 มาด้วย

Idempotency-Key (รูปแบบ A) ​

HTTPerror
400invalid Idempotency-Key
409request with this Idempotency-Key is in progress

ส่ง SMS — /sms/send, /sms/preview (รูปแบบ B) ​

ตรวจข้อมูล (HTTP 400, message = BAD_REQUEST) ​

descriptionสาเหตุ
Invalid request bodyJSON ไม่ถูกต้อง หรือขาดฟิลด์บังคับ (messages, from, destinations, to, text)
Messages not foundmessages ว่าง
Destinations not founddestinations ว่าง หรือมี to ว่าง
Text not foundtext ว่าง
sender not foundfrom ว่าง
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) ​

HTTPstatusCodemessagedescription
403403ACCOUNT_INACTIVEaccount is inactive
403403ACCOUNT_HELDaccount is on credit hold
403403SERVICE_NOT_ALLOWEDAPI sending is not enabled for this account
402402INSUFFICIENT_CREDITinsufficient credit: required <x>, available <y>
403101INVALID_SENDERsender '<from>' not authorized for this account
403102INVALID_DOMAINshorten URL domain '<domain>' not authorized for this account
500500INTERNAL_ERRORFailed to validate send request
500500INTERNAL_ERRORFailed to validate shorten URL domain
500500QUEUE_PUBLISH_FAILEDFailed to enqueue SMS for delivery — ข้อความยังไม่ถูกรับ ลองใหม่ได้ (แนะนำใช้ Idempotency-Key)

INSUFFICIENT_CREDIT เกิดกับบัญชีแบบเติมเงินล่วงหน้าเท่านั้น เครดิตที่ต้องใช้คิดจากเบอร์ที่ส่งได้จริง

สถานะรายเบอร์ใน details[].status ​

request ที่สำเร็จ (HTTP 200) อาจมีบางเบอร์ถูกปฏิเสธ — เบอร์ที่ REJECTED จะไม่ถูกส่งและไม่ถูกคิดเครดิต

codenamedescription
101PENDINGPending -Message has been accepted by the system
402REJECTEDInvalid number - phone number formatted incorrectly
403REJECTEDNumber is blacklisted
SUPPRESSEDREJECTEDRecipient has opted out of non-OTP SMS
NO_CONSENTREJECTEDNo consent from recipient for this account

SMS อื่น ๆ — /sms/senderlist, /sms/loginfo (รูปแบบ B) ​

HTTPstatusCodemessagedescription
401401UNAUTHORIZEDInvalid account
404404NOT_FOUNDAccount not found
500500INTERNAL_ERRORFailed to load sender list / Failed to query SMS logs

OTP — /OTP/* (รูปแบบ C) ​

HTTPcodemessagedescription
400400BAD_REQUESTInvalid request body
403403ACCOUNT_INACTIVEaccount is inactive
403403ACCOUNT_HELDaccount is on credit hold
403403SERVICE_NOT_ALLOWEDOTP is not enabled for this account
402402INSUFFICIENT_CREDITinsufficient credit: required 1.00, available <y>
404404OTP_CONFIG_NOT_FOUNDOTP config not found for this account
404404OTP_NOT_FOUNDOTP not found for this account
500500INTERNAL_SERVER_ERRORFailed to validate OTP request / Failed to verify OTP
200500INTERNAL_SERVER_ERRORFailed to process OTP request
200500SMS_SEND_FAILEDFailed to send OTP SMS
200400RESEND_FAILEDFailed to resend OTP

WARNING

3 แถวสุดท้ายตอบ HTTP 200 แต่มี error ใน body — ให้ตรวจว่ามีฟิลด์ error หรือ success เสมอ

ผลการตรวจรหัส (/OTP/verifyotp) ตอบ HTTP 200 และบอกผลใน status

status.codestatus.messageความหมาย
200VERIFIEDรหัสถูกต้อง
410EXPIREDรหัสหมดอายุ
429MAX_ATTEMPTSใส่ผิดครบจำนวนครั้งแล้ว
401INVALID_CODEรหัสไม่ถูกต้อง (description บอกจำนวนครั้งที่เหลือ)
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ไม่พบบัญชีจาก credentialUnauthorized.
403LINE 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) ​

HTTPdescription
400invalid request body
400URL must use http or https scheme
400page and pageSize must be positive integers
404short URL not found
500failed 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
500retry แบบเว้นระยะ (exponential backoff) — สำหรับการส่งให้ใช้ Idempotency-Key ป้องกันส่งซ้ำ