Temu
Get Config
Returns server-side capability flags used by the new-instance form on the frontend.
Initialize OAuth
Starts a new Temu OAuth flow.
Complete OAuth
Exchanges the OAuth authorization code returned by Temu for an access token and creates a new `TemuIntegrationInstance` persisted with that token.
Get OAuth Status
Polled by the frontend after the OAuth popup/redirect to learn the state of the OAuth session.
Sandbox Initialize
Creates a Temu sandbox integration instance **without** going through the OAuth flow.
Reconnect Integration
Re-authorizes an existing `TemuIntegrationInstance` with a fresh OAuth access token.
Test Connection
Verifies that the stored Temu access token for a given integration instance is still valid by calling Temu's `getWarehouses` endpoint (the cheapest read with no required parameters).
Get Authorization URL
Builds and returns the Temu seller-consent URL for this integration instance. Direct the merchant to this URL to authorize (or re-authorize) the connection; after they approve access, Temu redirects back to the platform's OAuth callback which completes the token exchange.
List Orders
Paginated list of Temu orders for an integration instance, powered by Spatie QueryBuilder.
Show Order
Fetch a single Temu order with full nested detail. Eager-loads orderItems.product.productListing.product, orderItems.product.productListing.subscriptionOffering, and salesOrder.salesOrderFulfillments.
Delete Order
Permanently delete a Temu order. Verifies the order belongs to the supplied integration instance (returns 403 if not). Does not remove the Temu order on Temu's side — only deletes the local cached record.
Delete Linked SKU Order
Delete the linked SKU.io sales order while keeping the Temu order. Returns 404 if no SKU order is linked.
Get Latest Sync Info
Returns aggregate stats used by the 'Refresh from Temu' modal: total order count, count with/without a linked SKU sales order, and the latest known order (parentOrderSn, parentOrderTime, parentOrderStatus). Used by the UI to default the date range and surface sync coverage.
Refresh Orders (Tracked)
Queue a tracked background job that pulls orders from Temu. Returns a `tracked_job_log_id` for the tracked job log endpoints to subscribe to.
Create SKU Orders (Bulk)
Dispatch a tracked background job that converts the selected Temu orders into SKU.io sales orders. Returns a `tracked_job_log_id` immediately so the caller can close the modal and watch progress via the global tray.
Create Products From Order Items
Backfill TemuProduct records for any TemuOrderItem rows that reference a `goodsId` not yet present as a product. Useful when the orders endpoint ran ahead of the products sync.
Refresh Orders
Queues a background job that pulls the latest orders from Temu and upserts them into the local order list. The job runs on a serialized queue so overlapping refreshes for the same instance cannot race. The sync window starts just after the most recent stored order (or the instance's configured start date when no orders exist yet).
Refresh Single Order
Fetches one order from Temu by its parent order number, saves (or updates) it locally, and returns the stored order. Use this to re-sync a single order on demand instead of running a full refresh.
Bulk Update SKU Orders
Re-applies the latest stored Temu order data onto the linked SKU sales orders — statuses, cancellations and fulfillment-relevant changes are translated into update actions and processed per order. Orders without a linked sales order are skipped.
Archive Order
Archive a single Temu order. Returns 403 if the order does not belong to the integration instance. The `archived` flag in the response indicates whether the call actually changed state (false means it was already archived).
Unarchive Order
Unarchive a single Temu order. Returns 403 if the order does not belong to the integration instance. The `unarchived` flag is false when the order was already active.
Bulk Archive Orders
Archive multiple orders in one call. Iterates the matched rows in chunks of 100.
Bulk Unarchive Orders
Unarchive multiple orders in one call. Iterates the matched rows in chunks of 100.
Get Raw Order (from Temu API)
Live-fetch the raw Temu order payload by `parentOrderSn` directly from Temu's API (bypasses the local cache). Returns 403 if the order does not belong to the integration instance, or 500 with the underlying error message if Temu's API call fails.
Order Activity Log
Paginated activity log entries for this Temu order, sourced from Spatie ActivityLog.
List Products
Paginated list of Temu products for an integration instance. Powered by Spatie QueryBuilder with grouped advanced filters.
Show Product
Fetch a single Temu product with its mapping, integration instance, and full json_object.
Export Products
Downloads every imported Temu product listing for the integration instance as a spreadsheet file (newest first), including mapping details for listings linked to internal products. Nested values such as the raw listing payload are serialized to JSON strings within their cells.
Check Archiveable Products
Pre-validates a set of Temu products for archiving without changing anything. For each product the response says whether it can be archived and, if not, why. A product cannot be archived while it appears on imported Temu orders.
Check Deleteable Products
Pre-validates a set of Temu products for deletion without changing anything. For each product the response says whether it can be deleted; Temu products currently have no delete restrictions, so every requested product is reported as deleteable.
Bulk Archive Products
Archives the selected Temu products, hiding them from the default product list. Products that appear on imported Temu orders are silently skipped — use the archiveable check endpoint first to see which products qualify.
Bulk Unarchive Products
Restores previously archived Temu products so they appear in the default product list again.
Bulk Delete Products
Permanently deletes the selected Temu products from the local catalog. Any product-listing mappings tied to those products are removed first, so linked internal products lose their Temu listing association. The listings on Temu itself are not affected.
Refresh Products (Tracked)
Dispatches a tracked background job to pull products from Temu. Returns a tracked_job_log_id the UI uses to surface progress via the tracked job log endpoints.
Latest Sync Info
Returns totals + most-recently-updated product info for the Refresh-from-Temu modal header. Counts exclude archived rows.
Get Raw Product
Calls Temu's bg.local.goods.detail.query directly and returns the raw payload for the on-demand viewer. 403 if the product does not belong to the given integration instance; 500 if the upstream call fails.
Refresh Products
Queues a background job that pulls the product catalog from Temu and upserts the listings locally. The job runs on a serialized queue so overlapping refreshes for the same instance cannot race. Depending on the instance's auto-link and auto-create settings, newly imported listings may be linked to existing internal products by SKU or have internal products created for them automatically.
Refresh Single Product
Fetches one product directly from Temu's API, persists the updated data, and returns the refreshed listing — synchronously, without queuing a catalog-wide refresh.
Smart Match
Find SKU product matches for a Temu product. Tries exact SKU (outGoodsSn first, then skuId) and fuzzy goodsName matches. Empty body.
Map Product to SKU Product
Map a single Temu product to either a SKU product (product_id) OR a subscription offering (subscription_offering_id). Exactly one of the two is required.
Unmap Product
Removes the product_listing linking this Temu product to a SKU product/offering. Returns 422 if the product has no current mapping.
Create SKU Product
Create a new SKU product from a Temu product and immediately link it via product_listing.
Bulk Map Products
Maps Temu listings to internal products by SKU in bulk. Each mapping entry links one Temu listing (identified by its Temu goods id) to the internal product whose SKU matches `mapped_sku`. After mapping, any imported order lines that were previously unmatched are re-linked to the newly mapped products in the background.
Bulk Create SKU Products
Creates internal SKU products from Temu listings and links them, running as a queued background job. If a listing's candidate SKU already exists internally, the listing is linked to the existing product instead of creating a duplicate. Field mappings configured for the instance control how listing fields populate the new products.
Import Product Mappings
Imports listing-to-product mappings from a previously uploaded CSV file, running as a queued background job on a serialized queue. The CSV must contain a column with the Temu goods id (the listing's unique field) and a `mapped_sku` column identifying the internal product each listing maps to.
Get Orders for Product
Paginated list of Temu orders that contain this product (matched by goodsId), newest first by parentOrderTime. 403 if the product does not belong to the integration instance.
List Fulfillments
Paginated list of SalesOrderFulfillment records for the given Temu integration instance. Per-page default is 10. Supports Spatie QueryBuilder filters (filter[...]), sorts (sort=...), and grouped advanced filters (filter_groups).
Show Fulfillment
Returns a single fulfillment with lines, warehouse/carrier mapping flags, API call logs, and the warehouse/carrier display-name maps used by the UI. Returns 404 if the fulfillment does not belong to the given Temu integration instance.
Submit Fulfillment to Temu
Registered by the shared salesChannel route macro (POST /api/temu/{integrationInstance}/fulfill). Submits an existing SalesOrderFulfillment to Temu. Temu does NOT auto-generate tracking — a carrier tracking number must already be stored on the fulfillment OR be supplied here in the request body (it will be persisted).
Get Shipment Status
Fetches the current shipment/tracking status from Temu for a single child order (orderSn) belonging to a parent order (parentOrderSn). Proxies bg.logistics.shipment.get on the Temu Open Platform.
Update Shipping Type
Updates the carrier and tracking number for a shipment that has already been submitted. Used when the original carrier doesn't pick up the package within 48 hours and the seller needs to switch carriers without recreating the shipment.
Get Unshipped Packages
Returns the list of child orders (packages) within a parent order that have not yet been confirmed as shipped on Temu. Used to drive the partial-shipment / multi-package UI.
Confirm Shipped Package
Confirms one or more packages within a parent order as shipped on Temu, supplying the carrier tracking number for each child order. Required because Temu does NOT auto-generate tracking — sellers must supply tracking for every package before Temu treats the parent order as shipped.
Get Fulfillment Stats
Returns lightweight fulfillment counters for the integration instance:
Get Fulfillment Preflight Result
Validates a stored fulfillment against Temu's shipment-confirmation requirements before submission. Temu requires three values per package — a mapped carrier, a mapped warehouse, and a tracking number — all of which must be configured on the platform side. This endpoint reports exactly which requirements are unmet so submission failures can be prevented up front.
Preview Fulfillment Preflight
Runs the same Temu shipment-confirmation checks as the stored-fulfillment preflight, but against raw input values instead of a persisted fulfillment. Use this to validate a fulfillment while it is still being composed, before anything is saved.
List Warehouses
Paginated list of TemuWarehouse records for the given integration instance. Includes the mapped local Warehouse (when set) via the `warehouse` relation. Per-page default is 15.
Download Warehouses (Sync from Temu)
Synchronously dispatches a background job against the Temu Open API to refresh the TemuWarehouse cache for this integration instance. Returns the refreshed list of Temu warehouses along with the local inventory warehouses configured on the instance for the mapping UI.
Map Warehouse to Local Warehouse
Sets `local_warehouse_id` on the TemuWarehouse record so fulfillments routed to this Temu warehouse pull stock from the chosen local Warehouse.
Check Mapping by Local Warehouse
Reverse lookup — given a local Warehouse ID, returns the TemuWarehouse it is mapped to (if any). Used by the fulfillment UI to warn users before submission when a local warehouse has no Temu mapping.
List Carriers
Paginated list of TemuCarrier records for the given integration instance. Includes the mapped local ShippingMethod (when set) via the `shipping_method` relation. Per-page default is 15.
Download Carriers (Sync from Temu)
Synchronously dispatches a background job against the Temu Open API to refresh the TemuCarrier cache for the requested region (default US=211). When `region_id=all`, dispatches once per supported region. Returns the refreshed list of TemuCarrier records together with the regions that were downloaded.
Map Carrier to Shipping Method
Sets `local_shipping_method_id` on the TemuCarrier record so that submitting a fulfillment with the chosen shipping method routes to this Temu carrier (logisticsServiceProviderId).
Check Mapping by Shipping Method
Reverse lookup — given a local ShippingMethod ID, returns the TemuCarrier it is mapped to (if any). Used by the fulfillment UI to warn users before submission when a shipping method has no Temu carrier mapping.
Get Available Fields
Returns the catalog of available Temu product fields (grouped by Basic Info, Pricing & Inventory, Dimensions & Weight) and SKU.io product fields available for mapping. Powers the field-mapping configuration UI dropdowns.
Get Field Mappings
Returns the saved listing field-mapping configuration for this Temu integration instance. Each entry pairs a Temu field (`listing_field`) with a SKU.io field (`sku_field`) and may include optional parsers that transform the value during import.
Update Field Mappings
Persist the listing field-mapping configuration for this Temu integration instance (model = `listings` in `integration_field_mappings`). Replaces the existing mapping for the instance.
List Inventory (Comparison)
Paginated inventory comparison — one row per SKU x Temu warehouse from sales_channel_product_inventory_caches. Joins productListing -> salesChannelProduct/product/subscriptionOffering and resolves the Temu warehouse name via temu_warehouses.warehouseId. Default per_page is 10; default sort is -id. Restricted to warehouses belonging to this integration instance. Supports Spatie QueryBuilder filters (filter[...]), sorts (sort=...), and grouped advanced filters (filter_groups).
Inventory Summary
Aggregate inventory statistics for the integration: total rows, in-sync count, variance count, needs-recalc count, plus the latest fetch and sync timestamps across all cached rows for Temu warehouses owned by this integration. Returns zeros and null timestamps when no warehouses are mapped.
List Locations
Returns every Temu warehouse for this integration instance — used to populate the location filter in the inventory UI. `id` is the external Temu warehouseId (also the value used in filter[location_id]), `is_active` reflects the warehouse's defaultWarehouse flag.
Recache Inventory (Recompute SKU.io Quantities)
Queues a background job, which (1) rebuilds `integration_settings.inventory.locations` from temu_warehouses (preserving user-edited masterOfStock and inventoryModificationRules) and (2) recomputes the `sku_quantity` column on every sales_channel_product_inventory_caches row for this integration. Request body is empty. Returns the tracked_job_log_id used to poll progress via the recache-progress endpoint or the tracked job log endpoints.
Recache Progress
Polls the TrackedJobLog row produced by Recache Inventory. Returns 404 if no log exists for the supplied id. The frontend tracked job log endpoints reads `progress_percentage`, `status`, `processed_items` / `total_items` and `messages`.
Sync Inventory to Temu (Push)
Queues a background job which pushes the cached SKU.io `sku_quantity` values up to Temu via the Temu inventory API. Request body is empty. Returns the tracked_job_log_id used to poll progress via the sync-progress endpoint or the tracked job log endpoints.
Sync Progress
Polls the TrackedJobLog row produced by Sync Inventory to Temu. Returns 404 if no log exists for the supplied id. When the job is complete, `results` includes per-item push outcomes (successes, failures with messages).
Sync Inventory to Temu
Computes the current sellable stock for mapped Temu listings and pushes the quantities to Temu synchronously. Listings whose cached quantities are stale are recalculated first, then the updated numbers are submitted to Temu's inventory API and the local sync cache is refreshed.
List Webhook Configurations
Returns every supported event code with its current local subscription state (`is_enabled`, `subscribed_at`). Drives the Configuration tab in the settings UI.
Enable All Webhook Subscriptions
Dispatches a background job to subscribe the shop to every event code in TemuEventCodeEnum. Runs through the Tracked Job pattern — frontend should call `notifyJobStarted` and watch the tracked job log endpoints for completion. Response includes the `tracked_job_log_id`.
Enable Webhook Subscription
Subscribes the shop to a single event code via `bg.tmc.message.update`. Idempotent — returns success even if already enabled. Returns 500 if Temu rejects the subscription or the event code is invalid.
Disable Webhook Subscription
Unsubscribes the shop from a single event code via `bg.tmc.message.update` (cancel list), then deletes the local `temu_webhooks` row. Idempotent — succeeds even if already disabled. If Temu reports the subscription is already gone (error code 110020009 / 'not found') it is treated as success.
List Webhook Events
Paginated list of webhook events for the given integration instance. Uses Spatie QueryBuilder with shared `getWebhookEventAllowedFilters` (text/numeric/datetime filters + AdvancedSearch) and supports grouped advanced filters via `filter_groups`. Default sort is `-created_at`, default per_page is 10. Returns Temu webhook event object payloads (truncates `processing_error` to 200 chars + ellipsis).
Get Processing Stats
Aggregate counts by processing_status for the given integration instance. Drives the summary cards above the events table.
Process Pending Events
Processes pending webhook events for the instance. Both body fields are optional:
Retry Failed Events
Resets failed events (where `processing_attempts < 3`) back to pending then processes them again.
Get Event Details
Full event payload including `json_data` (the raw decoded TMC message), `processing_error` (full text, not truncated), and timing metadata. Backs the event detail drawer.
Process Event By Id
Processes a single webhook event by id. No-op if the event is already in the processed state (returns success with `event already processed` message). Does NOT reset state — use `/reprocess` to force a re-run on a processed event.
Reprocess Event By Id
Forces a re-run of the event even if previously processed — resets the row to pending (clearing `processing_error`) and processes it again. Used by the 'Reprocess' action in the per-row menu.
Bulk Reprocess Events
Resets each event in `event_ids` to pending and processes it again.
Bulk Delete Events
Deletes the given webhook events. Requires `confirmation: 'YES'`.
Delete All Events (per instance)
Hard-deletes every webhook event row for the given integration instance. Requires `confirmation: 'YES'`. Returns the total `deleted_count`. Use with caution — there is no soft-delete on `temu_webhook_events`.
List Parent After-Sales
Paginated list of TemuParentAfterSale records (returns + refunds) for the given Temu integration instance. Per-page default is 15. Uses Spatie QueryBuilder with grouped filter support — `filter[...]`, `sort=...`, and grouped advanced filters via `filter_groups` are all accepted. Default sort is `-updateTime`.
Refresh Parent After-Sales
Dispatches a background job to pull recent after-sales (returns/refunds) from the Temu API and upsert them into temu_parent_after_sales. Returns immediately with a tracked_job_log_id so the frontend can poll the job-tray composable. Body: { days_updated?: int } — defaults to 30 days when omitted.
Query Pre-Start-Date Orders
Paginates through the Temu API (up to 10 pages of 100) for orders updated/created in the requested window, filters down to orders whose parentOrderTime is strictly before the configured inventory_start_date, and decorates each candidate with eligibility flags (eligible, already_imported, ineligible_reason). Returns 422 via the FormRequest if inventory_start_date is not set or if the date range is not strictly before it.
Search Pre-Start-Date Order
Calls the Temu order detail endpoint for a single parent_order_sn, filters out any result whose parentOrderTime is on/after the inventory_start_date, and decorates the result with eligibility flags. Empty `data` if the order is not found, not pre-start-date, or the upstream call errors. Returns 422 if inventory_start_date is not configured.
Import Pre-Start-Date Orders
Import selected pre-start-date orders from Temu by their parent order SNs. Each order is fetched from the Temu API and written so it shows up in the local order list, flagged as a pre-start-date import.
List Integration Instances
Lists every Temu integration instance on the account. Returns all instances in a single response with no pagination, so callers can populate pickers or iterate instances without paging.
Create Integration Instance
Creates a Temu integration instance directly from the supplied settings and credentials, and creates the linked sales channel record in the same transaction. Most production connections are established through the OAuth flow instead (`POST /api/temu/oauth/initialize` followed by `POST /api/temu/oauth/complete`), which populates the connection credentials automatically — use this endpoint when you already hold valid credentials.
Get Integration Instance
Returns a single Temu integration instance with its linked sales channel and store, effective settings, and the warehouse/carrier mapping indicators.
Update Integration Instance
Updates a Temu integration instance. All body fields are optional — only supply the fields you want to change.
Delete Integration Instance
Deletes a Temu integration instance. The deletion runs as a queued background job because it cascades widely: the instance's imported orders and products, webhook subscriptions and stored webhook events, API logs, saved import mappings, and the linked sales channel are all removed.
List Activity Log Entries
Returns the paginated change history recorded against a Temu integration instance, newest first. Each entry describes one recorded event (for example a settings update) with its structured `properties` payload and the name of the user who caused it (null for system-initiated changes).