สารบัญหน้านี้ (22)
- ภาพรวม
- Workflow: ออเดอร์จาก KINDEE เข้า → แปลงรูปแบบ → จอครัว + BI
- Workflow: สาขาใหม่ยังไม่จับคู่ → dead-letter → แก้แล้ว replay
- The WebhookEndpoint object
- The Delivery object
- The DeadLetter object
- Endpoints (10)
- POSTรับ webhook ขาเข้า
- GETรายการ webhook endpoint
- POSTสมัครรับ webhook
- PATCHแก้ไข endpoint
- DELETEลบ endpoint
- POSTหมุน secret
- GETประวัติการส่ง
- POSTส่งซ้ำ
- GETรายการ dead-letter
- POSTreplay dead-letter
- Webhooks (5)
- Errors (15)
- Rate limit
- เวอร์ชัน + Changelog
- เครื่องมือ: ตัวแปลง payload ขาเข้า → รูปแบบมาตรฐาน
- CHUAMTHANG Hub
- Docs
- Integration API
- Webhook
Webhook · /v1/webhooks · /v1/webhook-endpoints · /v1/deliveries · /v1/dead-letters
Webhook API (ขาเข้า + ขาออก)
จุดเดียวที่รับ webhook จากแอปส่งอาหาร ผู้ให้บริการรับชำระ และระบบ e-Tax — ตรวจลายเซ็น กันซ้ำ แปลงเป็น event มาตรฐาน แล้วส่งต่อให้ POS และระบบของคุณ พร้อมประวัติ ส่งซ้ำ และ dead-letter
- 10endpoint
- 2workflow
- 3object
- 5webhook event
- 16รหัส error

