{"openapi":"3.0.3","info":{"title":"VMASS Public API","description":"\n# 🚀 Hướng Dẫn Tích Hợp VMASS Public API\n\nChào mừng bạn đến với tài liệu kỹ thuật của VMASS POS System. API này cho phép các đối tác tích hợp sâu vào hệ thống bán hàng, quản lý đơn hàng, kho vận và khách hàng.\n\n## 🌟 Bắt đầu nhanh (Getting Started)\n\nNếu bạn là người mới, hãy làm theo các bước sau để thực hiện request đầu tiên:\n\n1. **Lấy API Key**: Truy cập **Tài khoản** > **Cài đặt** > **API Keys**.\n2. **Chọn Môi trường**:\n   - **Test Key** (`vmss_test_...`): Dùng để **Sandbox/Test**. Dữ liệu được tạo ra là dữ liệu ảo, không ảnh hưởng đến báo cáo doanh thu thực tế.\n   - **Live Key** (`vmss_live_...`): Dùng cho **Production**. Dữ liệu sẽ được ghi nhận vào hệ thống thật.\n3. **Authentication**: Gửi kèm header `X-API-Key: <your_key>` trong mọi request.\n\n---\n\n## 🔒 Authentication\n\n> 💡 **HƯỚNG DẪN TEST:** Để dùng thử API ngay trên trang này, hãy bấm nút **Authorize** 🔓 (nằm ở phía trên bên phải), nhập API Key và bấm **Authorize**.\n\nVMASS sử dụng API Key để xác thực. Bạn cần gửi key này trong header của request.\n\n```http\nX-API-Key: vmss_test_your_api_key_here\n```\n\n---\n\n## 🧪 Sandbox Mode (Dữ liệu Test) & Production Mode (Dữ liệu thật)\n\nHệ thống hỗ trợ chế độ Sandbox độc lập hoàn toàn để bạn an tâm tích hợp:\n\n| Tính năng | Sandbox (Test Key) | Production (Live Key) |\n|-----------|--------------------|-----------------------|\n| **Dữ liệu** | Dữ liệu Test (is_test=true) | Dữ liệu thật (Production) |\n| **Orders** | ✅ Tạo đơn hàng test & Xem đơn hàng thật | ✅ Tạo & Xem đơn hàng thật |\n| **Customers** | ✅ Tạo khách hàng test & Xem khách hàng thật | ✅ Xem & Cập nhật khách hàng thật |\n| **Inventory** | ✅ Chỉ xem (Read-only) | ✅ Xem & Cập nhật kho |\n| **Categories** | ✅ Chỉ xem (Read-only) | ✅ Xem & Cập nhật danh mục |\n| **Products** | ✅ Chỉ xem (Read-only) | ✅ Xem & Cập nhật sản phẩm |\n\n> **Lưu ý:** \n> - Bạn không thể dùng Test Key để sửa đổi dữ liệu thật (Ví dụ: Trừ kho thật, Sửa giá sản phẩm thật).\n\n---\n\n## 📞 Hỗ trợ\n\nNếu gặp vấn đề trong quá trình tích hợp, vui lòng liên hệ:\n- **Email**: hotro@vmass.vn\n- **Hotline**: 0708 245 246\n"},"servers":[{"url":"/api/public","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"**Hướng dẫn xác thực & test API:**\n\n**Bước 1:** Nhập API Key của bạn vào ô **Value** bên dưới (Ví dụ: `vmss_test_...` hoặc `vmss_live_...`)\n\n**Bước 2:** Nhấn nút **Authorize** để lưu xác thực, sau đó nhấn **Close** để đóng popup.\n\n**Bước 3:** Chọn một endpoint bất kỳ bên dưới, nhấn nút **Try it out** (góc phải) để mở form test.\n\n**Bước 4:** Điền các tham số (nếu có), rồi nhấn **Execute** để gửi request và xem kết quả.\n\n> 💡 **Mẹo:** API Key sẽ được lưu lại. Bạn không cần nhập lại khi refresh trang!"}},"schemas":{"Pagination":{"type":"object","properties":{"page":{"type":"integer","example":1},"limit":{"type":"integer","example":20},"total_items":{"type":"integer","example":100},"total_pages":{"type":"integer","example":5},"has_next":{"type":"boolean","example":true},"has_prev":{"type":"boolean","example":false}}},"Error":{"type":"object","properties":{"error":{"type":"string","example":"INVALID_REQUEST"},"message":{"type":"string","example":"Description of error"}}},"Order":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"total":{"type":"number"},"discount":{"type":"number"},"tax_fee":{"type":"number"},"status":{"type":"string"},"date":{"type":"string"},"time":{"type":"string"},"customer":{"type":"object"}}},"Product":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"sku":{"type":"string"},"barcode":{"type":"string"},"price":{"type":"string"},"price_sale":{"type":"string"},"active_sale":{"type":"boolean"},"image":{"type":"string"}}},"Inventory":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"sku":{"type":"string"},"unit":{"type":"string"},"count":{"type":"number"},"avarage_price":{"type":"number"},"nearest_expiry_date":{"type":"string","format":"date"}}},"Customer":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"address":{"type":"string"}}},"User":{"type":"object","properties":{"id":{"type":"integer"},"email":{"type":"string"},"username":{"type":"string"},"fullname":{"type":"string"},"companyName":{"type":"string"},"companyAddress":{"type":"string"},"hotline":{"type":"string"},"phoneNumber":{"type":"string"},"domain":{"type":"string"},"businessType":{"type":"string"},"image":{"type":"string"},"description":{"type":"string"},"namePay":{"type":"string","description":"Tên tài khoản ngân hàng"},"numberPay":{"type":"string","description":"Số tài khoản ngân hàng"},"bankPay":{"type":"string","description":"Tên ngân hàng"},"qrPayImage":{"type":"string","description":"URL ảnh QR thanh toán"},"birthDate":{"type":"string"},"companyUUID":{"type":"string"},"companyImage":{"type":"string"},"companyLogo":{"type":"string"},"companyWebsite":{"type":"string"},"companyStartTime":{"type":"string","example":"08:00"},"companyEndTime":{"type":"string","example":"22:00"},"credit_balance":{"type":"number","description":"Số dư tài khoản (VNĐ)"}}}},"parameters":{"PageParam":{"name":"page","in":"query","description":"Page number (1-indexed)","schema":{"type":"integer","default":1}},"LimitParam":{"name":"limit","in":"query","description":"Items per page (max 100)","schema":{"type":"integer","default":20}},"SortParam":{"name":"sort","in":"query","description":"Sort field. Prefix with - for descending","schema":{"type":"string","example":"-createdAt"}}}},"paths":{"/v1/orders":{"get":{"summary":"Danh sách đơn hàng","tags":["Orders"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/SortParam"},{"name":"status","in":"query","schema":{"type":"string"},"description":"Lọc theo trạng thái"},{"name":"date_from","in":"query","schema":{"type":"string","format":"date"},"description":"Từ ngày"},{"name":"date_to","in":"query","schema":{"type":"string","format":"date"},"description":"Đến ngày"},{"name":"total_gte","in":"query","schema":{"type":"number"},"description":"Tổng tiền >= giá trị"},{"name":"total_lte","in":"query","schema":{"type":"number"},"description":"Tổng tiền <= giá trị"}],"responses":{"200":{"description":"Danh sách đơn hàng với pagination"},"401":{"description":"Unauthorized - API Key không hợp lệ"}}},"post":{"summary":"Tạo đơn hàng mới","tags":["Orders"],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[A-Za-z0-9._:-]{8,128}$"},"description":"Khóa chống tạo trùng khi client retry. Dùng cùng key sẽ trả lại kết quả đã tạo trong 24 giờ."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"customer_id":{"type":"integer","description":"ID khách hàng (optional)","example":123},"items":{"type":"array","description":"Danh sách sản phẩm trong đơn hàng","items":{"type":"object","required":["product_id","quantity","price"],"properties":{"product_id":{"type":"integer","example":1,"description":"ID sản phẩm"},"variant_id":{"type":"integer","example":null,"description":"ID biến thể (nếu có)"},"quantity":{"type":"integer","example":2,"description":"Số lượng"},"price":{"type":"number","example":50000,"description":"Đơn giá (VNĐ)"},"note":{"type":"string","example":"Ít đường","description":"Ghi chú cho sản phẩm"},"ice":{"type":"string","example":"50","description":"Mức đá (0, 25, 50, 75, 100)"},"sugar":{"type":"string","example":"50","description":"Mức đường (0, 25, 50, 75, 100)"}}}},"payment_method":{"type":"string","enum":["cash","transfer","card","credit"],"default":"cash","description":"Phương thức thanh toán"},"staff_id":{"type":"string","description":"ID nhân viên tạo đơn"},"phone":{"type":"string","description":"Số điện thoại khách hàng (lưu vào từng món)"},"name":{"type":"string","description":"Tên khách hàng (lưu vào user_identify)"},"discount":{"type":"number","default":0,"example":10000,"description":"Giảm giá (VNĐ)"},"tax_fee":{"type":"number","default":0,"example":20000,"description":"Thuế (VNĐ)"},"fee_other":{"type":"number","default":0,"example":15000,"description":"Phí khác: ship, phục vụ... (VNĐ)"},"note":{"type":"string","example":"Giao hàng trước 12h","description":"Ghi chú đơn hàng"}}},"example":{"customer_id":143,"phone":"0972425431","name":"Bùi Minh","payment_method":"card","items":[{"product_id":9,"quantity":2,"price":79000,"note":"Ít ngọt","ice":"100","sugar":"50"}],"discount":17000,"tax_fee":10000,"fee_other":24000,"note":"Ship nhanh"}}}},"responses":{"201":{"description":"Đơn hàng được tạo thành công"},"400":{"description":"Dữ liệu không hợp lệ hoặc thiếu Idempotency-Key"},"409":{"description":"Idempotency-Key đang được xử lý"}}}},"/v1/orders/{id}":{"get":{"summary":"Chi tiết đơn hàng","tags":["Orders"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"ID đơn hàng"}],"responses":{"200":{"description":"Chi tiết đơn hàng bao gồm items"},"404":{"description":"Không tìm thấy đơn hàng"}}}},"/v1/orders/{id}/status":{"get":{"summary":"Lấy trạng thái đơn hàng","tags":["Orders"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Trạng thái đơn hàng"},"404":{"description":"Không tìm thấy đơn hàng"}}},"patch":{"summary":"Cập nhật trạng thái đơn hàng","tags":["Orders"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","description":"Trạng thái mới của đơn hàng","enum":["pending","processing","out_of_stock","completed","paid","cancelled"],"example":"completed"}}},"example":{"status":"completed"}}}},"responses":{"200":{"description":"Trạng thái được cập nhật"},"400":{"description":"Trạng thái không hợp lệ"},"404":{"description":"Không tìm thấy đơn hàng"}}}},"/v1/categories":{"get":{"summary":"Danh sách danh mục sản phẩm","description":"Lấy danh sách tất cả danh mục sản phẩm có sẵn để sử dụng khi tạo sản phẩm mới.","tags":["Categories"],"parameters":[{"name":"name_like","in":"query","schema":{"type":"string"},"description":"Tìm theo tên danh mục hoặc bỏ trống để tìm tất cả"}],"responses":{"200":{"description":"Danh sách danh mục","content":{"application/json":{"example":{"data":[{"id":1,"name":"Đồ uống","createdAt":"2024-01-15T08:00:00Z"},{"id":2,"name":"Đồ ăn","createdAt":"2024-01-15T08:00:00Z"},{"id":3,"name":"Tráng miệng","createdAt":"2024-01-15T08:00:00Z"}],"total":3}}}}}},"post":{"summary":"Tạo danh mục mới","description":"**Chỉ dành cho Live Key.** Test Key không thể tạo danh mục.","tags":["Categories"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"Đồ uống","description":"Tên danh mục"}}},"example":{"name":"Đồ uống đặc biệt"}}}},"responses":{"201":{"description":"Danh mục được tạo thành công"},"400":{"description":"Thiếu trường bắt buộc hoặc danh mục đã tồn tại"},"403":{"description":"Test Key không được phép tạo danh mục"}}}},"/v1/categories/{id}":{"delete":{"summary":"Xóa danh mục","description":"**Chỉ dành cho Live Key.** Soft delete danh mục.","tags":["Categories"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"},"description":"ID danh mục cần xóa"}],"responses":{"200":{"description":"Danh mục được xóa thành công"},"403":{"description":"Test Key không được phép xóa danh mục"},"404":{"description":"Không tìm thấy danh mục"}}}},"/v1/products":{"get":{"summary":"Danh sách sản phẩm","tags":["Products"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/SortParam"},{"name":"category_id","in":"query","schema":{"type":"integer"},"description":"Lọc theo danh mục"},{"name":"name_like","in":"query","schema":{"type":"string"},"description":"Tìm theo tên (like)"},{"name":"active_sale","in":"query","schema":{"type":"boolean"},"description":"Đang khuyến mãi"},{"name":"sku","in":"query","schema":{"type":"string"},"description":"Tìm theo SKU"},{"name":"barcode","in":"query","schema":{"type":"string"},"description":"Tìm theo barcode"}],"responses":{"200":{"description":"Danh sách sản phẩm"}}},"post":{"summary":"Tạo sản phẩm mới","description":"**Chỉ dành cho Live Key.** Test Key không thể tạo sản phẩm.","tags":["Products"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","price","category_id"],"properties":{"name":{"type":"string","example":"Cà phê sữa đá","description":"Tên sản phẩm"},"price":{"type":"number","example":35000,"description":"Giá bán (VNĐ)"},"category_id":{"type":"integer","example":1,"description":"ID danh mục"},"sku":{"type":"string","example":"CF-SUA-DA","description":"Mã SKU (tự động generate nếu không cung cấp)"},"barcode":{"type":"string","example":"8936012345678","description":"Mã vạch"},"image":{"type":"string","description":"URL hình ảnh sản phẩm"},"price_sale":{"type":"number","example":29000,"description":"Giá khuyến mãi (VNĐ)"},"active_sale":{"type":"boolean","default":false,"description":"Bật/tắt khuyến mãi"}}},"example":{"name":"Bạc xỉu Truyền thống","price":48000,"category_id":2,"sku":"SKU-2597","barcode":"8936017974578","price_sale":67000,"active_sale":false}}}},"responses":{"201":{"description":"Sản phẩm được tạo thành công"},"400":{"description":"Thiếu trường bắt buộc"},"403":{"description":"Test Key không được phép tạo sản phẩm"}}}},"/v1/products/{id}":{"get":{"summary":"Chi tiết sản phẩm","tags":["Products"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Chi tiết sản phẩm bao gồm variants"},"404":{"description":"Không tìm thấy sản phẩm"}}},"patch":{"summary":"Cập nhật sản phẩm","tags":["Products"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","example":"Cà phê sữa đá","description":"Tên sản phẩm"},"price":{"type":"number","example":35000,"description":"Giá gốc (VNĐ)"},"price_sale":{"type":"number","example":29000,"description":"Giá khuyến mãi (VNĐ)"},"active_sale":{"type":"boolean","example":true,"description":"Bật/tắt khuyến mãi"},"barcode":{"type":"string","example":"8936012345678","description":"Mã vạch"}}},"example":{"name":"Matcha latte Classic","price":28000,"price_sale":64000,"active_sale":true}}}},"responses":{"200":{"description":"Sản phẩm được cập nhật"},"404":{"description":"Không tìm thấy sản phẩm"}}},"delete":{"summary":"Xóa sản phẩm (Soft Delete)","description":"**Chỉ dành cho Live Key.** Test Key không thể xóa sản phẩm.","tags":["Products"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Đã xóa sản phẩm"},"403":{"description":"Test Key không được phép xóa sản phẩm"},"404":{"description":"Không tìm thấy sản phẩm"}}}},"/v1/products/{id}/variants":{"get":{"summary":"Danh sách biến thể của sản phẩm","tags":["Products"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Danh sách variants"},"404":{"description":"Không tìm thấy sản phẩm"}}}},"/v1/products/{id}/recipe":{"get":{"summary":"Công thức (nguyên liệu) của sản phẩm","tags":["Products"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Danh sách nguyên liệu cần để làm sản phẩm"},"404":{"description":"Không tìm thấy sản phẩm"}}}},"/v1/inventory":{"get":{"summary":"Danh sách nguyên liệu/tồn kho","tags":["Inventory"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/SortParam"},{"name":"name_like","in":"query","schema":{"type":"string"},"description":"Tìm theo tên"},{"name":"sku","in":"query","schema":{"type":"string"}},{"name":"barcode","in":"query","schema":{"type":"string"}},{"name":"count_lte","in":"query","schema":{"type":"number"},"description":"Số lượng <= giá trị"},{"name":"count_gte","in":"query","schema":{"type":"number"},"description":"Số lượng >= giá trị"}],"responses":{"200":{"description":"Danh sách nguyên liệu"}}},"post":{"summary":"Tạo nguyên liệu/tồn kho mới","description":"**Chỉ dành cho Live Key.** Test Key không thể tạo nguyên liệu.","tags":["Inventory"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","unit"],"properties":{"name":{"type":"string","example":"Cà phê rang xay","description":"Tên nguyên liệu"},"unit":{"type":"string","example":"kg","description":"Đơn vị tính (kg, g, lít, ml, cái, gói...)"},"count":{"type":"number","example":10,"description":"Số lượng ban đầu","default":0},"avarage_price":{"type":"number","example":150000,"description":"Giá nhập trung bình (VNĐ)","default":0},"sku":{"type":"string","example":"NL-CF-001","description":"Mã SKU (optional)"},"barcode":{"type":"string","example":"8936012345679","description":"Mã vạch (unique)"},"nearest_expiry_date":{"type":"string","format":"date","example":"2025-12-31","description":"Hạn sử dụng gần nhất"}}},"example":{"name":"Bột matcha","unit":"ml","count":3.7,"avarage_price":199000,"sku":"NL-139"}}}},"responses":{"201":{"description":"Nguyên liệu được tạo thành công"},"400":{"description":"Thiếu trường bắt buộc hoặc barcode trùng"},"403":{"description":"Test Key không được phép tạo nguyên liệu"}}}},"/v1/inventory/{id}":{"get":{"summary":"Chi tiết nguyên liệu","tags":["Inventory"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Chi tiết nguyên liệu"},"404":{"description":"Không tìm thấy"}}},"delete":{"summary":"Xóa nguyên liệu (Soft Delete)","description":"**Chỉ dành cho Live Key.** Test Key không thể xóa nguyên liệu.","tags":["Inventory"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Đã xóa nguyên liệu"},"403":{"description":"Test Key không được phép xóa nguyên liệu"},"404":{"description":"Không tìm thấy nguyên liệu"}}}},"/v1/inventory/{id}/quantity":{"patch":{"summary":"Cập nhật số lượng tồn kho","tags":["Inventory"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["quantity"],"properties":{"quantity":{"type":"number","description":"Số lượng","example":10},"operation":{"type":"string","enum":["add","subtract","set"],"description":"Phép tính: add (cộng), subtract (trừ), set (gán)","example":"add"}}},"example":{"quantity":25,"operation":"add"}}}},"responses":{"200":{"description":"Số lượng được cập nhật"},"400":{"description":"Số lượng không hợp lệ"},"404":{"description":"Không tìm thấy"}}}},"/v1/inventory/low-stock":{"get":{"summary":"Nguyên liệu sắp hết","tags":["Inventory"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"name":"threshold","in":"query","schema":{"type":"number","default":10},"description":"Ngưỡng cảnh báo (mặc định: 10%)"}],"responses":{"200":{"description":"Danh sách nguyên liệu có số lượng <= threshold"}}}},"/v1/inventory/expiring":{"get":{"summary":"Nguyên liệu sắp hết hạn","tags":["Inventory"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"name":"days","in":"query","schema":{"type":"integer","default":7},"description":"Số ngày (mặc định: 7)"}],"responses":{"200":{"description":"Danh sách nguyên liệu sắp hết hạn trong N ngày"}}}},"/v1/recipes":{"get":{"summary":"Danh sách tất cả công thức","tags":["Recipes"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"}],"responses":{"200":{"description":"Danh sách công thức (grouped by product)"}}},"post":{"summary":"Tạo/cập nhật công thức cho sản phẩm","tags":["Recipes"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["product_id","ingredients"],"properties":{"product_id":{"type":"integer","description":"ID sản phẩm","example":10},"ingredients":{"type":"array","description":"Danh sách nguyên liệu","items":{"type":"object","required":["stock_id","quantity"],"properties":{"stock_id":{"type":"integer","description":"ID nguyên liệu","example":5},"quantity":{"type":"number","description":"Số lượng cần dùng","example":0.5}}},"example":[{"stock_id":5,"quantity":0.5},{"stock_id":8,"quantity":0.2}]}}},"example":{"product_id":26,"ingredients":[{"stock_id":15,"quantity":3},{"stock_id":29,"quantity":3.5}]}}}},"responses":{"201":{"description":"Công thức được tạo/cập nhật"},"400":{"description":"Dữ liệu không hợp lệ"},"404":{"description":"Không tìm thấy sản phẩm"}}}},"/v1/recipes/product/{product_id}":{"get":{"summary":"Lấy công thức của 1 sản phẩm","tags":["Recipes"],"parameters":[{"name":"product_id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Danh sách nguyên liệu của sản phẩm"},"404":{"description":"Không tìm thấy sản phẩm"}}}},"/v1/recipes/inventory/{stock_id}":{"get":{"summary":"Lấy các sản phẩm sử dụng 1 nguyên liệu","tags":["Recipes"],"parameters":[{"name":"stock_id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Danh sách sản phẩm sử dụng nguyên liệu này"},"404":{"description":"Không tìm thấy nguyên liệu"}}}},"/v1/recipes/{id}":{"delete":{"summary":"Xóa 1 entry công thức","tags":["Recipes"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Đã xóa"},"404":{"description":"Không tìm thấy"}}}},"/v1/customers":{"get":{"summary":"Danh sách khách hàng","tags":["Customers"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/LimitParam"},{"name":"name_like","in":"query","schema":{"type":"string"},"description":"Tìm theo tên"},{"name":"phone","in":"query","schema":{"type":"string"},"description":"Tìm theo SĐT"},{"name":"email","in":"query","schema":{"type":"string"},"description":"Tìm theo email"}],"responses":{"200":{"description":"Danh sách khách hàng"}}},"post":{"summary":"Tạo khách hàng mới","tags":["Customers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"Nguyễn Văn A","description":"Tên khách hàng"},"phone":{"type":"string","example":"0901234567","description":"Số điện thoại"},"email":{"type":"string","example":"nguyenvana@gmail.com","description":"Email"},"address":{"type":"string","example":"123 Đường ABC, Quận 1, TP.HCM","description":"Địa chỉ"}}},"example":{"name":"Trần Anh","phone":"0982059704","email":"linh943@outlook.com","address":"95 Võ Văn Tần, Tân Bình, TP.HCM"}}}},"responses":{"201":{"description":"Khách hàng được tạo"},"409":{"description":"SĐT đã tồn tại"}}}},"/v1/customers/{id}":{"get":{"summary":"Chi tiết khách hàng","tags":["Customers"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Chi tiết khách hàng"},"404":{"description":"Không tìm thấy"}}},"patch":{"summary":"Cập nhật thông tin khách hàng","tags":["Customers"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"address":{"type":"string"}}}}}},"responses":{"200":{"description":"Khách hàng được cập nhật"},"404":{"description":"Không tìm thấy"}}},"delete":{"summary":"Xóa khách hàng (Soft Delete)","tags":["Customers"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa khách hàng"},"404":{"description":"Không tìm thấy"}}}},"/v1/user":{"get":{"summary":"Lấy thông tin tài khoản","description":"Lấy thông tin profile cơ bản của tài khoản kết nối (không bao gồm dữ liệu nhạy cảm)","tags":["User"],"responses":{"200":{"description":"Thông tin tài khoản","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/User"}}}}}}}}},"/v1/sandbox/reset":{"post":{"summary":"Xóa toàn bộ dữ liệu Test (Sandbox Cleanup)","description":"Xóa tất cả Orders, Bills, Webhooks được tạo bởi Test Key.","tags":["Sandbox"],"responses":{"200":{"description":"Dữ liệu test đã được xóa","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"deleted_stats":{"type":"object","properties":{"bills":{"type":"integer"},"orders":{"type":"integer"},"webhooks":{"type":"integer"}}}}}}}}}}}},"tags":[{"name":"Orders","description":"Quản lý đơn hàng - Tạo, xem, cập nhật trạng thái"},{"name":"Categories","description":"Quản lý danh mục sản phẩm - Xem danh sách, tạo mới, xóa"},{"name":"Products","description":"Quản lý sản phẩm - Xem danh sách, chi tiết, variants, công thức"},{"name":"Inventory","description":"Quản lý nguyên liệu/tồn kho - Theo dõi số lượng, cảnh báo hết hàng"},{"name":"User","description":"Thông tin tài khoản - Lấy profile cơ bản"},{"name":"Recipes","description":"Quản lý công thức sản phẩm - Liên kết sản phẩm với nguyên liệu"},{"name":"Customers","description":"Quản lý khách hàng - Thông tin, lịch sử mua hàng"},{"name":"Sandbox","description":"Công cụ hỗ trợ Test/Sandbox - Dọn dẹp dữ liệu"}]}