Skip to content

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.

FieldTypeRequiredMô tả
namestringTên danh mục
slugstringAuto-generate nếu trống
descriptionstringMô tả
iconstringEmoji hoặc icon name
colorstringHex color
sort_orderintThứ 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:

ParamMô tả
categoryFilter theo category ID
all=trueInclude inactive services
bash
curl "https://api.salehay.com/api/catalog/services?category=uuid" \
  -H "Authorization: Bearer <TOKEN>"

POST /api/catalog/services

FieldTypeRequiredMô tả
namestringTên dịch vụ
codestringMã duy nhất (VD: "MASS-60")
category_idUUIDGắn category
pricenumberGiá (VND)
compare_pricenumberGiá cũ (hiển thị giảm giá)
duration_minutesintThời lượng
typestringservice/consultation/treatment/exam
tagsstring[]Tags
variantsJSON[]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

FieldTypeRequiredMô tả
namestringTên sản phẩm
skustringMã SKU
category_idUUIDCategory
pricenumberGiá bán
cost_pricenumberGiá vốn
unitstringĐơn vị (item, ml, kg...)
stockintTồn kho
low_stock_thresholdintNgưỡ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

FieldTypeRequiredMô tả
namestringTên gói
descriptionstringMô tả
discount_typestringfixed / percent
discount_valuenumberGiá trị giảm
validity_daysintHiệu lực (default: 365)
itemsarrayDanh 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.

🔒 Internal Documentation — Dev Team Only