ดึงข้อมูล Stock ปัจจุบัน (Point-in-time Snapshot) แยกตาม SKU และ Warehouse
ข้อมูลที่ได้คือสถานะ Stock ณ ขณะที่เรียก API — ไม่ใช่ประวัติการเคลื่อนไหว สำหรับประวัติให้ใช้ List Stock Movements
Endpoint นี้เหมาะสำหรับ:
read:inventory
Access Token ต้องได้รับ Scope read:inventory มิฉะนั้นระบบจะปฏิเสธคำขอ
GET /api/partner/v1/inventory
Authorization: Bearer <access_token>
| Parameter | Type | Required | Description |
|---|---|---|---|
| branch_id | string (UUID) | No | กรองตามสาขา สามารถส่งหลายค่าได้ — intersect กับ Token's allowed_branch_ids |
| warehouse_id | string (UUID) | No | กรองตาม Warehouse |
| product_sku_id | string (UUID) | No | กรองตาม SKU |
| limit | integer | No | จำนวนรายการต่อหน้า (1–200) ค่าเริ่มต้น 50 |
| cursor | string | No | Cursor สำหรับดึงหน้าถัดไป |
สามารถระบุหลายสาขาได้
GET /api/partner/v1/inventory?branch_id=uuid1&branch_id=uuid2
ผลลัพธ์จะเป็น Intersection ระหว่างสาขาที่ส่งมากับสาขาที่ Token อนุญาต (allowed_branch_ids)
Endpoint นี้ใช้ Cursor-based Pagination
หาก has_more เป็น true ให้ส่ง next_cursor กลับมาใน parameter cursor
GET /api/partner/v1/inventory?cursor=<next_cursor>
ค่า Cursor เป็น Opaque Value — ไม่ควรอ่าน แก้ไข หรือสร้างเอง
curl -X GET \
"https://<host>/api/partner/v1/inventory?branch_id=b1f85720-71cf-420e-a584-e36b75d3fd20&limit=50" \
-H "Authorization: Bearer <access_token>"
{
"data": [
{
"id": "bf4ccd97-28c8-4c4e-9655-405cc2dcafbb",
"product_sku_id": "b55338d0-cf79-4431-996c-e21e84039757",
"warehouse_id": "1c5e4054-faef-4fb4-b95b-3baeefc2bcb9",
"branch_id": "b1f85720-71cf-420e-a584-e36b75d3fd20",
"quantity_on_hand": "100",
"quantity_reserved": "0",
"quantity_available": "100",
"average_cost": "224",
"stock_value": "22400",
"reorder_point": "80",
"last_movement_date": "2026-05-24T09:28:08.533Z",
"created_at": "2026-05-24T09:28:08.534Z",
"product_skus": {
"sku_code": "SKU-005",
"sku_name": "แซลมอน 10 ไม้",
"barcode": ""
},
"warehouses": {
"warehouse_name": "Main Storage"
}
}
],
"pagination": {
"next_cursor": "...",
"has_more": true,
"limit": 50
}
}
| Field | Type | Description |
|---|---|---|
| id | string (UUID) | Inventory Record ID |
| product_sku_id | string (UUID) | SKU ที่บันทึก Stock |
| warehouse_id | string (UUID) | Warehouse ที่เก็บ Stock |
| branch_id | string (UUID) | สาขาของ Warehouse นี้ |
| quantity_on_hand | string (decimal) | Stock ทั้งหมดที่มีอยู่ |
| quantity_reserved | string (decimal) | Stock ที่ถูก Reserve ไว้แล้ว |
| quantity_available | string (decimal) | Stock ที่พร้อมใช้ = on_hand − reserved |
| average_cost | string (decimal) | ต้นทุนเฉลี่ยต่อหน่วย |
| stock_value | string (decimal) | มูลค่า Stock รวม = quantity_on_hand × average_cost |
| reorder_point | string (decimal) | null | จุดที่ควรสั่งซื้อเพิ่ม — null หากไม่ได้ตั้งค่า |
| last_movement_date | string (ISO 8601) | null | วันที่มีการเคลื่อนไหว Stock ล่าสุด |
| created_at | string (ISO 8601) | เวลาที่สร้าง record |
| product_skus | { sku_code, sku_name, barcode } | ข้อมูล SKU สรุป |
| warehouses | { warehouse_name } | ชื่อ Warehouse |
ฟิลด์จำนวนและมูลค่าทั้งหมดถูกส่งกลับในรูปแบบ Decimal String เพื่อป้องกันปัญหา Floating Point
Partner ควรใช้ Decimal Library หรือ Big Number Library ในการคำนวณ
เมื่อ quantity_available ลดลงถึงหรือต่ำกว่า reorder_point ระบบจะส่ง Webhook event inventory.stock.low
ดูรายละเอียดที่ Create Webhook