โมดูลนี้ทำอะไร
- รับ webhook ขาเข้า 5 แหล่ง: แต่ละแหล่งลงลายเซ็นคนละแบบ — Hub ตรวจให้ทั้งหมด
- แปลง payload ดิบเป็น event มาตรฐาน (เงินเป็นสตางค์ เวลา +07:00 รหัสสาขา/เมนูของ BAANKHAO)
- ส่ง event ขาออกให้ระบบลูกค้า (BI ระบบบัญชีแฟรนไชส์ซี) พร้อมลายเซ็น Chuamthang-Signature และส่งซ้ำ 7 ครั้ง
- dead-letter สำหรับข้อความที่ประมวลผลไม่ได้ + replay หลังแก้สาเหตุ
ใช้เมื่อไร / ใครเรียก
- แอปส่งอาหาร / ผู้ให้บริการรับชำระ / e-Tax ส่ง event เข้ามา
- ระบบของฝ่ายบริหารหรือแฟรนไชส์ซีต้องการรู้ทันทีเมื่อเกิดเหตุการณ์
- ทีมปฏิบัติการไล่ปัญหาข้อความที่หาย
Base path/v1/webhooks · /v1/webhook-endpoints · /v1/deliveries · /v1/dead-lettersBase URLhttps://api.chuamthang.exampleSandboxhttps://sandbox.api.chuamthang.example
การยืนยันตัวตนและสิทธิ์ (scope)
ทุกคำขอส่ง API key ในหัว Authorization: Bearer … — คีย์ sandbox ขึ้นต้น ct_test_ คีย์ production ขึ้นต้น ct_live_ · คีย์ของ POS สาขาถูกจำกัดให้เห็นเฉพาะสาขาตัวเอง (branch_not_allowed) · ส่ง Chuamthang-Version เพื่อตรึงเวอร์ชัน · คีย์แต่ละตัวมี scope ตามตารางนี้ (ขอเพิ่มได้ใน Developer Console)
GET https://sandbox.api.chuamthang.example/v1/webhook-endpoints HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWk
Chuamthang-Version: 2026-08-01
Accept: application/json| scope | ให้ทำอะไร | ระบบที่มักใช้ |
|---|---|---|
(ไม่ใช้ API key) | ขาเข้า /v1/webhooks/inbound/{source} ยืนยันด้วยลายเซ็นของแต่ละแหล่ง + IP allowlist | KINDEE · IMAEM · PAYGATE · TAXDEE |
webhooks:read | ดู endpoint ประวัติการส่ง dead-letter | ระบบลูกค้า · ทีมไอที |
webhooks:write | สมัคร/แก้/ลบ endpoint หมุน secret ส่งซ้ำ | ระบบลูกค้า |
webhooks:replay | replay dead-letter | ทีมปฏิบัติการ |
Object หลัก
WebhookEndpointปลายทางขาออกของระบบลูกค้า 1 รายการ13 ฟิลด์Deliveryการส่ง event 1 ครั้งไป 1 endpoint (รวมทุก attempt)14 ฟิลด์DeadLetterข้อความที่ประมวลผลไม่ได้ (ตัวอย่าง: ออเดอร์สาขาใหม่ที่ยังไม่จับคู่)12 ฟิลด์
ความสัมพันธ์กับโมดูลอื่น
- Third-Party Servicesecret ของแหล่งขาเข้าและการจับคู่สาขาเก็บใน connector
- Payment Gatewaywebhook ของ PAYGATE ถูกแปลงเป็น payment.succeeded / payment.failed
- CRMการผูกบัญชีจากแอปส่งอาหารเข้ามาทาง inbound
- Data Syncsync.job.completed และ conflict ส่งออกผ่าน endpoint เดียวกัน
- ขาออก: ตรวจหัว Chuamthang-Signature ทุกครั้ง · ใช้ event id กันประมวลผลซ้ำ · event อาจมาสลับลำดับ
- ขาเข้า: Hub ตอบภายใน 300 ms แล้วประมวลผลต่อในคิว · 4xx = แหล่งหยุดส่งซ้ำ · 5xx = แหล่งส่งซ้ำ
- payload ดิบเก็บ 14 วัน (ตัดข้อมูลส่วนบุคคลเกินจำเป็น — เบอร์ลูกค้าแอปส่งอาหารถูกปิดบังตั้งแต่ต้นทาง)
- เงินในรูปแบบมาตรฐานเป็นสตางค์ · เวลา ISO 8601 +07:00 · list ใช้ cursor
Workflow — ลำดับการทำงานจริง (2 เรื่อง)
แต่ละเรื่องดูได้ 2 แบบ: Infographic อธิบายภาษาคนทั่วไป และ Sequence ทีละขั้น กดเล่นแล้วดูคำขอ/ผลลัพธ์ของทุกขั้น (ลูกศรประ = ไม่รอผล เช่น webhook หรือคิว)
ออเดอร์จาก KINDEE เข้า → แปลงรูปแบบ → จอครัว + BI
ลูกค้าสั่ง กะเพราหมูกรอบไข่ดาว ×2 + ชาไทยเย็น ×1 ผ่านแอป KINDEE ถึงสาขาลาดพร้าว 71
- KINDEE Deliveryแอปส่งอาหารสมมติ
- CHUAMTHANG Hubinbound
- คิว event
- POS ครัวสาขา 041
- BI ฝ่ายบริหารwebhook endpoint
- 1
KINDEE Delivery → CHUAMTHANG Hub
KINDEE ส่งออเดอร์ในรูปแบบของตัวเอง (ราคาเป็นข้อความบาท เวลาเป็น epoch ms)
POST /v1/webhooks/inbound/kindee - 2
CHUAMTHANG Hub → CHUAMTHANG Hub
คำนวณ HMAC-SHA256 ของ raw body ด้วย secret ของ KINDEE เทียบกับหัว และเวลาไม่เก่ากว่า 5 นาที
- 3
CHUAMTHANG Hub → CHUAMTHANG Hub
orderRef KD-88213470 ยังไม่เคยรับ → แปลงเป็น delivery_order.created (storeCode BK-041 → brn_041 · 89.00 → 8900)
- 4
CHUAMTHANG Hub → KINDEE Delivery
ตอบ KINDEE ทันที
- 5
CHUAMTHANG Hub → คิว event
event มาตรฐานเข้าคิว
ไม่รอผล (async) - 6
คิว event → POS ครัว
ใบสั่งขึ้นจอครัวพร้อมหมายเหตุ "ไม่เผ็ด"
ไม่รอผล (async) - 7
คิว event → BI ฝ่ายบริหาร
ส่งต่อ BI ที่สมัคร event นี้ — ปลายทางตอบ 500
ไม่รอผล (async) - 8
คิว event → คิว event
ส่งซ้ำตามตาราง (ทันที · 1 นาที · 5 นาที · …)
ไม่รอผล (async) - 9
คิว event → BI ฝ่ายบริหาร
ส่ง event เดิม event_id เดิม — สำเร็จ
ไม่รอผล (async) - 10
BI ฝ่ายบริหาร → CHUAMTHANG Hub
ทีม BI ดูประวัติว่าครั้งแรกล้มเพราะอะไร
GET /v1/deliveries?endpoint_id=we_01Bi7&event_type=delivery_order.created
ออเดอร์ขึ้นจอครัวใน 1.2 วินาที · KINDEE ได้คำตอบใน 140 ms · BI ได้ข้อมูลแม้ปลายทางล่ม 1 ครั้ง (ส่งซ้ำอัตโนมัติ)
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 KINDEE Delivery CHUAMTHANG Hub
POST /v1/webhooks/inbound/kindee
KINDEE ส่งออเดอร์ในรูปแบบของตัวเอง (ราคาเป็นข้อความบาท เวลาเป็น epoch ms)
POST /v1/webhooks/inbound/kindee HTTP/1.1
X-Kindee-Signature: b3JkZXI…Zz0=
X-Request-Timestamp: 1791775502
Content-Type: application/json
{
"eventType": "ORDER_PLACED",
"orderRef": "KD-88213470",
"storeCode": "BK-041",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
}2 CHUAMTHANG Hub CHUAMTHANG Hub
ตรวจ HMAC + เวลา
คำนวณ HMAC-SHA256 ของ raw body ด้วย secret ของ KINDEE เทียบกับหัว และเวลาไม่เก่ากว่า 5 นาที
3 CHUAMTHANG Hub CHUAMTHANG Hub
กันซ้ำ + แปลง
orderRef KD-88213470 ยังไม่เคยรับ → แปลงเป็น delivery_order.created (storeCode BK-041 → brn_041 · 89.00 → 8900)
4 CHUAMTHANG Hub KINDEE Delivery
202 Accepted
ตอบ KINDEE ทันที
HTTP/1.1 202 Accepted
{
"received": true,
"event_id": "evt_01JB8K2",
"type": "delivery_order.created",
"duplicate": false
}5 CHUAMTHANG Hub คิว eventasync
publish event
event มาตรฐานเข้าคิว
6 คิว event POS ครัวasync
delivery_order.created
ใบสั่งขึ้นจอครัวพร้อมหมายเหตุ "ไม่เผ็ด"
HTTP/1.1 200 OK
{
"type": "delivery_order.created",
"source": "kindee",
"external_id": "KD-88213470",
"branch_id": "brn_041",
"placed_at": "2026-10-12T10:25:00+07:00",
"items": [
{
"sku": "MN-101",
"name": "กะเพราหมูกรอบไข่ดาว",
"quantity": 2,
"unit_price": 8900,
"note": "ไม่เผ็ด"
},
{
"sku": "MN-201",
"name": "ชาไทยเย็น",
"quantity": 1,
"unit_price": 4500,
"note": null
}
],
"total": 22300,
"payment_status": "paid",
"customer": {
"display_name": "คุณณัฐ",
"phone_masked": "08x-xxx-5521"
},
"eta_minutes": 18
}7 คิว event BI ฝ่ายบริหารasync
POST (Chuamthang-Signature)
ส่งต่อ BI ที่สมัคร event นี้ — ปลายทางตอบ 500
HTTP/1.1 500 Internal Server Error
{
"message": "internal error"
}8 คิว event คิว eventasync
รอ 1 นาที
ส่งซ้ำตามตาราง (ทันที · 1 นาที · 5 นาที · …)
9 คิว event BI ฝ่ายบริหารasync
POST (ครั้งที่ 2)
ส่ง event เดิม event_id เดิม — สำเร็จ
HTTP/1.1 200 OK
{
"ok": true
}10 BI ฝ่ายบริหาร CHUAMTHANG Hub
GET /v1/deliveries?endpoint_id=we_01Bi7
ทีม BI ดูประวัติว่าครั้งแรกล้มเพราะอะไร
GET /v1/deliveries?endpoint_id=we_01Bi7&event_type=delivery_order.created HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWkHTTP/1.1 200 OK
{
"object": "list",
"data": [
{
"id": "whd_5Pq81",
"object": "webhook_delivery",
"endpoint_id": "we_01Bi7",
"event_id": "evt_01JB8K2",
"event_type": "delivery_order.created",
"status": "succeeded",
"endpoint_url": "https://bi.baankhao.example/hooks/chuamthang",
"api_version": "2026-08-01",
"attempt_count": 2,
"last_http_status": 200,
"attempts": [
{
"n": 1,
"at": "2026-10-12T10:25:02+07:00",
"http_status": 500,
"duration_ms": 1840,
"error": "ปลายทางตอบ 500"
},
{
"n": 2,
"at": "2026-10-12T10:26:02+07:00",
"http_status": 200,
"duration_ms": 198,
"error": null
}
],
"next_retry_at": null,
"request": {
"headers": {
"Chuamthang-Signature": "t=1791775502,v1=4e1c…",
"Content-Type": "application/json"
},
"body_bytes": 1184
},
"created_at": "2026-10-12T10:25:02+07:00"
}
],
"has_more": false,
"next_cursor": null
}ออเดอร์ขึ้นจอครัวใน 1.2 วินาที · KINDEE ได้คำตอบใน 140 ms · BI ได้ข้อมูลแม้ปลายทางล่ม 1 ครั้ง (ส่งซ้ำอัตโนมัติ)
สาขาใหม่ยังไม่จับคู่ → dead-letter → แก้แล้ว replay
สาขา 063 เปิดวันนี้และ KINDEE เปิดรับออเดอร์แล้ว แต่ connector ยังไม่มี BK-063 ในการจับคู่สาขา ออเดอร์แรกจึงแปลงไม่ได้
- KINDEE Delivery
- CHUAMTHANG Hub
- Dead-letterเก็บ 14 วัน
- ทีมปฏิบัติการไอที
- POS ครัวสาขา 063
- 1
KINDEE Delivery → CHUAMTHANG Hub
ออเดอร์แรกของสาขาใหม่ storeCode BK-063
POST /v1/webhooks/inbound/kindee - 2
CHUAMTHANG Hub → CHUAMTHANG Hub
storeCode "BK-063" ไม่อยู่ในตารางจับคู่สาขา
- 3
CHUAMTHANG Hub → Dead-letter
เก็บทั้งก้อนพร้อมเหตุผล
- 4
CHUAMTHANG Hub → KINDEE Delivery
ตอบ 4xx เพื่อให้ KINDEE ไม่ส่งซ้ำวน (ข้อมูลปลอดภัยใน dead-letter แล้ว)
- 5
CHUAMTHANG Hub → ทีมปฏิบัติการ
แจ้งทีมพร้อมสาเหตุ
ไม่รอผล (async) - 6
ทีมปฏิบัติการ → CHUAMTHANG Hub
เพิ่ม brn_063 ↔ BK-063 ในการจับคู่สาขา (หน้า Third-Party Service)
PATCH /v1/connectors/con_kindee - 7
ทีมปฏิบัติการ → CHUAMTHANG Hub
ลองแปลงก่อน — ผ่าน
POST /v1/dead-letters/replay - 8
ทีมปฏิบัติการ → CHUAMTHANG Hub
replay จริง
POST /v1/dead-letters/replay - 9
CHUAMTHANG Hub → POS ครัว
ออเดอร์ขึ้นจอครัวสาขา 063 (ป้าย "ล่าช้า 6 นาที")
ไม่รอผล (async) - 10
CHUAMTHANG Hub → KINDEE Delivery
Hub ยืนยันรับออเดอร์กับ KINDEE ย้อนหลัง ไรเดอร์ได้เวลาใหม่
ไม่รอผล (async)
ออเดอร์ไม่หาย (อยู่ใน dead-letter) · ทีมรู้ใน 1 นาที · หลังเพิ่มการจับคู่ replay สำเร็จ ออเดอร์ถึงครัวช้าไป 6 นาที แทนที่จะหายเงียบ
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 KINDEE Delivery CHUAMTHANG Hub
POST /v1/webhooks/inbound/kindee
ออเดอร์แรกของสาขาใหม่ storeCode BK-063
POST /v1/webhooks/inbound/kindee HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWk
{
"eventType": "ORDER_PLACED",
"orderRef": "KD-88214011",
"storeCode": "BK-063",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
}2 CHUAMTHANG Hub CHUAMTHANG Hub
ลายเซ็นถูก · แปลงไม่ได้
storeCode "BK-063" ไม่อยู่ในตารางจับคู่สาขา
3 CHUAMTHANG Hub Dead-letter
เก็บ payload ดิบ
เก็บทั้งก้อนพร้อมเหตุผล
4 CHUAMTHANG Hub KINDEE Delivery
422 payload_unmappable
ตอบ 4xx เพื่อให้ KINDEE ไม่ส่งซ้ำวน (ข้อมูลปลอดภัยใน dead-letter แล้ว)
HTTP/1.1 422 Unprocessable Entity
{
"error": {
"code": "payload_unmappable",
"details": [
"storeCode \"BK-063\" ไม่อยู่ในตารางจับคู่สาขา"
],
"dead_letter_id": "dlq_3Fz09"
}
}5 CHUAMTHANG Hub ทีมปฏิบัติการasync
webhook webhook.dead_lettered
แจ้งทีมพร้อมสาเหตุ
6 ทีมปฏิบัติการ CHUAMTHANG Hub
PATCH /v1/connectors/con_kindee
เพิ่ม brn_063 ↔ BK-063 ในการจับคู่สาขา (หน้า Third-Party Service)
PATCH /v1/connectors/con_kindee HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWk
{
"branch_mapping": {
"brn_041": "BK-041",
"brn_012": "BK-012",
"brn_058": "BK-058",
"brn_063": "BK-063"
}
}HTTP/1.1 200 OK
{
"id": "con_kindee"
}7 ทีมปฏิบัติการ CHUAMTHANG Hub
POST /v1/dead-letters/replay (dry_run)
ลองแปลงก่อน — ผ่าน
POST /v1/dead-letters/replay HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWk
{
"ids": [
"dlq_3Fz09"
],
"dry_run": true
}HTTP/1.1 200 OK
{
"requested": 1,
"succeeded": 1,
"dry_run": true
}8 ทีมปฏิบัติการ CHUAMTHANG Hub
POST /v1/dead-letters/replay
replay จริง
POST /v1/dead-letters/replay HTTP/1.1
Authorization: Bearer ct_test_4Lm9QxB27dWk
{
"ids": [
"dlq_3Fz09"
]
}HTTP/1.1 200 OK
{
"requested": 1,
"succeeded": 1,
"failed": 0
}9 CHUAMTHANG Hub POS ครัวasync
delivery_order.created
ออเดอร์ขึ้นจอครัวสาขา 063 (ป้าย "ล่าช้า 6 นาที")
10 CHUAMTHANG Hub KINDEE Deliveryasync
confirm_order (ผ่าน connector)
Hub ยืนยันรับออเดอร์กับ KINDEE ย้อนหลัง ไรเดอร์ได้เวลาใหม่
ออเดอร์ไม่หาย (อยู่ใน dead-letter) · ทีมรู้ใน 1 นาที · หลังเพิ่มการจับคู่ replay สำเร็จ ออเดอร์ถึงครัวช้าไป 6 นาที แทนที่จะหายเงียบ
Objects
The WebhookEndpoint object
ปลายทางขาออกของระบบลูกค้า 1 รายการ
idstringไม่บังคับอ่านอย่างเดียวรหัส endpoint
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
urlstring · uriจำเป็นURL ปลายทาง (https · ห้าม IP ภายใน)
descriptionstringไม่บังคับคำอธิบาย
eventsarray<string>จำเป็นevent ที่ต้องการ (ใส่ * = ทั้งหมด)
statusstringไม่บังคับอ่านอย่างเดียวสถานะ — disabled อัตโนมัติเมื่อส่งไม่สำเร็จติดต่อกัน 3 วัน
secret_hintstringไม่บังคับอ่านอย่างเดียวใบ้ secret (ค่าเต็มแสดงครั้งเดียวตอนสร้าง/หมุน)
api_versionstringไม่บังคับเวอร์ชันรูปแบบ payload ที่ส่ง
branchesarray<string>ไม่บังคับส่งเฉพาะ event ของสาขาเหล่านี้ (null = ทุกสาขา)
stats_24hobjectไม่บังคับอ่านอย่างเดียวสถิติ 24 ชม.
ฟิลด์ย่อยของ
stats_24h(3)deliveredintegerไม่บังคับส่งสำเร็จ
failedintegerไม่บังคับครั้งที่ล้มเหลว (ก่อนลองใหม่)
avg_msintegerไม่บังคับเวลาตอบเฉลี่ยของปลายทาง
disabled_reasonstringไม่บังคับอ่านอย่างเดียวเหตุที่ปิด
created_atstring · date-timeไม่บังคับอ่านอย่างเดียวสร้างเมื่อ
updated_atstring · date-timeไม่บังคับอ่านอย่างเดียวแก้ล่าสุด
{
"id": "we_01Bi7",
"object": "webhook_endpoint",
"url": "https://bi.baankhao.example/hooks/chuamthang",
"description": "แดชบอร์ดยอดขายของฝ่ายบริหาร (BI)",
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted"
],
"status": "enabled",
"secret_hint": "whsec_…0c",
"api_version": "2026-08-01",
"branches": null,
"stats_24h": {
"delivered": 9184,
"failed": 37,
"avg_ms": 212
},
"disabled_reason": null,
"created_at": "2025-12-01T10:00:00+07:00",
"updated_at": "2026-09-15T14:20:00+07:00"
}
The Delivery object
การส่ง event 1 ครั้งไป 1 endpoint (รวมทุก attempt)
idstringไม่บังคับอ่านอย่างเดียวรหัสการส่ง
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
endpoint_idstringไม่บังคับอ่านอย่างเดียวendpoint ปลายทาง
event_idstringไม่บังคับอ่านอย่างเดียวevent ที่ส่ง (ใช้กันประมวลผลซ้ำฝั่งผู้รับ)
event_typestringไม่บังคับอ่านอย่างเดียวชนิด event
statusstringไม่บังคับอ่านอย่างเดียวสถานะ
endpoint_urlstring · uriไม่บังคับอ่านอย่างเดียวURL ปลายทาง ณ เวลาที่ส่ง
api_versionstringไม่บังคับอ่านอย่างเดียวเวอร์ชันรูปแบบ payload ที่ใช้
attempt_countintegerไม่บังคับอ่านอย่างเดียวจำนวนครั้งที่ส่งแล้ว (สูงสุด 7)
last_http_statusintegerไม่บังคับอ่านอย่างเดียวสถานะที่ปลายทางตอบครั้งล่าสุด
attemptsarray<object>ไม่บังคับอ่านอย่างเดียวทุกครั้งที่ส่ง
ฟิลด์ย่อยของ
attempts(5)nintegerไม่บังคับครั้งที่
atstring · date-timeไม่บังคับเวลา
http_statusintegerไม่บังคับสถานะที่ปลายทางตอบ (0 = เชื่อมต่อไม่ได้)
duration_msintegerไม่บังคับเวลาที่ใช้
errorstringไม่บังคับข้อผิดพลาด
next_retry_atstring · date-timeไม่บังคับอ่านอย่างเดียวจะลองครั้งถัดไปเมื่อ (null = ไม่ลองแล้ว)
requestobjectไม่บังคับอ่านอย่างเดียวสรุปคำขอที่ส่ง (ไม่เก็บ body เกิน 7 วัน)
ฟิลด์ย่อยของ
request(2)headersobjectไม่บังคับหัวที่ส่ง
body_bytesintegerไม่บังคับขนาด body
created_atstring · date-timeไม่บังคับอ่านอย่างเดียวเกิด event เมื่อ
{
"id": "whd_5Pq81",
"object": "webhook_delivery",
"endpoint_id": "we_01Bi7",
"event_id": "evt_01JB8K2",
"event_type": "delivery_order.created",
"status": "succeeded",
"endpoint_url": "https://bi.baankhao.example/hooks/chuamthang",
"api_version": "2026-08-01",
"attempt_count": 2,
"last_http_status": 200,
"attempts": [
{
"n": 1,
"at": "2026-10-12T10:25:02+07:00",
"http_status": 500,
"duration_ms": 1840,
"error": "ปลายทางตอบ 500"
},
{
"n": 2,
"at": "2026-10-12T10:26:02+07:00",
"http_status": 200,
"duration_ms": 198,
"error": null
}
],
"next_retry_at": null,
"request": {
"headers": {
"Chuamthang-Signature": "t=1791775502,v1=4e1c…",
"Content-Type": "application/json"
},
"body_bytes": 1184
},
"created_at": "2026-10-12T10:25:02+07:00"
}
The DeadLetter object
ข้อความที่ประมวลผลไม่ได้ (ตัวอย่าง: ออเดอร์สาขาใหม่ที่ยังไม่จับคู่)
idstringไม่บังคับอ่านอย่างเดียวรหัสรายการใน dead-letter
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
directionstringไม่บังคับอ่านอย่างเดียวinbound = ขาเข้าที่แปลงไม่ได้ · outbound = ขาออกที่ส่งไม่สำเร็จครบทุกครั้ง
sourcestringไม่บังคับอ่านอย่างเดียวแหล่ง (ขาเข้า) หรือ endpoint_id (ขาออก)
reasonobjectไม่บังคับอ่านอย่างเดียวสาเหตุ
ฟิลด์ย่อยของ
reason(2)codestringไม่บังคับรหัส error
detailsarray<string>ไม่บังคับรายละเอียด
external_idstringไม่บังคับอ่านอย่างเดียวเลขอ้างอิงของแหล่ง
payloadobjectไม่บังคับอ่านอย่างเดียวpayload ดิบที่ได้รับ (เก็บ 14 วัน)
received_atstring · date-timeไม่บังคับอ่านอย่างเดียวได้รับเมื่อ
statusstringไม่บังคับอ่านอย่างเดียวสถานะ
replayed_atstring · date-timeไม่บังคับอ่านอย่างเดียวreplay เมื่อ
replay_resultobjectไม่บังคับอ่านอย่างเดียวผล replay ล่าสุด
expires_atstring · date-timeไม่บังคับอ่านอย่างเดียวลบอัตโนมัติเมื่อ
{
"id": "dlq_3Fz09",
"object": "dead_letter",
"direction": "inbound",
"source": "kindee",
"reason": {
"code": "payload_unmappable",
"details": [
"storeCode \"BK-063\" ไม่อยู่ในตารางจับคู่สาขา"
]
},
"external_id": "KD-88214011",
"payload": {
"eventType": "ORDER_PLACED",
"orderRef": "KD-88214011",
"storeCode": "BK-063",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
},
"received_at": "2026-10-12T11:02:40+07:00",
"status": "pending",
"replayed_at": null,
"replay_result": null,
"expires_at": "2026-10-26T11:02:40+07:00"
}Endpoints (10)
| Method | Path | ทำอะไร | scope |
|---|---|---|---|
| POST | /v1/webhooks/inbound/{source} | รับ webhook ขาเข้า | |
| GET | /v1/webhook-endpoints | รายการ webhook endpoint | webhooks:read |
| POST | /v1/webhook-endpoints | สมัครรับ webhookidempotent | webhooks:write |
| PATCH | /v1/webhook-endpoints/{endpoint_id} | แก้ไข endpoint | webhooks:write |
| DELETE | /v1/webhook-endpoints/{endpoint_id} | ลบ endpoint | webhooks:write |
| POST | /v1/webhook-endpoints/{endpoint_id}/rotate-secret | หมุน secretidempotent | webhooks:write |
| GET | /v1/deliveries | ประวัติการส่ง | webhooks:read |
| POST | /v1/deliveries/{delivery_id}/retry | ส่งซ้ำ | webhooks:write |
| GET | /v1/dead-letters | รายการ dead-letter | webhooks:read |
| POST | /v1/dead-letters/replay | replay dead-letteridempotent | webhooks:replay |
รับ webhook ขาเข้า
POST/v1/webhooks/inbound/{source}
จุดรับ webhook จากบริการภายนอก — ตรวจลายเซ็นตามวิธีของแต่ละแหล่ง กันซ้ำด้วยเลขอ้างอิง แปลงเป็น event มาตรฐานของ Hub แล้วส่งต่อให้ POS และ endpoint ที่สมัครไว้
Path parameterspath
sourcestringจำเป็นแหล่ง
Headersheader
X-Kindee-Signaturestringไม่บังคับKINDEE: HMAC-SHA256 (base64) ของ raw body
X-Imaem-Signstringไม่บังคับIMAEM: HMAC-SHA256 (hex) ของ "<timestamp>.<raw body>"
X-PGA-Signaturestringไม่บังคับPAYGATE A: HMAC-SHA256 (hex) ของ raw body + IP allowlist
X-Request-Timestampstringไม่บังคับเวลาส่ง (unix) — เก่ากว่า 5 นาทีถูกปฏิเสธ
Request bodyapplication/json
(payload ของแหล่ง)objectจำเป็นรูปแบบเฉพาะของแต่ละแหล่ง — ดูตัวอย่างและการแปลงในเครื่องมือท้ายหน้า
ผลลัพธ์
- 202รับและแปลงแล้ว
- 200event ซ้ำ (เคยรับ external_id นี้แล้ว)
- 422แปลงไม่ได้ — เก็บเข้า dead-letter
- 401
signature_invalidลายเซ็นไม่ถูกต้อง - 401
signature_expiredลายเซ็นหมดอายุ - 404
source_unknownไม่รู้จักแหล่ง webhook - 422
payload_unmappableแปลง payload ไม่ได้ - 200
duplicate_eventevent ซ้ำ (ไม่ประมวลผลซ้ำ) - 413
payload_too_largeข้อมูลใหญ่เกิน - 400
invalid_jsonอ่าน JSON ไม่ได้
- ตอบภายใน 300 ms เสมอ — งานต่อจากนี้ทำแบบเข้าคิว (แหล่งส่วนใหญ่ timeout ที่ 5–10 วินาที)
- ตอบ 4xx ทำให้แหล่งหยุดส่งซ้ำ (ข้อมูลอยู่ใน dead-letter แล้ว) · 5xx แหล่งจะส่งซ้ำตามตารางของเขา
- ตัวอย่าง KINDEE: 2 รายการ 223.00 บาท → total 22300 สตางค์
curl -X POST "https://sandbox.api.chuamthang.example/v1/webhooks/inbound/kindee" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Content-Type: application/json" \
-H "Chuamthang-Version: 2026-08-01" \
-d '{
"eventType": "ORDER_PLACED",
"orderRef": "KD-88213470",
"storeCode": "BK-041",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
}'const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhooks/inbound/kindee', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Chuamthang-Version': '2026-08-01',
},
body: JSON.stringify({
"eventType": "ORDER_PLACED",
"orderRef": "KD-88213470",
"storeCode": "BK-041",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.post(
"https://sandbox.api.chuamthang.example/v1/webhooks/inbound/kindee",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Chuamthang-Version": "2026-08-01",
},
json={
"eventType": "ORDER_PLACED",
"orderRef": "KD-88213470",
"storeCode": "BK-041",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"received": true,
"event_id": "evt_01JB8K2",
"type": "delivery_order.created",
"duplicate": false
}{
"received": true,
"event_id": "evt_01JB8K2",
"duplicate": true
}{
"error": {
"code": "payload_unmappable",
"message": "แปลง payload ไม่ได้",
"details": [
"storeCode \"BK-063\" ไม่อยู่ในตารางจับคู่สาขา"
],
"dead_letter_id": "dlq_3Fz09",
"request_id": "req_6Wd0Lz8C"
}
}{
"error": {
"code": "signature_invalid",
"message": "ลายเซ็นไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#signature_invalid"
}
}{
"error": {
"code": "signature_expired",
"message": "ลายเซ็นหมดอายุ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#signature_expired"
}
}{
"error": {
"code": "source_unknown",
"message": "ไม่รู้จักแหล่ง webhook",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#source_unknown"
}
}{
"error": {
"code": "payload_unmappable",
"message": "แปลง payload ไม่ได้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#payload_unmappable"
}
}{
"error": {
"code": "duplicate_event",
"message": "event ซ้ำ (ไม่ประมวลผลซ้ำ)",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#duplicate_event"
}
}{
"error": {
"code": "payload_too_large",
"message": "ข้อมูลใหญ่เกิน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#payload_too_large"
}
}{
"error": {
"code": "invalid_json",
"message": "อ่าน JSON ไม่ได้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#invalid_json"
}
}รายการ webhook endpoint
endpoint ขาออกของระบบลูกค้าที่สมัครรับ event
Query parametersquery
statusstringไม่บังคับสถานะ
eventstringไม่บังคับendpoint ที่รับ event นี้
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — รหัสของรายการสุดท้ายในหน้าก่อน (ใช้ค่า next_cursor ที่ได้)
ผลลัพธ์
- 200endpoint
- 401
unauthorizedไม่ได้ยืนยันตัวตน - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
curl -X GET "https://sandbox.api.chuamthang.example/v1/webhook-endpoints?limit=20" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Chuamthang-Version: 2026-08-01"const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhook-endpoints?limit=20', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Chuamthang-Version': '2026-08-01',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.get(
"https://sandbox.api.chuamthang.example/v1/webhook-endpoints?limit=20",
headers={
"Authorization": f"Bearer {API_KEY}",
"Chuamthang-Version": "2026-08-01",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"data": [
{
"id": "we_01Bi7",
"object": "webhook_endpoint",
"url": "https://bi.baankhao.example/hooks/chuamthang",
"description": "แดชบอร์ดยอดขายของฝ่ายบริหาร (BI)",
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted"
],
"status": "enabled",
"secret_hint": "whsec_…0c",
"api_version": "2026-08-01",
"branches": null,
"stats_24h": {
"delivered": 9184,
"failed": 37,
"avg_ms": 212
},
"disabled_reason": null,
"created_at": "2025-12-01T10:00:00+07:00",
"updated_at": "2026-09-15T14:20:00+07:00"
},
{
"id": "we_07Fr2",
"object": "webhook_endpoint",
"url": "https://acc.franchise-041.example/webhooks/bk",
"description": "ระบบบัญชีของแฟรนไชส์ซีสาขา 041",
"events": [
"erp.sales_journal.posted",
"payment.succeeded"
],
"status": "enabled",
"secret_hint": "whsec_…0c",
"api_version": "2026-08-01",
"branches": [
"brn_041"
],
"stats_24h": {
"delivered": 241,
"failed": 0,
"avg_ms": 380
},
"disabled_reason": null,
"created_at": "2025-12-01T10:00:00+07:00",
"updated_at": "2026-09-15T14:20:00+07:00"
}
],
"has_more": false,
"next_cursor": null
}{
"error": {
"code": "unauthorized",
"message": "ไม่ได้ยืนยันตัวตน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#unauthorized"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}สมัครรับ webhook
ลงทะเบียน URL และ event ที่ต้องการ — ได้ secret สำหรับตรวจลายเซ็น (แสดงครั้งเดียว)
Headersheader
Idempotency-Keystring · uuidไม่บังคับกันรายการซ้ำเมื่อส่งซ้ำ (เก็บ 24 ชม.) — แนะนำ UUID v4 ต่อ 1 รายการ
Request bodyapplication/json
urlstring · uriจำเป็นURL ปลายทาง
eventsarray<string>จำเป็นevent
descriptionstringไม่บังคับคำอธิบาย
branchesarray<string>ไม่บังคับเฉพาะสาขา
api_versionstringไม่บังคับเวอร์ชัน payload
ผลลัพธ์
- 201สร้างแล้ว — เก็บ secret ไว้ทันที
- 400
invalid_requestคำขอไม่ถูกต้อง - 422
endpoint_url_invalidURL ปลายทางไม่ถูกต้อง - 409
idempotency_conflictIdempotency-Key ซ้ำแต่เนื้อหาต่าง - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
- Hub ส่ง POST ทดสอบ (event ping) ไป URL ทันที — ปลายทางต้องตอบ 2xx ภายใน 10 วินาที
- ตรวจลายเซ็นจากหัว Chuamthang-Signature: t=<unix>,v1=HMAC-SHA256(secret, "<t>.<raw body>") — ดูโค้ดและเครื่องมือตรวจในหัวข้อ Webhooks
curl -X POST "https://sandbox.api.chuamthang.example/v1/webhook-endpoints" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f" \
-H "Chuamthang-Version: 2026-08-01" \
-d '{
"url": "https://acc.franchise-041.example/webhooks/bk",
"events": [
"erp.sales_journal.posted",
"payment.succeeded"
],
"description": "ระบบบัญชีของแฟรนไชส์ซีสาขา 041",
"branches": [
"brn_041"
],
"api_version": "2026-08-01"
}'const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhook-endpoints', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': '7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f',
'Chuamthang-Version': '2026-08-01',
},
body: JSON.stringify({
"url": "https://acc.franchise-041.example/webhooks/bk",
"events": [
"erp.sales_journal.posted",
"payment.succeeded"
],
"description": "ระบบบัญชีของแฟรนไชส์ซีสาขา 041",
"branches": [
"brn_041"
],
"api_version": "2026-08-01"
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.post(
"https://sandbox.api.chuamthang.example/v1/webhook-endpoints",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f",
"Chuamthang-Version": "2026-08-01",
},
json={
"url": "https://acc.franchise-041.example/webhooks/bk",
"events": [
"erp.sales_journal.posted",
"payment.succeeded"
],
"description": "ระบบบัญชีของแฟรนไชส์ซีสาขา 041",
"branches": [
"brn_041"
],
"api_version": "2026-08-01"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_07Fr2",
"object": "webhook_endpoint",
"url": "https://acc.franchise-041.example/webhooks/bk",
"events": [
"erp.sales_journal.posted",
"payment.succeeded"
],
"branches": [
"brn_041"
],
"status": "enabled",
"secret": "whsec_ct_test_7d2b91fa0c",
"created_at": "2026-10-12T13:00:00+07:00"
}{
"error": {
"code": "invalid_request",
"message": "คำขอไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#invalid_request"
}
}{
"error": {
"code": "endpoint_url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#endpoint_url_invalid"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่เนื้อหาต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#idempotency_conflict"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}แก้ไข endpoint
PATCH/v1/webhook-endpoints/{endpoint_id}
เปลี่ยน URL event สาขา หรือเปิดใหม่หลังถูกปิดอัตโนมัติ (status: enabled)
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint (we_…)
Request bodyapplication/json
urlstring · uriไม่บังคับURL
eventsarray<string>ไม่บังคับevent
branchesarray<string>ไม่บังคับสาขา
statusstringไม่บังคับเปิด/ปิด
ผลลัพธ์
- 200endpoint หลังแก้
- 404
resource_not_foundไม่พบข้อมูล - 422
endpoint_url_invalidURL ปลายทางไม่ถูกต้อง - 422
validation_failedข้อมูลไม่ผ่านกฎธุรกิจ
curl -X PATCH "https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Content-Type: application/json" \
-H "Chuamthang-Version: 2026-08-01" \
-d '{
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted",
"sync.job.completed"
]
}'const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Chuamthang-Version': '2026-08-01',
},
body: JSON.stringify({
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted",
"sync.job.completed"
]
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.patch(
"https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Chuamthang-Version": "2026-08-01",
},
json={
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted",
"sync.job.completed"
]
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_01Bi7",
"object": "webhook_endpoint",
"url": "https://bi.baankhao.example/hooks/chuamthang",
"description": "แดชบอร์ดยอดขายของฝ่ายบริหาร (BI)",
"events": [
"delivery_order.created",
"payment.succeeded",
"erp.sales_journal.posted",
"sync.job.completed"
],
"status": "enabled",
"secret_hint": "whsec_…0c",
"api_version": "2026-08-01",
"branches": null,
"stats_24h": {
"delivered": 9184,
"failed": 37,
"avg_ms": 212
},
"disabled_reason": null,
"created_at": "2025-12-01T10:00:00+07:00",
"updated_at": "2026-10-12T13:10:00+07:00"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบข้อมูล",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#resource_not_found"
}
}{
"error": {
"code": "endpoint_url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#endpoint_url_invalid"
}
}{
"error": {
"code": "validation_failed",
"message": "ข้อมูลไม่ผ่านกฎธุรกิจ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#validation_failed"
}
}ลบ endpoint
DELETE/v1/webhook-endpoints/{endpoint_id}
หยุดส่งทันที การส่งที่ค้างลองใหม่ถูกยกเลิก (ประวัติเก็บต่อ 30 วัน)
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint (we_…)
ผลลัพธ์
- 204ลบแล้ว
- 404
resource_not_foundไม่พบข้อมูล - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
curl -X DELETE "https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Chuamthang-Version: 2026-08-01"const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7', {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Chuamthang-Version': '2026-08-01',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.delete(
"https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7",
headers={
"Authorization": f"Bearer {API_KEY}",
"Chuamthang-Version": "2026-08-01",
},
timeout=10,
)
res.raise_for_status()
print(res.json())(ไม่มีเนื้อหา){
"error": {
"code": "resource_not_found",
"message": "ไม่พบข้อมูล",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#resource_not_found"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}หมุน secret
POST/v1/webhook-endpoints/{endpoint_id}/rotate-secret
ออก secret ใหม่ — ช่วงเปลี่ยนผ่าน Hub ลงลายเซ็นทั้ง secret เก่าและใหม่ (v1 สองค่า) จนครบเวลาที่กำหนด
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint (we_…)
Headersheader
Idempotency-Keystring · uuidไม่บังคับกันรายการซ้ำเมื่อส่งซ้ำ (เก็บ 24 ชม.) — แนะนำ UUID v4 ต่อ 1 รายการ
Request bodyapplication/json
expire_old_in_hoursintegerไม่บังคับsecret เก่าใช้ได้อีกกี่ชั่วโมง (0 = ทันที)
ผลลัพธ์
- 200secret ใหม่ (แสดงครั้งเดียว)
- 404
resource_not_foundไม่พบข้อมูล - 422
validation_failedข้อมูลไม่ผ่านกฎธุรกิจ - 409
idempotency_conflictIdempotency-Key ซ้ำแต่เนื้อหาต่าง
curl -X POST "https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7/rotate-secret" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f" \
-H "Chuamthang-Version: 2026-08-01" \
-d '{
"expire_old_in_hours": 0
}'const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7/rotate-secret', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': '7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f',
'Chuamthang-Version': '2026-08-01',
},
body: JSON.stringify({
"expire_old_in_hours": 0
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.post(
"https://sandbox.api.chuamthang.example/v1/webhook-endpoints/we_01Bi7/rotate-secret",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f",
"Chuamthang-Version": "2026-08-01",
},
json={
"expire_old_in_hours": 0
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_01Bi7",
"secret": "whsec_ct_test_e41a07bc93",
"old_secret_expires_at": "2026-10-13T13:20:00+07:00"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบข้อมูล",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#resource_not_found"
}
}{
"error": {
"code": "validation_failed",
"message": "ข้อมูลไม่ผ่านกฎธุรกิจ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#validation_failed"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่เนื้อหาต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#idempotency_conflict"
}
}ประวัติการส่ง
การส่ง webhook ขาออกทุกครั้งพร้อม attempt ทั้งหมด — กรองตาม endpoint event สถานะ
Query parametersquery
endpoint_idstringไม่บังคับendpoint
statusstringไม่บังคับสถานะ
event_typestringไม่บังคับชนิด event
created_fromstring · date-timeไม่บังคับตั้งแต่
sortstringไม่บังคับเรียงลำดับ — ใส่ - นำหน้าเพื่อเรียงจากมากไปน้อย
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — รหัสของรายการสุดท้ายในหน้าก่อน (ใช้ค่า next_cursor ที่ได้)
ending_beforestringไม่บังคับcursor ย้อนกลับ — รหัสของรายการแรกในหน้าปัจจุบัน
ผลลัพธ์
- 200ประวัติ
- 400
invalid_requestคำขอไม่ถูกต้อง - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
curl -X GET "https://sandbox.api.chuamthang.example/v1/deliveries?endpoint_id=we_01Bi7&limit=20" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Chuamthang-Version: 2026-08-01"const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/deliveries?endpoint_id=we_01Bi7&limit=20', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Chuamthang-Version': '2026-08-01',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.get(
"https://sandbox.api.chuamthang.example/v1/deliveries?endpoint_id=we_01Bi7&limit=20",
headers={
"Authorization": f"Bearer {API_KEY}",
"Chuamthang-Version": "2026-08-01",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"data": [
{
"id": "whd_5Pq81",
"object": "webhook_delivery",
"endpoint_id": "we_01Bi7",
"event_id": "evt_01JB8K2",
"event_type": "delivery_order.created",
"status": "succeeded",
"endpoint_url": "https://bi.baankhao.example/hooks/chuamthang",
"api_version": "2026-08-01",
"attempt_count": 2,
"last_http_status": 200,
"attempts": [
{
"n": 1,
"at": "2026-10-12T10:25:02+07:00",
"http_status": 500,
"duration_ms": 1840,
"error": "ปลายทางตอบ 500"
},
{
"n": 2,
"at": "2026-10-12T10:26:02+07:00",
"http_status": 200,
"duration_ms": 198,
"error": null
}
],
"next_retry_at": null,
"request": {
"headers": {
"Chuamthang-Signature": "t=1791775502,v1=4e1c…",
"Content-Type": "application/json"
},
"body_bytes": 1184
},
"created_at": "2026-10-12T10:25:02+07:00"
}
],
"has_more": true,
"next_cursor": "whd_5Pq80"
}{
"error": {
"code": "invalid_request",
"message": "คำขอไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#invalid_request"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}ส่งซ้ำ
POST/v1/deliveries/{delivery_id}/retry
ส่ง event เดิม (event_id เดิม) ไปปลายทางอีกครั้งทันที — ใช้หลังแก้ปัญหาฝั่งปลายทาง
Path parameterspath
delivery_idstringจำเป็นรหัสการส่ง (whd_…)
ผลลัพธ์
- 202เข้าคิวส่งแล้ว
- 404
resource_not_foundไม่พบข้อมูล - 409
delivery_not_retryableส่งซ้ำไม่ได้
- ส่งซ้ำได้เฉพาะ status = failed · ปลายทางควรกันซ้ำด้วย event_id
curl -X POST "https://sandbox.api.chuamthang.example/v1/deliveries/whd_5Pq77/retry" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Chuamthang-Version: 2026-08-01"const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/deliveries/whd_5Pq77/retry', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Chuamthang-Version': '2026-08-01',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.post(
"https://sandbox.api.chuamthang.example/v1/deliveries/whd_5Pq77/retry",
headers={
"Authorization": f"Bearer {API_KEY}",
"Chuamthang-Version": "2026-08-01",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "whd_5Pq77",
"status": "pending",
"attempts_so_far": 7,
"queued_at": "2026-10-12T13:30:00+07:00"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบข้อมูล",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#resource_not_found"
}
}{
"error": {
"code": "delivery_not_retryable",
"message": "ส่งซ้ำไม่ได้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#delivery_not_retryable"
}
}รายการ dead-letter
ข้อความที่ประมวลผลไม่ได้: ขาเข้าที่แปลงไม่ได้ และขาออกที่ส่งไม่สำเร็จครบทุกครั้ง (เก็บ 14 วัน)
Query parametersquery
directionstringไม่บังคับทิศทาง
sourcestringไม่บังคับแหล่ง
reasonstringไม่บังคับรหัสสาเหตุ
statusstringไม่บังคับสถานะ
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — รหัสของรายการสุดท้ายในหน้าก่อน (ใช้ค่า next_cursor ที่ได้)
ผลลัพธ์
- 200รายการ
- 400
invalid_requestคำขอไม่ถูกต้อง - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
curl -X GET "https://sandbox.api.chuamthang.example/v1/dead-letters?source=kindee&reason=payload_unmappable&status=pending&limit=20" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Chuamthang-Version: 2026-08-01"const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/dead-letters?source=kindee&reason=payload_unmappable&status=pending&limit=20', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Chuamthang-Version': '2026-08-01',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.get(
"https://sandbox.api.chuamthang.example/v1/dead-letters?source=kindee&reason=payload_unmappable&status=pending&limit=20",
headers={
"Authorization": f"Bearer {API_KEY}",
"Chuamthang-Version": "2026-08-01",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"data": [
{
"id": "dlq_3Fz09",
"object": "dead_letter",
"direction": "inbound",
"source": "kindee",
"reason": {
"code": "payload_unmappable",
"details": [
"storeCode \"BK-063\" ไม่อยู่ในตารางจับคู่สาขา"
]
},
"external_id": "KD-88214011",
"payload": {
"eventType": "ORDER_PLACED",
"orderRef": "KD-88214011",
"storeCode": "BK-063",
"placedAt": 1791775500000,
"customer": {
"name": "คุณณัฐ",
"phone": "08x-xxx-5521"
},
"items": [
{
"menuCode": "MN-101",
"title": "กะเพราหมูกรอบไข่ดาว",
"qty": 2,
"priceTHB": "89.00",
"note": "ไม่เผ็ด"
},
{
"menuCode": "MN-201",
"title": "ชาไทยเย็น",
"qty": 1,
"priceTHB": "45.00",
"note": ""
}
],
"totalTHB": "223.00",
"payment": "PAID_ONLINE",
"riderEtaMin": 18
},
"received_at": "2026-10-12T11:02:40+07:00",
"status": "pending",
"replayed_at": null,
"replay_result": null,
"expires_at": "2026-10-26T11:02:40+07:00"
}
],
"has_more": false,
"next_cursor": null
}{
"error": {
"code": "invalid_request",
"message": "คำขอไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#invalid_request"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}replay dead-letter
ประมวลผลรายการใน dead-letter ใหม่ (หลังแก้สาเหตุ เช่น เพิ่มการจับคู่สาขา) — เลือกตามรหัสหรือตามตัวกรอง สูงสุด 500 รายการ/ครั้ง
Headersheader
Idempotency-Keystring · uuidไม่บังคับกันรายการซ้ำเมื่อส่งซ้ำ (เก็บ 24 ชม.) — แนะนำ UUID v4 ต่อ 1 รายการ
Request bodyapplication/json
idsarray<string>ไม่บังคับรหัสที่จะ replay
filterobjectไม่บังคับหรือเลือกตามตัวกรอง
ฟิลด์ย่อยของ
filter(3)sourcestringไม่บังคับแหล่ง
reasonstringไม่บังคับสาเหตุ
received_fromstring · date-timeไม่บังคับตั้งแต่
dry_runbooleanไม่บังคับแปลงอย่างเดียวไม่ส่งต่อ
ผลลัพธ์
- 200ผล replay
- 422
validation_failedข้อมูลไม่ผ่านกฎธุรกิจ - 413
payload_too_largeข้อมูลใหญ่เกิน - 409
idempotency_conflictIdempotency-Key ซ้ำแต่เนื้อหาต่าง - 403
insufficient_scopeสิทธิ์ของคีย์ไม่พอ
curl -X POST "https://sandbox.api.chuamthang.example/v1/dead-letters/replay" \
-H "Authorization: Bearer ct_test_4Lm9QxB27dWk" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f" \
-H "Chuamthang-Version: 2026-08-01" \
-d '{
"ids": [
"dlq_3Fz09"
]
}'const API_KEY = process.env.API_KEY; // ct_test_4Lm9QxB27dWk
const res = await fetch('https://sandbox.api.chuamthang.example/v1/dead-letters/replay', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': '7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f',
'Chuamthang-Version': '2026-08-01',
},
body: JSON.stringify({
"ids": [
"dlq_3Fz09"
]
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # ct_test_4Lm9QxB27dWk
res = requests.post(
"https://sandbox.api.chuamthang.example/v1/dead-letters/replay",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f",
"Chuamthang-Version": "2026-08-01",
},
json={
"ids": [
"dlq_3Fz09"
]
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"requested": 1,
"succeeded": 1,
"failed": 0,
"results": [
{
"id": "dlq_3Fz09",
"status": "replayed",
"event_id": "evt_01JB9C4",
"type": "delivery_order.created"
}
]
}{
"error": {
"code": "validation_failed",
"message": "ข้อมูลไม่ผ่านกฎธุรกิจ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#validation_failed"
}
}{
"error": {
"code": "payload_too_large",
"message": "ข้อมูลใหญ่เกิน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#payload_too_large"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่เนื้อหาต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#idempotency_conflict"
}
}{
"error": {
"code": "insufficient_scope",
"message": "สิทธิ์ของคีย์ไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#insufficient_scope"
}
}Webhooks — แจ้งเหตุการณ์ไปที่ระบบของคุณ
ลงทะเบียน URL ปลายทาง แล้วระบบจะส่ง POST พร้อม JSON ทุกครั้งที่เกิดเหตุการณ์ด้านล่าง · ตอบกลับ 2xx ภายใน 10 วินาที ไม่งั้นจะส่งซ้ำตามตาราง · ทุกคำขอมีหัว Chuamthang-Signature ให้ตรวจว่ามาจากเราจริง · event อาจมาซ้ำหรือสลับลำดับ ให้ใช้ id กันประมวลผลซ้ำ
delivery_order.createdออเดอร์แอปส่งอาหาร (รูปแบบมาตรฐาน)
ส่งเมื่อ: แปลง webhook ขาเข้าจาก KINDEE / IMAEM สำเร็จ
{
"id": "evt_01JB7Q00",
"type": "delivery_order.created",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"type": "delivery_order.created",
"source": "kindee",
"external_id": "KD-88213470",
"branch_id": "brn_041",
"placed_at": "2026-10-12T10:25:00+07:00",
"items": [
{
"sku": "MN-101",
"name": "กะเพราหมูกรอบไข่ดาว",
"quantity": 2,
"unit_price": 8900,
"note": "ไม่เผ็ด"
},
{
"sku": "MN-201",
"name": "ชาไทยเย็น",
"quantity": 1,
"unit_price": 4500,
"note": null
}
],
"total": 22300,
"payment_status": "paid",
"customer": {
"display_name": "คุณณัฐ",
"phone_masked": "08x-xxx-5521"
},
"eta_minutes": 18
}
}delivery_order.canceledออเดอร์แอปส่งอาหารถูกยกเลิก
ส่งเมื่อ: แหล่งแจ้งยกเลิกก่อนไรเดอร์รับ
{
"id": "evt_01JB7Q01",
"type": "delivery_order.canceled",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"source": "imaem",
"external_id": "IM2610-551208",
"branch_id": "brn_041",
"reason": "customer_canceled",
"refund": 28500
}
}tax_invoice.issuedออกใบกำกับภาษีอิเล็กทรอนิกส์แล้ว
ส่งเมื่อ: TAXDEE แจ้งออกเอกสาร
{
"id": "evt_01JB7Q02",
"type": "tax_invoice.issued",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"type": "tax_invoice.issued",
"source": "taxdee",
"document_no": "ETX-BK041-2610-00087",
"document_type": "tax_invoice_abb",
"bill_id": "bill_041_0187",
"buyer_tax_id": null,
"issued_at": "2026-10-11T12:40:22+07:00",
"amount": 40565,
"pdf_url": "https://files.taxdee.example/d/ETX-BK041-2610-00087.pdf"
}
}webhook.dead_letteredข้อความเข้า dead-letter
ส่งเมื่อ: แปลงขาเข้าไม่ได้ หรือส่งขาออกล้มเหลวครบทุกครั้ง
{
"id": "evt_01JB7Q03",
"type": "webhook.dead_lettered",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "dlq_3Fz09",
"direction": "inbound",
"source": "kindee",
"reason": {
"code": "payload_unmappable",
"details": [
"storeCode \"BK-063\" ไม่อยู่ในตารางจับคู่สาขา"
]
}
}
}webhook.endpoint.disabledendpoint ถูกปิดอัตโนมัติ
ส่งเมื่อ: ส่งไม่สำเร็จต่อเนื่อง 3 วัน
{
"id": "evt_01JB7Q04",
"type": "webhook.endpoint.disabled",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "we_03Old",
"url": "https://old-report.baankhao.example/hook",
"disabled_reason": "consecutive_failures",
"last_http_status": 410
}
}ส่งซ้ำเมื่อปลายทางไม่ตอบ
- 1ทันที
- 21 นาที
- 35 นาที
- 430 นาที
- 52 ชั่วโมง
- 66 ชั่วโมง
- 724 ชั่วโมง (ครั้งสุดท้าย)
ครบทุกครั้งแล้วยังล้มเหลว → ปิด endpoint อัตโนมัติและส่งอีเมลแจ้งผู้ดูแล · ดูประวัติการส่งและกดส่งซ้ำได้ในแดชบอร์ด
ตรวจลายเซ็น
# ลายเซ็นอยู่ในหัว Chuamthang-Signature: t=<unix>,v1=<hex>
# คำนวณ HMAC-SHA256(secret, "<t>.<raw body>") แล้วเทียบกับ v1
printf '%s' "$T.$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET"import crypto from 'node:crypto';
// ใช้ raw body (ยังไม่ parse JSON) เท่านั้น
export function verify(rawBody, sigHeader, secret) {
const parts = Object.fromEntries(sigHeader.split(',').map((p) => p.split('=')));
const age = Math.abs(Date.now() / 1000 - Number(parts.t));
if (age > 300) return false; // เก่ากว่า 5 นาที = ปฏิเสธ (กัน replay)
const expected = crypto.createHmac('sha256', secret).update(parts.t + '.' + rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}import hmac, hashlib, time
def verify(raw_body: bytes, sig_header: str, secret: str) -> bool:
parts = dict(p.split("=", 1) for p in sig_header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False # เก่ากว่า 5 นาที = ปฏิเสธ (กัน replay)
msg = parts["t"].encode() + b"." + raw_body
expected = hmac.new(secret.encode(), msg, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts["v1"])Errors — รหัสข้อผิดพลาด
ทุก error ตอบกลับเป็น JSON รูปแบบเดียวกัน พร้อม request_id สำหรับแจ้งทีมสนับสนุน · รหัส HTTP บอกกลุ่มของปัญหา ส่วน error.code บอกสาเหตุที่แน่นอน (ใช้เขียนเงื่อนไขในโค้ดได้ เพราะไม่เปลี่ยนตามภาษา)
- 4xx คำขอไม่ถูกต้อง — แก้ที่ฝั่งผู้เรียก ส่งซ้ำแบบเดิมจะได้ผลเดิม
- 5xx ปัญหาฝั่งระบบ — ลองใหม่แบบเว้นระยะ (exponential backoff) พร้อม Idempotency-Key
{
"error": {
"code": "signature_invalid",
"message": "ลายเซ็นไม่ถูกต้อง",
"param": "items[0].quantity",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.chuamthang.example/errors#signature_invalid"
}
}| HTTP | code | ความหมาย | วิธีแก้ |
|---|---|---|---|
| 401 | signature_invalid | ลายเซ็นไม่ถูกต้อง ลายเซ็นของ webhook ขาเข้าไม่ตรงกับ secret ของแหล่งนั้น | ตรวจ secret ที่ตั้งไว้ใน connector ให้ตรงกับฝั่งผู้ส่ง · ห้ามแก้ body ก่อนส่ง |
| 401 | signature_expired | ลายเซ็นหมดอายุ timestamp ในลายเซ็นเก่ากว่า 5 นาที (กันการส่งซ้ำ/replay) | ตรวจนาฬิกาฝั่งผู้ส่ง (NTP) · ส่งใหม่ด้วยลายเซ็นใหม่ |
| 404 | source_unknown | ไม่รู้จักแหล่ง webhook {source} ใน path ไม่ใช่แหล่งที่ลงทะเบียนไว้ | ใช้ค่า kindee imaem paygate_a paygate_b taxdee |
| 422 | payload_unmappable | แปลง payload ไม่ได้ payload ขาดฟิลด์ที่ต้องใช้ หรือค่าแปลงไม่ได้ (เช่น ราคาไม่ใช่ตัวเลข สาขาไม่อยู่ในตารางจับคู่) | ดู error.details[] · รายการถูกเก็บใน dead-letter ให้แก้ตารางจับคู่แล้ว replay |
| 200 | duplicate_event | event ซ้ำ (ไม่ประมวลผลซ้ำ) เคยรับ event ที่มี external id นี้แล้ว — ตอบ 200 พร้อม duplicate: true เพื่อให้ผู้ส่งหยุดส่งซ้ำ | ไม่ต้องทำอะไร · ใช้ duplicate: true ตรวจในล็อกได้ |
| 422 | endpoint_url_invalid | URL ปลายทางไม่ถูกต้อง URL ต้องเป็น https:// ที่เข้าถึงได้จากอินเทอร์เน็ต และไม่ใช่ IP ภายใน | ใช้โดเมนที่มีใบรับรอง TLS ถูกต้อง |
| 409 | delivery_not_retryable | ส่งซ้ำไม่ได้ การส่งนี้สำเร็จแล้ว หรือ endpoint ถูกปิด/ลบไปแล้ว | ส่งซ้ำได้เฉพาะสถานะ failed · เปิด endpoint ก่อน |
| 400 | invalid_request | คำขอไม่ถูกต้อง ขาดฟิลด์ที่จำเป็น หรือชนิดข้อมูลผิด — ดู error.param ว่าฟิลด์ไหน | ตรวจ body ตาม schema ของ endpoint · เงินต้องเป็นจำนวนเต็มสตางค์ · เวลาเป็น ISO 8601 |
| 400 | invalid_json | อ่าน JSON ไม่ได้ body ไม่ใช่ JSON ที่ถูกต้อง (เช่น มีจุลภาคเกิน หรือเข้ารหัสไม่ใช่ UTF-8) | ส่ง Content-Type: application/json และ encode ด้วยไลบรารี JSON ไม่ต่อสตริงเอง |
| 413 | payload_too_large | ข้อมูลใหญ่เกิน body เกิน 1 MB (webhook ขาเข้าเกิน 256 KB) หรือ batch เกินจำนวนที่กำหนด | แบ่งส่งเป็นหลายคำขอ · batch สูงสุดตามที่ระบุในแต่ละ endpoint |
| 404 | resource_not_found | ไม่พบข้อมูล รหัสใน path ไม่มีอยู่ หรืออยู่คนละสภาพแวดล้อม (sandbox/production) | ตรวจรหัสและสภาพแวดล้อม · ข้อมูล sandbox ถูกล้างทุกวันอาทิตย์ 03:00 |
| 403 | insufficient_scope | สิทธิ์ของคีย์ไม่พอ API key นี้ไม่มี scope ที่ endpoint ต้องการ | ขอ scope เพิ่มในหน้า Developer Console (ผู้ดูแลระบบของ BAANKHAO อนุมัติ) |
| 422 | validation_failed | ข้อมูลไม่ผ่านกฎธุรกิจ รูปแบบถูกแต่ขัดกับกฎ เช่น วันที่ในอนาคต หรือจำนวนติดลบ — ดู error.details[] | แก้ตามรายการใน details แล้วส่งใหม่ |
| 409 | idempotency_conflict | Idempotency-Key ซ้ำแต่เนื้อหาต่าง เคยใช้ Idempotency-Key นี้กับคำขอที่ body ต่างกันภายใน 24 ชั่วโมง | สร้างคีย์ใหม่ (UUID v4) ต่อ 1 รายการ · ส่งคีย์เดิมซ้ำได้เฉพาะเมื่อ body เหมือนเดิม |
| 429 | rate_limited | เรียกเกินโควตา เกินโควตาของคีย์หรือของ endpoint ในช่วงเวลา | รอตามหัว Retry-After แล้วลองใหม่แบบเว้นระยะเพิ่มขึ้น + jitter |
| 401 | unauthorized | ไม่ได้ยืนยันตัวตน ไม่มีหัว Authorization หรือ API key ไม่ถูกต้อง/ถูกเพิกถอน | ส่ง Authorization: Bearer ct_test_… (sandbox) หรือ ct_live_… (production) · ตรวจว่าใช้คีย์ให้ตรงสภาพแวดล้อม |
ไม่พบรหัสที่ค้นหา
Rate limit — โควตาการเรียก
| ขอบเขต | โควตา | Burst | หมายเหตุ |
|---|---|---|---|
| webhook ขาเข้า (ต่อแหล่ง) | 1,000 ครั้ง/นาที | 200 | เกินแล้วตอบ 429 — แหล่งส่งซ้ำเอง |
| จัดการ endpoint (ต่อคีย์) | 30 ครั้ง/นาที | — | |
| replay (ต่อคีย์) | 10 ครั้ง/นาที × 500 รายการ | — | |
| ขาออก (ต่อ endpoint) | 50 คำขอพร้อมกัน | — | ปลายทางตอบช้า → Hub ลดจำนวนพร้อมกันเอง |
RateLimit-Limitโควตาของช่วงเวลาRateLimit-Remainingครั้งที่เหลือRateLimit-Resetวินาทีจนโควตาเริ่มใหม่- เกินโควตา → 429 พร้อม
Retry-After· แนะนำลองใหม่แบบเว้นระยะเพิ่มขึ้น + สุ่มเล็กน้อย (jitter)
HTTP/1.1 429 Too Many Requests
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 23
Retry-After: 23
{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา ลองใหม่ใน 23 วินาที",
"request_id": "req_2Kd9QwZ1"
}
}เวอร์ชันและ Changelog
เลือกเวอร์ชันด้วยหัว Chuamthang-Version (ไม่ส่ง = เวอร์ชันที่ผูกกับ API key) · การเปลี่ยนที่ไม่ทำให้โค้ดเดิมพัง (เพิ่มฟิลด์/endpoint) ออกในเวอร์ชันเดิมได้ · การเปลี่ยนที่ทำให้พังออกเป็นเวอร์ชันใหม่เสมอ และแจ้งล่วงหน้าอย่างน้อย 6 เดือนก่อนปิดเวอร์ชันเก่า
| เวอร์ชัน | สถานะ | รองรับถึง |
|---|---|---|
2026-08-01 ล่าสุด | ปัจจุบัน | — |
2025-11-15 | ยังรองรับ | 30 ก.ย. 2570 |
2024-06-01 | เลิกใช้แล้ว | 31 ธ.ค. 2569 |
- เพิ่ม
2026-08-01เพิ่ม dry_run ใน POST /v1/dead-letters/replay
- เปลี่ยน
2026-08-01ขาเข้าที่แปลงไม่ได้ตอบ 422 (เดิม 202 แล้วเงียบ) — แหล่งเห็นปัญหาได้
- เพิ่ม
2025-11-15รองรับแหล่ง imaem (ลายเซ็น "<timestamp>.<body>")
- เพิ่ม
2025-11-15รองรับแหล่ง paygate_b
- ความปลอดภัย
2025-11-15ปฏิเสธ webhook ขาเข้าที่ timestamp เก่ากว่า 5 นาที (กัน replay)
- แก้ไข
2025-11-15event ซ้ำจาก KINDEE ทำให้ออเดอร์ขึ้นครัว 2 ใบ — กันซ้ำด้วย external_id แล้ว
- เพิ่ม
2025-11-15เปิดตัว dead-letter queue + GET /v1/dead-letters
- เลิกใช้
2025-11-15เลิกใช้หัว X-Chuamthang-Hmac (ลายเซ็นแบบไม่มี timestamp) — ใช้ Chuamthang-Signature
- เพิ่ม
2024-06-01POST /v1/webhook-endpoints/{id}/rotate-secret พร้อมช่วงเปลี่ยนผ่าน
ตัวแปลง payload ขาเข้า → รูปแบบมาตรฐาน
เลือกแหล่ง → แก้ payload ดิบได้ → เห็น event มาตรฐานที่ได้ + ตารางฟิลด์ที่ map และข้อผิดพลาดถ้าแปลงไม่ได้ (กฎเดียวกับ /v1/webhooks/inbound/{source}) · คำนวณในเบราว์เซอร์ทั้งหมด ไม่ได้เรียก API จริง