Errors
Error response format มาตรฐาน:
{
"error": {
"code": "not_found",
"message": "no ecu_model with code XYZ",
"docs_url": "https://developers.smongrot.com/docs/errors"
}
}
Error codes
| HTTP | Code | เกิดเมื่อ | แก้ยังไง |
|---|---|---|---|
| 400 | bad_request | Missing/invalid parameter | เช็ค required params ใน endpoint docs |
| 401 | unauthorized | Missing/invalid/revoked key | ดู Authentication |
| 404 | not_found | Path หรือ resource ไม่มี | เช็ค URL + ID |
| 405 | method_not_allowed | ใช้ POST/PUT/DELETE | v1 = GET only |
| 429 | rate_limit_exceeded | เกินโควตาวัน | ดู Rate limits |
| 500 | internal_error | Server bug | Retry, ถ้ายัง fail แจ้งเรา |
HTTP status conventions
- 2xx — success
- 4xx — ผู้เรียกทำผิด (payload, auth, quota)
- 5xx — server side issue (เราแก้เอง)
อย่า retry 4xx อัตโนมัติ — จะยังผิดเดิมทุกครั้ง (ยกเว้น 429 พร้อม Retry-After)
Retry 5xx ได้ — ใช้ exponential backoff (1s, 2s, 4s, 8s, max 60s)
ตัวอย่าง error responses
Missing ecu_code parameter
GET /v1/ecu-models/
HTTP/2 404
{ "error": { "code": "not_found", "message": "no route for /v1/ecu-models/" } }
Wrong key format
Authorization: Bearer wrong_prefix_key
HTTP/2 401
{ "error": { "code": "unauthorized", "message": "malformed key" } }
ECU code ที่ไม่มี
GET /v1/ecu-models/DOES-NOT-EXIST
HTTP/2 404
{ "error": { "code": "not_found", "message": "no ecu_model with code DOES-NOT-EXIST" } }
Reporting bugs
ถ้าเจอ error code ที่ไม่ documented หรือ 500 บ่อยๆ — email มาที่ hello@smongrot.com พร้อม:
- Timestamp (UTC)
- Full request (path + headers ยกเว้น API key)
- Response body
หรือ open issue