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: `syncCustomers`

This endpoint is used to synchronize customer profiles, including their favorite items.
Endpoint: POST /v1/syncCustomers

Request Payload#

KeyTypeDescription
commandstringThe action to perform: "create" or "update".
infoobjectThe full Customer data object, including favorite_item_ids.
Sample Request Body (Updating customer with enhanced addresses)#
{
  "customers": [
    {
      "command": "update",
      "info": {
        "id": "cus_a1b2c3d4",
        "full_name": "Fatima Al-Fahad",
        "phone_number": "+966551234567",
        "email": "fatima.alfahad@example.com",
        "saved_addresses": [
          {
            "tag": "Home",
            "house_number": "123",
            "building_name": "Al-Fahad Tower",
            "street": "Olaya Street",
            "area": "Olaya",
            "city": "Riyadh",
            "postal_code": "12345",
            "country": "SA",
            "location": { "latitude": 24.7136, "longitude": 46.6753 }
          }
        ],
        "favorite_merchant_ids": ["mer_riyadh_burger_house", "mer_new_coffee_shop"],
        "favorite_item_ids": [
           "item_rbh_classic_burger",
           "item_almarai_milk_1l",
           "item_saudi_dates_500g"
        ],
        "is_active": true,
        "updated_at": "2025-10-17T16:25:00Z"
      }
    }
  ]
}

Response Payload#

Reports only on failed operations.
Sample Error Response#
{
  "status": "partial_failure",
  "errors": [
    {
      "id": "cus_a1b2c3d4", // Corresponds to the ID sent in the request's info object
      "error": {
        "code": "INVALID_DATA",
        "message": "One or more favorite_item_ids are invalid."
      }
    }
    // Succeeded customer updates are not listed
  ]
}
Previous
API: `syncInventory`
Next
API: `syncOrders`
Built with