Sanal AI
  1. API Requirements
Sanal AI
  • Introduction
    • ๐Ÿš€ Sanal AI - Encore Data
    • ๐Ÿ› ๏ธ Getting Started
    • ๐Ÿค The Approach / Model
  • Data Structures
    • ๐Ÿ“ Data Layout
    • ๐Ÿช Merchants
    • ๐Ÿ“‚ Categories
    • ๐Ÿท๏ธ Items
    • ๐Ÿ›’ Products
    • ๐Ÿ“ฆ Inventory
    • ๐Ÿ‘ค Customers
    • ๐Ÿงพ Orders
    • ๐Ÿงพ Variants & Combinations
  • API Requirements
    • ๐Ÿ”Œ API Requirements
    • API: `syncMerchants`
    • API: `syncCategories`
    • API: `syncItems`
    • API: `syncProducts`
    • API: `syncInventory`
    • API: `syncCustomers`
    • API: `syncOrders`
  1. API Requirements

API: `syncInventory`

This high-frequency endpoint is used to synchronize real-time stock levels, using the specific SKU from Product.variant_combinations or the modifier_id.
Endpoint: POST /v1/syncInventory

Request Payload#

KeyTypeDescription
commandstringThe action to perform: "update".
infoobjectThe full Inventory data object, including variant_combination_sku or modifier_id as applicable.

Sample Request Body#

This example shows updating the stock for a specific T-shirt variant (TSHIRT-L-RD) and simultaneously marking a modifier (mod_gift_wrap) as unavailable for another product.
{
  "inventory": [
    {
      "command": "update",
      "info": {
        "id": "inv_TSHIRT-L-RD", // Assumes an ID exists or can be derived
        "product_id": "prod_retail_tshirt",
        "variant_combination_sku": "TSHIRT-L-RD", // Target specific variant combo
        "modifier_id": null,
        "quantity": 15,
        "is_in_stock": true,
        "updated_at": "2025-10-18T20:00:00Z"
      }
    },
    {
       "command": "update",
       "info": {
        "id": "inv_other_prod_mod_giftwrap", // Assumes an ID exists
        "product_id": "prod_some_other_product", // ID of product with gift wrap
        "variant_combination_sku": null, // Modifier applies regardless of variant
        "modifier_id": "mod_gift_wrap", // Target specific modifier
        "quantity": null,
        "is_in_stock": false, // Mark as unavailable
        "updated_at": "2025-10-18T20:01:00Z"
       }
    }
  ]
}

Response Payload#

Reports only on failed operations.
Sample Error Response#
{
  "status": "partial_failure",
  "errors": [
    {
      "id": "inv_TSHIRT-L-RD", // Corresponds to the ID sent in the request's info object
      "error": {
        "code": "INVALID_SKU",
        "message": "variant_combination_sku 'TSHIRT-L-RD' does not exist for product_id 'prod_retail_tshirt'."
      }
    }
    // Succeeded operations are not listed
  ]
}

Previous
API: `syncProducts`
Next
API: `syncCustomers`
Built with