Appearance
Catalog API Reference
Thông tin nhanh
- Base URL:
https://api.salehay.com- Auth: JWT Bearer token (tenant-scoped)
- Prefix:
/api/catalog/*
Xem thêm: API Index · SOP Catalog
Categories
GET /api/catalog/categories
Lấy danh sách categories (active only).
bash
curl https://api.salehay.com/api/catalog/categories \
-H "Authorization: Bearer <TOKEN>"Response:
json
{
"categories": [
{
"id": "uuid",
"name": "Chăm sóc da",
"slug": "cham-soc-da",
"icon": "✨",
"color": "#FFD700",
"sort_order": 0
}
]
}POST /api/catalog/categories
Tạo category mới.
| Field | Type | Required | Mô tả |
|---|---|---|---|
name | string | ✅ | Tên danh mục |
slug | string | Auto-generate nếu trống | |
description | string | Mô tả | |
icon | string | Emoji hoặc icon name | |
color | string | Hex color | |
sort_order | int | Thứ tự hiển thị |
PATCH /api/catalog/categories/:id
Cập nhật category. Gửi chỉ các fields muốn sửa.
DELETE /api/catalog/categories/:id
Soft delete — set is_active = false.
Services
GET /api/catalog/services
Lấy danh sách services. Filter bằng query params:
| Param | Mô tả |
|---|---|
category | Filter theo category ID |
all=true | Include inactive services |
bash
curl "https://api.salehay.com/api/catalog/services?category=uuid" \
-H "Authorization: Bearer <TOKEN>"POST /api/catalog/services
| Field | Type | Required | Mô tả |
|---|---|---|---|
name | string | ✅ | Tên dịch vụ |
code | string | ✅ | Mã duy nhất (VD: "MASS-60") |
category_id | UUID | Gắn category | |
price | number | Giá (VND) | |
compare_price | number | Giá cũ (hiển thị giảm giá) | |
duration_minutes | int | Thời lượng | |
type | string | service/consultation/treatment/exam | |
tags | string[] | Tags | |
variants | JSON[] | Biến thể |
TIP
Khi thay đổi price, hệ thống tự ghi price_history — không cần call API riêng.
PATCH /api/catalog/services/:id
Cập nhật service. Price history auto-tracked.
DELETE /api/catalog/services/:id
Soft delete — is_active = false.
Products
GET /api/catalog/products
Lấy danh sách products (non-deleted). Filter: ?category=uuid.
POST /api/catalog/products
| Field | Type | Required | Mô tả |
|---|---|---|---|
name | string | ✅ | Tên sản phẩm |
sku | string | Mã SKU | |
category_id | UUID | Category | |
price | number | Giá bán | |
cost_price | number | Giá vốn | |
unit | string | Đơn vị (item, ml, kg...) | |
stock | int | Tồn kho | |
low_stock_threshold | int | Ngưỡng cảnh báo (default: 5) |
PATCH /api/catalog/products/:id
Cập nhật. Price history auto-tracked.
DELETE /api/catalog/products/:id
Soft delete — is_deleted = true, is_active = false.
Packages
GET /api/catalog/packages
Lấy danh sách packages kèm items (services + products).
Response:
json
{
"packages": [
{
"id": "uuid",
"name": "Gói Thư giãn",
"original_price": 500000,
"total_price": 400000,
"discount_type": "percent",
"discount_value": 20,
"items": [
{
"item_type": "service",
"service_name": "Massage 60p",
"quantity": 1,
"unit_price": 250000
}
]
}
]
}POST /api/catalog/packages
| Field | Type | Required | Mô tả |
|---|---|---|---|
name | string | ✅ | Tên gói |
description | string | Mô tả | |
discount_type | string | fixed / percent | |
discount_value | number | Giá trị giảm | |
validity_days | int | Hiệu lực (default: 365) | |
items | array | Danh sách items |
Item format:
json
{
"item_type": "service",
"service_id": "uuid",
"quantity": 1,
"unit_price": 250000,
"sort_order": 0
}PATCH /api/catalog/packages/:id
Cập nhật package. Nếu gửi items, hệ thống replace toàn bộ items cũ.
DELETE /api/catalog/packages/:id
Soft delete.