Endpoints: สินค้าและออเดอร์
Endpoint สำหรับแคตตาล็อก, ออเดอร์, สต๊อก และรายการร้านของคุณ เพิ่งเริ่มใช้งาน? อ่าน เริ่มต้นใช้งาน สำหรับการยืนยันตัวตน และดู หลักการทั่วไป สำหรับโครงห่อผลลัพธ์, วันที่ และการแบ่งหน้า ทุก endpoint เป็นแบบอ่านอย่างเดียว
Products & catalog
POST/api/canonical-product-controller/canonical/fetch-products
Fetches canonical products with their current Shopee binding data. Returns one row per (canonical, binding) pair—canonicals with multiple Shopee listings produce multiple results. Useful for Shopee-keyed product lookups and reconciliation workflows.
Request body
Array of CanonicalProductWithShopeeBindingSearchParams — filter by canonical id, name, SKU, model SKU, or by Shopee item/model/shop id and region.
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | no | Canonical variant id |
name | string | no | Canonical product name (exact match) |
brand | string | no | Brand name |
sku | string | no | Canonical SKU |
modelSku | string | no | Canonical model SKU |
shopeeItemId | integer | no | Shopee item id |
shopeeModelId | integer | no | Shopee model id (for modeled items) |
shopeeShopId | integer | no | Shopee shop id |
region | string | no | Region code (e.g. 'TH') |
Response — Array of CanonicalProductWithShopeeBindingView
List of canonical products with their Shopee binding details (price, stock, margin, images). Each canonical can appear multiple times if it has multiple Shopee bindings.
| Field | Type | Description |
|---|---|---|
id | integer | Canonical variant id |
name | string | Product name |
sku | string | Canonical SKU |
cogs | number | Total cost of goods sold |
price | number | Current Shopee listing price |
stock | integer | Current Shopee stock |
margin | number | Margin on this Shopee binding (0–1 fraction) |
totalStock | integer | Min stock across all platform bindings for this canonical |
shopeeItemId | integer | Shopee item id |
shopeeModelId | integer | Shopee model id (if modeled) |
imageUrl | string | Product image URL from Shopee |
…and more — see the full schema in the OpenAPI spec.
POST/api/canonical-product-controller/canonical/fetch-products-with-platforms
Fetches canonical products and attaches ALL platform bindings (Shopee, Lazada, TikTok) in a platforms array. One row per canonical, regardless of how many platforms it's bound to. Used for neutral, multi-platform product lists.
Request body
Array of CanonicalProductSearchParams — filter by canonical id, name, SKU, model SKU, or by platform and platform shop id.
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | no | Canonical variant id |
name | string | no | Product name |
sku | string | no | Canonical SKU |
modelSku | string | no | Model SKU |
platform | string | no | Platform code ('shopee', 'lazada', 'tiktok') |
platformShopId | string | no | Shopee shop id, Lazada seller id, or TikTok shop id |
activeOnly | boolean | no | When true, exclude inactive bindings (default false) |
Response — Array of CanonicalProductWithPlatforms
List of canonical products, each carrying margin distribution stats and a platforms array of all bound marketplace items.
| Field | Type | Description |
|---|---|---|
id | integer | Canonical variant id |
name | string | Product name |
sku | string | Canonical SKU |
cogs | number | Total COGS |
totalStock | integer | Min stock across all bindings |
variantCount | integer | Number of platform variants/bindings |
medianMargin | number | Median margin across bindings |
platforms | array | Per-binding refs (platform, item/model ids, shop id, price, stock, margin) |
…and more — see the full schema in the OpenAPI spec.
POST/api/canonical-product-controller/canonical/fetch-products-with-platforms-paginated
Cursor-paginated canonical product list with the same platform-bindings metadata as the non-paginated variant. Pass the returned nextCursor.canonicalId back as cursorCanonicalId for the next page. Supports optional platform/shop scoping.
Request body
CanonicalProductPaginatedFetchRequest
| Field | Type | Required | Description |
|---|---|---|---|
cursorCanonicalId | integer | no | Cursor from prior page's nextCursor (omit for first page) |
pageSize | integer | no | Rows per page (default 20) |
platform | string | no | Filter to this platform |
platformShopId | string | no | Filter to this shop/seller id |
filters | array | no | Column filters (text search, numeric range) |
Response — CursorPaginatedResult<CanonicalProductCursor, CanonicalProductWithPlatforms>
| Field | Type | Description |
|---|---|---|
rows | array | Array of CanonicalProductWithPlatforms |
nextCursor | object | Cursor for next page (canonicalId, userId) or null if at end |
POST/api/canonical-product-controller/canonical/fetch-products-with-platforms-paginated/v2
Offset-based pagination (page number + size) over canonical products with platform bindings. Supports sorting (name, SKU, COGS, stock) and per-column filters. Preferred for UI product tables that need page numbers and sort controls.
Request body
CanonicalProductPaginatedV2FetchRequest
| Field | Type | Required | Description |
|---|---|---|---|
page | integer | no | 0-based page number (default 0) |
pageSize | integer | no | Rows per page (default 20) |
sortField | string | no | Sort column ('name', 'sku', 'modelSku', 'cogs', 'stock') |
sortDir | string | no | 'asc' or 'desc' (default 'asc') |
platform | string | no | Filter by platform |
platformShopId | string | no | Filter by shop/seller id |
filters | array | no | Per-column text/numeric filters |
Response — OffsetPaginatedResult<CanonicalProductWithPlatforms>
| Field | Type | Description |
|---|---|---|
rows | array | Products for this page |
totalItems | integer | Total product count |
totalPages | integer | Total page count |
currentPage | integer | 0-based current page |
POST/api/canonical-product-controller/canonical/fetch-products-margin-stats
Computes margin distribution (min, max, median, quartiles) over the filtered canonical product set. Uses the same filters as the paginated fetch; pagination parameters are ignored. Products with no margined binding are excluded.
Request body
CanonicalProductPaginatedV2FetchRequest — only the filter/platform/platformShopId fields are used.
Response — ProductMarginStats
| Field | Type | Description |
|---|---|---|
productCount | integer | Products with non-null margin in the result set |
minMargin | number | Lowest margin (0–1 fraction) |
maxMargin | number | Highest margin |
medianMargin | number | Median margin |
q1Margin | number | 25th percentile margin |
q3Margin | number | 75th percentile margin |
dataFreshAt | string (date) | Oldest product pull time across the user's shops |
POST/api/canonical-product-controller/canonical/fetch-product-costs
Reads the detailed per-component cost breakdown (manufacturing, labor, shipping, packaging) and VAT-inclusivity flags for one or more canonical variants. Backs the product Cost Breakdown editor.
Request body
Array of integer — canonical variant ids.
Response — Array of CanonicalProductCostRow
| Field | Type | Description |
|---|---|---|
id | integer | Canonical variant id |
cogs | number | Total cost of goods sold |
manufacturingCost | number | Manufacturing cost |
laborCost | number | Labor cost |
shippingCost | number | Inbound shipping cost |
packagingCost | number | Packaging cost |
manufacturingCostVatInclusive | boolean | Whether manufacturing cost includes VAT |
shippingCostVatInclusive | boolean | Whether shipping cost includes VAT |
packagingCostVatInclusive | boolean | Whether packaging cost includes VAT |
POST/api/canonical-product-controller/canonical/search-products
Searches canonical products by name, SKU, model SKU, and (if numeric) platform item ids using trigram similarity. Results are ranked by relevance and hard-capped at 50 hits. Optional platform/shop filters narrow results.
Request body
CanonicalProductSearchRequest
| Field | Type | Required | Description |
|---|---|---|---|
query | string | no | Free-text: product name, SKU, model SKU, or numeric item id |
platform | string | no | Restrict to canonicals bound on this platform |
platformShopId | string | no | Restrict to canonicals bound to this shop/seller id |
Response — Array of CanonicalProductSearchHit
Top-50 results ranked by relevance.
| Field | Type | Description |
|---|---|---|
canonical | object | CanonicalProductWithPlatforms (name, SKU, COGS, all platform bindings) |
score | number | Relevance score |
matchedFields | array | Which fields matched (NAME, SKU, MODEL_SKU, ITEM_ID) |
GET/api/canonical-product-controller/canonical/has-cogs
Checks whether any canonical product variant has COGS set for a given Shopee shop. Used to gate features (like the financial breakdown) until the seller has populated cost data.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
shopId | integer | yes | Shopee shop id |
Response — HasCogsResponse
| Field | Type | Description |
|---|---|---|
hasCogs | boolean | True if at least one variant for this shop has COGS > 0 |
GET/api/canonical-product-controller/lazada/canonical/has-cogs
Checks whether any canonical product variant has COGS set for a given Lazada seller.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
sellerId | integer | yes | Lazada seller account id |
region | string | yes | Region code (e.g. 'TH') |
Response — HasCogsResponse
| Field | Type | Description |
|---|---|---|
hasCogs | boolean | True if at least one variant for this seller has COGS > 0 |
GET/api/canonical-product-controller/tiktok/canonical/has-cogs
Checks whether any canonical product variant has COGS set for a given TikTok shop.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
shopId | integer | yes | TikTok shop id |
region | string | yes | Region code (e.g. 'TH') |
Response — HasCogsResponse
| Field | Type | Description |
|---|---|---|
hasCogs | boolean | True if at least one variant for this shop has COGS > 0 |
Orders
POST/api/canonical-order-controller/canonical/orders/fetch-paginated
Cursor-paginated list of orders across all the user's shops on every connected platform (Shopee, Lazada, TikTok). Returns order id, platform, status, buyer-paid total, and timestamps. Pass the returned nextCursor.canonicalOrderId back as cursorCanonicalOrderId for the next page.
Request body
CanonicalOrderPaginatedFetchRequest
| Field | Type | Required | Description |
|---|---|---|---|
cursorCanonicalOrderId | integer | no | Cursor from prior page (omit for first page) |
pageSize | integer | no | Rows per page (default 20) |
platform | string | no | Filter by platform ('shopee', 'lazada', 'tiktok'); omit for all |
fromDate | integer | no | Start date (YYYYMMDD) |
toDate | integer | no | End date (YYYYMMDD) |
Response — CursorPaginatedResult<CanonicalOrderCursor, CanonicalOrder>
| Field | Type | Description |
|---|---|---|
rows | array | Array of CanonicalOrder |
nextCursor | object | Cursor for next page or null if at end |
GET/api/canonical-order-controller/canonical/orders/{canonicalOrderId}
Fetches one complete order with all line items, quantities, prices, and fees — including the per-line and order-level financial breakdown (revenue, COGS, profit, margin).
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
canonicalOrderId | integer | yes | Canonical order id |
Response — CanonicalOrder
| Field | Type | Description |
|---|---|---|
canonicalOrderId | integer | Order id |
platform | string | Platform ('shopee', 'lazada', 'tiktok') |
orderSn | string | Order serial number |
orderStatus | string | Platform-specific status code |
totalOrderRevenue | number | Post-discount item revenue |
totalOrderCogs | number | Total COGS across line items |
totalOrderProfit | number | Total profit (revenue − COGS − fees) |
totalOrderMargin | number | Overall order margin (profit / revenue) |
createTime | string (date) | Order creation timestamp |
lineItems | array | Per-line items (name, quantity, price, COGS, profit, margin, fulfillment status) |
…and more — see the full schema in the OpenAPI spec.
GET/api/canonical-order-controller/canonical/orders/count-by-date
Counts total orders across all the user's shops for an optional platform and date range. Returns a single integer. Useful for dashboards, health checks, and sync progress.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
platform | string | no | Filter by platform; omit for all |
fromDate | string | no | Start date (YYYY-MM-DD), inclusive |
toDate | string | no | End date (YYYY-MM-DD), inclusive |
Response — integer — total order count matching the filters.
GET/api/canonical-order-controller/canonical/orders/pending-shipment/count
Counts orders awaiting shipment over a rolling recent window — a real-time fulfillment backlog indicator.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
sinceDays | integer | no | Look back N days (default 30) |
Response — integer — count of orders in pending-shipment status in the last N days.
Inventory
GET/api/inventory/reorder
Fetches the latest computed reorder policies for all SKUs: when to reorder and how much, with reorder point, order-now quantity, and order-by date.
Response — Array of InventoryReorderPolicyDto
| Field | Type | Description |
|---|---|---|
canonicalVariantId | integer | SKU id |
canonicalVariantName | string | Product/variant name |
currentStock | integer | On-hand inventory |
reorderPoint | integer | Stock level triggering a reorder signal |
orderQuantity | integer | Units to order when triggered |
orderByDate | string (date) | Target procurement date to avoid stockout |
stockoutRiskPercent | number | Probability of stockout in the forecast horizon |
…and more — see the full schema in the OpenAPI spec.
GET/api/inventory/forecast
Fetches the demand forecast for one or all canonical products over the planning horizon. Returns forecast rows with predictive bands (q10/q90), expected-demand center line (q50), credible band (muQ10/muQ90), and a trailing-week baseline (ma8) for charting.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
canonicalVariantId | integer | no | One SKU; omit for all products |
bucket | string | no | Time bucket ('D' daily, 'W' weekly; default weekly) |
Response — InventoryForecastResponseDto
| Field | Type | Description |
|---|---|---|
variants | array | Per-variant forecasts: product header, stats block, bindings, and forecast rows (q10, q50, q90, muQ10, muQ90, ma8) |
…and more — see the full schema in the OpenAPI spec.
GET/api/inventory/demand-chart
Fetches realized weekly demand history and the latest forecast (with all confidence bands) in one call, ready for plotting. Partial in-progress weeks are flagged.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
canonicalVariantId | integer | no | One SKU; omit for all products |
bucket | string | no | Time bucket (default 'W' weekly) |
weeksBack | integer | no | Weeks of history to include (default 26) |
Response — InventoryDemandChartDto
| Field | Type | Description |
|---|---|---|
canonicalVariantId | integer | SKU id |
history | array | Realized weekly units (isPartial=true for in-progress week) |
forecast | array | Latest forecast rows (q10, q50, q90, muQ10, muQ90, ma8) |
…and more — see the full schema in the OpenAPI spec.
GET/api/inventory/params
Fetches inventory settings: lead time, service target, MOQ/lot size, capital budget, alert toggles, plus any per-variant reorder-point overrides.
Response — Array of InventoryPolicyParamsDto
| Field | Type | Description |
|---|---|---|
canonicalVariantId | integer | SKU id (null for the shop-default row) |
leadTimeDays | integer | Procurement lead time |
serviceLevel | number | Target in-stock probability (0–1, e.g. 0.95) |
minimumOrderQuantity | integer | Minimum purchase quantity per order |
capitalBudget | number | Capital budget for reorders |
userReorderPoint | integer | Manual reorder-point override (null = use model) |
alertsEnabled | boolean | Live alerts on/off (shop-default row) |
…and more — see the full schema in the OpenAPI spec.
GET/api/inventory/alerts
Fetches live and resolved inventory alerts. An alert fires when stock reaches the reorder point and auto-resolves once stock recovers.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by status ('open', 'acknowledged', 'dismissed', 'resolved') |
Response — Array of InventoryAlertDto
| Field | Type | Description |
|---|---|---|
id | integer | Alert id |
canonicalVariantId | integer | SKU id |
currentStock | integer | Stock level when the alert fired |
thresholdSource | string | 'user' (override) or 'model' (algorithm) |
thresholdLevel | integer | Reorder point that triggered the alert |
status | string | 'open', 'acknowledged', 'dismissed', or 'resolved' |
firedAt | string (date) | When the alert was triggered |
resolvedAt | string (date) | When stock recovered (null if still open) |
…and more — see the full schema in the OpenAPI spec.
GET/api/inventory/open-orders
Fetches purchase orders the merchant has logged as in flight. Open orders feed the next model run as pipeline arrivals and count into the position checked by alerts.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by status ('open', 'received', 'cancelled') |
Response — Array of InventoryOpenOrderDto
| Field | Type | Description |
|---|---|---|
id | integer | Purchase order id |
canonicalVariantId | integer | SKU id |
orderedQuantity | integer | Units ordered |
expectedArrivalWeek | string (date) | Target arrival date (Monday of the week) |
status | string | 'open', 'received', or 'cancelled' |
receivedAt | string (date) | When stock was received (null if not yet arrived) |
…and more — see the full schema in the OpenAPI spec.
Unified financial overview
POST/api/unified/financial-overview/shop-overview
A user-wide realized-profit overview rolled up across ALL your shops (Shopee + TikTok + Lazada) over a lookback window. Returns total profit, revenue-weighted average margin, top/worst products, the cost-breakdown P&L waterfall, and per-platform subtotals. The optional body tunes the window, top-N, and VAT treatment.
Request body
UnifiedFinancialOverviewFetchRequest (optional)
| Field | Type | Required | Description |
|---|---|---|---|
lookbackDays | integer | no | Trailing window in days (default 30); ignored if from/to set |
from | string (date) | no | Explicit start date (YYYY-MM-DD); overrides lookbackDays |
to | string (date) | no | Explicit end date (YYYY-MM-DD) |
topN | integer | no | Top/worst products to return (default 5) |
includeVat | boolean | no | Include VAT calculation (default false) |
Response — UnifiedUserFinancialOverview
| Field | Type | Description |
|---|---|---|
grossGmv | number | Total GMV across platforms |
totalNetRevenue | number | Post-discount, pre-fee revenue |
totalProfit | number | Realized profit (revenue − COGS − fees) |
avgMargin | number | Revenue-weighted average margin (0–1) |
lossMakerCount | integer | Products with negative profit |
costBreakdown | array | P&L waterfall (commission, payment fee, shipping, VAT, etc.) |
topProducts | array | Top earners by profit |
worstProducts | array | Thinnest margins |
perPlatform | array | Per-platform revenue, profit, and margins |
…and more — see the full schema in the OpenAPI spec.
Shops & accounts
GET/api/shopee/fetch-all-user-shops
Fetches all Shopee shops connected to your account. Call this first to discover which shops you own — most shop-scoped endpoints need a shopId from here.
Response — Array of ShopeeShop
| Field | Type | Description |
|---|---|---|
shopId | integer | Shopee shop id |
shopName | string | Display shop name |
region | string | Region code (e.g. 'TH') |
timezone | string | Shop timezone (e.g. 'Asia/Bangkok') |
sellerClass | string | Seller classification |
authorizationStatus | string | e.g. 'AUTHORIZED', 'DEAUTHORIZED' |
GET/api/shopee/fetch-all-user-shop-accounts
Fetches authorization status for each Shopee (shop, app-type) grant. A non-null deauthorizedAt means the grant is revoked/expired and needs re-auth — handy for diagnosing why a shop's orders or ads data is missing.
Response — Array of ShopeeAccountEntry
| Field | Type | Description |
|---|---|---|
shopId | integer | Shopee shop id |
appType | string | Grant type ('default' core data, 'ads' campaign data, 'ams' open campaign) |
authorizedAt | string (date) | When the grant was last authorized |
deauthorizedAt | string (date) | When it expired/was revoked (null if active) |
POST/api/shopee/shop/check-commission-rates
Compares empirical commission rates (computed from order data) against the rates declared in Shopee Seller Centre — useful for auditing when displayed and calculated rates diverge.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
shopId | integer | yes | Shopee shop id |
region | string | yes | Region code (e.g. 'TH') |
Response — ShopeeCommissionRateCheckResult
| Field | Type | Description |
|---|---|---|
declaredRate | number | Commission rate from Seller Centre (%) |
empiricalRate | number | Calculated rate from orders (%) |
sampleOrderCount | integer | Orders used in the empirical calculation |
mismatchPercent | number | Mismatch frequency (%) |
…and more — see the full schema in the OpenAPI spec.
GET/api/shopee/shop/profile
Fetches shop profile details (name, logo, description) from Shopee.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
shopId | integer | yes | Shopee shop id |
Response — ShopeeShopProfile
| Field | Type | Description |
|---|---|---|
shopName | string | Shop name |
shopLogo | string | Logo image URL |
shopDescription | string | Shop bio/description |
followCount | integer | Shop followers |
responseRate | number | Seller response rate (0–1) |
GET/api/lazada/auth/fetch-all-user-shops
Fetches all Lazada sellers (accounts) connected to your account. Call this first to discover which Lazada accounts you own — seller-scoped endpoints need the sellerId from here.
Response — Array of LazadaShop
| Field | Type | Description |
|---|---|---|
sellerId | integer | Lazada seller account id |
shopName | string | Shop/account name |
region | string | Region code (e.g. 'TH', 'VN', 'PH') |
sellerType | string | Seller type ('REGULAR', 'LAZMALL', 'SHOP') |
GET/api/tiktok/auth/fetch-all-user-shops
Fetches all TikTok Shops connected to your account. TikTok shop ids are 19-digit numbers larger than JavaScript's safe-integer max — treat them as opaque strings end-to-end.
Response — Array of TikTokShopResponse
| Field | Type | Description |
|---|---|---|
shopId | string | TikTok shop id (opaque string, not a number) |
shopName | string | Shop name |
region | string | Region code (e.g. 'TH', 'VN') |