Sanal AI
  1. Data Structures
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. Data Structures

๐Ÿงพ Orders

This object represents a single transaction. It is an immutable historical record of a purchase, capturing details at the time the order was placed.

Fields#

NameTypeDescription
idstringUnique identifier for the order (e.g., ord_...).
customer_idstringID of the Customer.
merchant_idstringID of the Merchant.
order_numberstringCustomer-facing, human-readable order number (e.g., Sanal-10026).
ordered_itemsarrayList of items purchased. See structure below.
subtotalnumberTotal cost of ordered_items before fees/taxes.
delivery_feenumberCharge for delivery.
taxesnumberTotal tax charged.
total_amountnumberFinal grand total (subtotal + delivery_fee + taxes).
currencystringCurrency of the transaction (e.g., "SAR", "AED"). Based on merchant's country.
statusstringCurrent status (e.g., pending_confirmation, delivered, cancelled).
delivery_addressobjectThe delivery address used for this specific order, including coordinates, instructions, and recipient details. See structure below.
payment_methodstringPayment method used (e.g., "credit_card", "apple_pay").
payment_statusstringStatus of the payment (e.g., paid, pending, failed).
updated_atstringTimestamp of the last status change (ISO 8601 UTC).

Structure of delivery_address Object#

Enhanced delivery address with location coordinates, delivery instructions, and recipient information.
NameTypeDescription
tagstringUser-defined label for the address (e.g., "Home", "Office").
house_numberstringHouse/building number (e.g., "123", "45A").
building_namestringOptional. Name of the building (e.g., "Al-Fahad Tower").
streetstringStreet name without house number (e.g., "Olaya Street").
areastringOptional. Area/neighborhood name (e.g., "Olaya").
citystringCity name.
postal_codestringOptional. Postal/ZIP code.
countrystringCountry code (ISO 3166-1 alpha-2).
locationobjectPrecise geographic coordinates (latitude, longitude).
delivery_instructionsstringOptional. Special instructions for delivery (e.g., "Ring doorbell twice", "Leave at front door").
recipient_namestringOptional. Name of the person to deliver to.
recipient_phonestringOptional. Phone number of the recipient for delivery coordination.

Structure of ordered_items Object#

Each object captures the state of a purchased item, including the specific variant SKU chosen and any selected modifiers.
NameTypeDescription
product_idstringID of the Product (merchant's offer) purchased.
item_idstringID of the global Item.
variant_combination_skustringOptional. The unique SKU from Product.variant_combinations representing the specific variant chosen. null if the base product was ordered.
purchase_product_namestringThe product/variant name at time of purchase.
purchase_unit_pricenumberThe final unit price for the chosen variant combination (before modifiers).
quantityintegerNumber of units ordered.
selected_modifiersarrayOptional. The list of chosen modifiers (id, name, purchase_price).

Sample JSON#

Simple Retail Order Example#
{
  "id": "ord_retail_xyz",
  "customer_id": "cus_a1b2c3d4",
  "merchant_id": "mer_tamimi_riyadh",
  "order_number": "Sanal-10027",
  "ordered_items": [
    {
      "product_id": "prod_tm_55667",
      "item_id": "item_almarai_milk_1l",
      "variant_combination_sku": null,
      "purchase_product_name": "Fresh Full Fat Milk - 1L",
      "purchase_unit_price": 5.75,
      "quantity": 2,
      "selected_modifiers": []
    },
    {
      "product_id": "prod_tm_banana",
      "item_id": "item_banana_each",
      "variant_combination_sku": null,
      "purchase_product_name": "Banana (Single)",
      "purchase_unit_price": 1.50,
      "quantity": 5,
      "selected_modifiers": []
    }
  ],
  "subtotal": 19.00,
  "delivery_fee": 10.00,
  "taxes": 2.85,
  "total_amount": 31.85,
  "currency": "SAR",
  "status": "delivered",
  "delivery_address": { 
    "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 },
    "delivery_instructions": "Ring the doorbell twice, leave at front door if no answer",
    "recipient_name": "Fatima Al-Fahad",
    "recipient_phone": "+966551234567"
  },
  "payment_method": "apple_pay",
  "payment_status": "paid",
  "updated_at": "2025-10-17T15:00:00Z"
}
Complex Restaurant Order Example (Burger with Variant and Modifier)#
{
  "id": "ord_resto_abc",
  "customer_id": "cus_b5e6f7g8",
  "merchant_id": "mer_riyadh_burger_house",
  "order_number": "Sanal-10028",
  "ordered_items": [
    {
      "product_id": "prod_rbh_classic_burger",
      "item_id": "item_rbh_classic_burger",
      "variant_combination_sku": "RBH-CLASSIC-D", // User chose the Double Patty variant
      "purchase_product_name": "Classic Riyadh Burger - Double Patty", // Name reflects variant
      "purchase_unit_price": 42.00, // Price from the variant combination
      "quantity": 1,
      "selected_modifiers": [ // User added Extra Cheese
        { "id": "mod_cheese", "name": "Extra Cheese", "purchase_price": 3.00 }
      ]
    }
    // ... potentially other items like drinks
  ],
  "subtotal": 45.00, // (42.00 + 3.00)
  "delivery_fee": 12.00,
  "taxes": 6.75,
  "total_amount": 63.75,
  "currency": "SAR",
  "status": "delivered",
  "delivery_address": { 
    "tag": "Office", 
    "house_number": "456",
    "building_name": "King Abdullah Financial District",
    "street": "KAFD", 
    "area": "KAFD",
    "city": "Riyadh",
    "postal_code": "13519",
    "country": "SA",
    "location": { "latitude": 24.7625, "longitude": 46.6418 },
    "delivery_instructions": "Call when you arrive, security will let you in",
    "recipient_name": "Ahmed Al-Rashid",
    "recipient_phone": "+966501234567"
  },
  "payment_method": "credit_card",
  "payment_status": "paid",
  "updated_at": "2025-10-17T15:30:00Z"
}
Previous
๐Ÿ‘ค Customers
Next
๐Ÿงพ Variants & Combinations
Built with