{
  "openapi": "3.1.0",
  "info": {
    "title": "MingBirXizmat Partner API",
    "version": "2026-10-21",
    "summary": "Sotuvchilar, restoranlar, logistika va korporativ mijozlar uchun API.",
    "description": "Partner API hamkorga faqat o‘z biznesi ma’lumotlari bilan ishlash imkonini beradi. Kalitlar developer konsolida yaratiladi (mbx_live_ — haqiqiy, mbx_test_ — sandbox). Barcha POST so‘rovlari Idempotency-Key sarlavhasini talab qiladi.",
    "contact": { "name": "MingBirXizmat Developer Platform", "url": "/developers.html" }
  },
  "servers": [
    { "url": "https://mingbirxizmat.uz/api/partner/v1", "description": "Production (live va test kalitlar)" },
    { "url": "/api/partner/v1", "description": "Joriy server" }
  ],
  "security": [{ "bearerAuth": [] }],
  "tags": [
    { "name": "Account", "description": "Kalit va hisob konteksti" },
    { "name": "Products", "description": "Marketplace mahsulotlari (sotuvchi)" },
    { "name": "Orders", "description": "Buyurtmalar (marketplace, logistika, taomlar)" },
    { "name": "Food", "description": "Restoran buyurtmalari" },
    { "name": "Logistics", "description": "Yuk tashish: narx va buyurtma" },
    { "name": "Analytics", "description": "Qisqa tahlil" },
    { "name": "Webhooks", "description": "Webhook endpointlari va hodisalar" },
    { "name": "Sandbox", "description": "Faqat test kalit uchun yordamchi amallar" }
  ],
  "paths": {
    "/me": {
      "get": {
        "tags": ["Account"], "operationId": "getMe", "summary": "Kalit konteksti",
        "description": "Kalit rejimi, scope’lari, tezlik chegarasi va kalit egasining biznes yaroqliligi.",
        "x-scopes": [],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiKeyContextResponse" } } } }, "401": { "$ref": "#/components/responses/Unauthorized" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/products": {
      "get": {
        "tags": ["Products"], "operationId": "listProducts", "summary": "O‘z mahsulotlari ro‘yxati",
        "x-scopes": ["catalog:read", "catalog:write"],
        "parameters": [{ "$ref": "#/components/parameters/Limit" }, { "$ref": "#/components/parameters/StartingAfter" }, { "name": "status", "in": "query", "schema": { "type": "string", "enum": ["draft", "active", "paused", "archived"] } }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductList" } } } }, "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" } }
      },
      "post": {
        "tags": ["Products"], "operationId": "createProduct", "summary": "Mahsulot yaratish",
        "description": "Live kalit: mahsulot haqiqiy katalogga moderatsiya (pending) holatida tushadi. Test kalit: faqat sandbox. Rasm — faqat panel orqali yuklangan media id (mkm_…).",
        "x-scopes": ["catalog:write"],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductInput" } } } },
        "responses": { "201": { "description": "Yaratildi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductResponse" } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "$ref": "#/components/responses/Forbidden" }, "409": { "$ref": "#/components/responses/Conflict" }, "422": { "$ref": "#/components/responses/Invalid" } }
      }
    },
    "/orders": {
      "get": {
        "tags": ["Orders"], "operationId": "listOrders", "summary": "O‘z buyurtmalari",
        "description": "Marketplace (sotuvchi yoki mijoz sifatida), logistika (mijoz) va restoran buyurtmalari. Telefon, ism va aniq manzil qaytarilmaydi.",
        "x-scopes": ["orders:read"],
        "parameters": [{ "$ref": "#/components/parameters/Limit" }, { "$ref": "#/components/parameters/StartingAfter" }, { "name": "type", "in": "query", "schema": { "type": "string", "enum": ["marketplace", "logistics", "food"] } }, { "name": "status", "in": "query", "schema": { "type": "string" } }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderList" } } } }, "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" } }
      }
    },
    "/orders/{id}": {
      "get": {
        "tags": ["Orders"], "operationId": "getOrder", "summary": "Bitta buyurtma",
        "x-scopes": ["orders:read"],
        "parameters": [{ "$ref": "#/components/parameters/Id" }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Order" }, "requestId": { "type": "string" } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } }
      }
    },
    "/orders/{id}/status": {
      "post": {
        "tags": ["Orders"], "operationId": "setOrderStatus", "summary": "Marketplace buyurtma holatini o‘zgartirish (sotuvchi)",
        "description": "API orqali faqat accepted, preparing, ready, shipped. Bekor qilish va yakunlash (zaxira/to‘lovga ta’sir qiladi) — sotuvchi panelida.",
        "x-scopes": ["orders:write"],
        "parameters": [{ "$ref": "#/components/parameters/Id" }, { "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["status"], "properties": { "status": { "type": "string", "enum": ["accepted", "preparing", "ready", "shipped"] }, "version": { "type": "integer", "description": "Optimistik qulf: joriy versiya" } } } } } },
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/MarketplaceOrder" } } } } } }, "404": { "$ref": "#/components/responses/NotFound" }, "409": { "$ref": "#/components/responses/Conflict" }, "422": { "$ref": "#/components/responses/Invalid" } }
      }
    },
    "/food/orders": {
      "get": {
        "tags": ["Food"], "operationId": "listFoodOrders", "summary": "Restoran buyurtmalari",
        "description": "Faqat kalit egasi faol a’zo bo‘lgan restoranlar. Mijoz manzili, telefoni va topshirish kodi qaytarilmaydi.",
        "x-scopes": ["orders:read"],
        "parameters": [{ "name": "restaurantId", "in": "query", "schema": { "type": "string" } }, { "name": "status", "in": "query", "schema": { "type": "string" } }, { "$ref": "#/components/parameters/Limit" }, { "$ref": "#/components/parameters/StartingAfter" }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderList" } } } }, "403": { "$ref": "#/components/responses/Forbidden" }, "404": { "$ref": "#/components/responses/NotFound" } }
      }
    },
    "/logistics/quote": {
      "post": {
        "tags": ["Logistics"], "operationId": "quoteShipment", "summary": "Yuk tashish narxi",
        "description": "Narx faqat serverda hisoblanadi; yuborilgan narx maydonlari e’tiborsiz qoldiriladi.",
        "x-scopes": ["logistics:quote"],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Shipment" } } } },
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/LogisticsQuote" } } } } } }, "422": { "$ref": "#/components/responses/Invalid" } }
      }
    },
    "/logistics/orders": {
      "post": {
        "tags": ["Logistics"], "operationId": "createLogisticsOrder", "summary": "Yuk tashish buyurtmasi",
        "description": "Kalit egasi mijoz sifatida buyurtma beradi. B2B bank o‘tkazmasi uchun company.name va company.stir (9 raqam) kerak. Test kalit — sandbox, haydovchilarga yuborilmaydi.",
        "x-scopes": ["logistics:orders"],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Shipment" } } } },
        "responses": { "201": { "description": "Yaratildi", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/LogisticsOrder" } } } } } }, "403": { "$ref": "#/components/responses/Forbidden" }, "422": { "$ref": "#/components/responses/Invalid" } }
      }
    },
    "/logistics/orders/{id}": {
      "get": {
        "tags": ["Logistics"], "operationId": "getLogisticsOrder", "summary": "Logistika buyurtmasi",
        "x-scopes": ["logistics:orders"],
        "parameters": [{ "$ref": "#/components/parameters/Id" }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/LogisticsOrder" } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } }
      }
    },
    "/logistics/orders/{id}/cancel": {
      "post": {
        "tags": ["Logistics"], "operationId": "cancelLogisticsOrder", "summary": "Logistika buyurtmasini bekor qilish",
        "x-scopes": ["logistics:orders"],
        "parameters": [{ "$ref": "#/components/parameters/Id" }, { "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": false, "content": { "application/json": { "schema": { "type": "object", "properties": { "reason": { "type": "string", "maxLength": 200 } } } } } },
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/LogisticsOrder" } } } } } }, "404": { "$ref": "#/components/responses/NotFound" }, "409": { "$ref": "#/components/responses/Conflict" } }
      }
    },
    "/analytics/summary": {
      "get": {
        "tags": ["Analytics"], "operationId": "analyticsSummary", "summary": "Buyurtmalar tahlili",
        "x-scopes": ["analytics:read"],
        "parameters": [{ "name": "days", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 90, "default": 30 } }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/AnalyticsSummary" } } } } } } }
      }
    },
    "/webhook-endpoints": {
      "get": {
        "tags": ["Webhooks"], "operationId": "listWebhookEndpoints", "summary": "Webhook endpointlari (kalit rejimida)",
        "x-scopes": ["webhooks:manage"],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/WebhookEndpoint" } } } } } } } }
      },
      "post": {
        "tags": ["Webhooks"], "operationId": "createWebhookEndpoint", "summary": "Webhook endpoint qo‘shish",
        "description": "Faqat https, 443/8443 port; xususiy/ichki IP va domenlar rad etiladi (DNS tekshiruvi bilan). Sir (whsec_…) faqat shu javobda bir marta qaytadi.",
        "x-scopes": ["webhooks:manage"],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WebhookEndpointInput" } } } },
        "responses": { "201": { "description": "Yaratildi", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "endpoint": { "$ref": "#/components/schemas/WebhookEndpoint" }, "secret": { "type": ["string", "null"], "description": "whsec_… — bir marta" }, "shownOnce": { "type": "boolean" } } } } } } } }, "422": { "$ref": "#/components/responses/Invalid" } }
      }
    },
    "/events": {
      "get": {
        "tags": ["Webhooks"], "operationId": "listEvents", "summary": "So‘nggi hodisalar (polling uchun)",
        "x-scopes": ["webhooks:manage", "orders:read"],
        "parameters": [{ "name": "type", "in": "query", "schema": { "$ref": "#/components/schemas/EventType" } }, { "$ref": "#/components/parameters/Limit" }, { "$ref": "#/components/parameters/StartingAfter" }],
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Event" } }, "meta": { "$ref": "#/components/schemas/ListMeta" } } } } } } }
      }
    },
    "/sandbox/orders": {
      "post": {
        "tags": ["Sandbox"], "operationId": "createSandboxOrder", "summary": "Namunaviy buyurtma (faqat mbx_test_)",
        "description": "Sandbox mahsulotingizdan namunaviy marketplace buyurtmasi yaratadi va test webhooklariga order.created yuboradi.",
        "x-scopes": ["orders:read", "orders:write"],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": false, "content": { "application/json": { "schema": { "type": "object", "properties": { "productId": { "type": "string" }, "quantity": { "type": "integer", "minimum": 1, "maximum": 20 } } } } } },
        "responses": { "201": { "description": "Yaratildi", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/MarketplaceOrder" } } } } } }, "403": { "$ref": "#/components/responses/Forbidden" } }
      }
    }
  },
  "webhooks": {
    "order.created": { "post": { "summary": "Yangi buyurtma", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } },
    "order.updated": { "post": { "summary": "Buyurtma holati/versiyasi o‘zgardi", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } },
    "delivery.status": { "post": { "summary": "Yetkazish holati", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } },
    "food.order.status": { "post": { "summary": "Taom buyurtmasi holati", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } },
    "product.moderated": { "post": { "summary": "Mahsulot moderatsiyadan o‘tdi yoki rad etildi", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } },
    "payout.recorded": { "post": { "summary": "To‘lov (payout) qayd etildi", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Event" } } } }, "responses": { "2XX": { "description": "Qabul qilindi" } } } }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "mbx_live_<40> | mbx_test_<40>", "description": "Developer konsolida yaratilgan API kalit. Faqat serverda saqlang." }
    },
    "parameters": {
      "IdempotencyKey": { "name": "Idempotency-Key", "in": "header", "required": true, "description": "16–128 belgi [A-Za-z0-9_:.-]. 24 soat saqlanadi; bir xil kalit + boshqa tana → 409 IDEMPOTENCY_KEY_REUSED.", "schema": { "type": "string", "pattern": "^[A-Za-z0-9_:.-]{16,128}$" } },
      "Limit": { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 } },
      "StartingAfter": { "name": "starting_after", "in": "query", "description": "Oldingi sahifaning oxirgi elementi id’si", "schema": { "type": "string" } },
      "Id": { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{6,120}$" } }
    },
    "headers": {
      "RateLimitLimit": { "schema": { "type": "integer" }, "description": "Kalit uchun daqiqalik chegara" },
      "RateLimitRemaining": { "schema": { "type": "integer" } },
      "RetryAfter": { "schema": { "type": "integer" }, "description": "Soniyalar" }
    },
    "responses": {
      "BadRequest": { "description": "Noto‘g‘ri so‘rov (masalan Idempotency-Key yo‘q)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Unauthorized": { "description": "Kalit yo‘q, noto‘g‘ri, bekor qilingan yoki muddati tugagan", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Forbidden": { "description": "Scope yo‘q, IP ruxsat etilmagan yoki biznes yaroqsiz", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "NotFound": { "description": "Topilmadi (yoki sizga tegishli emas)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Conflict": { "description": "Ziddiyat (versiya, holat o‘tishi, idempotentlik)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Invalid": { "description": "Tekshiruv xatosi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "RateLimited": { "description": "Tezlik chegarasi", "headers": { "Retry-After": { "$ref": "#/components/headers/RetryAfter" } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    },
    "schemas": {
      "Error": {
        "type": "object", "required": ["error"],
        "properties": { "error": { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "string", "examples": ["SCOPE_REQUIRED"] }, "message": { "type": "string" }, "field": { "type": "string" }, "requestId": { "type": "string" }, "docs": { "type": "string" } } } }
      },
      "ListMeta": { "type": "object", "properties": { "hasMore": { "type": "boolean" } } },
      "Scope": { "type": "string", "enum": ["orders:read", "orders:write", "catalog:read", "catalog:write", "logistics:quote", "logistics:orders", "webhooks:manage", "analytics:read"] },
      "ApiKeyContextResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "object": { "const": "api_key_context" }, "apiVersion": { "type": "string" }, "livemode": { "type": "boolean" },
              "key": { "type": "object", "properties": { "id": { "type": "string" }, "prefix": { "type": "string" }, "mode": { "type": "string", "enum": ["live", "test"] }, "scopes": { "type": "array", "items": { "$ref": "#/components/schemas/Scope" } }, "rateLimitPerMinute": { "type": "integer" }, "expiresAt": { "type": ["string", "null"], "format": "date-time" } } },
              "account": { "type": "object", "properties": { "id": { "type": "string" }, "role": { "type": "string" } } },
              "businesses": { "type": "object", "properties": { "seller": { "type": "boolean" }, "sellerStore": { "type": "boolean" }, "logistics": { "type": "boolean" }, "restaurants": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "role": { "type": "string" } } } } } }
            }
          },
          "requestId": { "type": "string" }
        }
      },
      "ProductInput": {
        "type": "object", "required": ["title", "categoryId", "priceMinor", "stockQuantity"],
        "properties": {
          "title": { "type": "string", "minLength": 3, "maxLength": 120, "description": "Havola va telefon raqam bo‘lmasin" },
          "categoryId": { "type": "string", "examples": ["c01-01"] },
          "description": { "type": "string", "maxLength": 2000 },
          "priceMinor": { "type": "integer", "minimum": 500, "description": "So‘mda (butun son)" },
          "stockQuantity": { "type": "integer", "minimum": 0, "maximum": 100000 },
          "sku": { "type": "string", "pattern": "^[A-Za-z0-9_-]{2,80}$" },
          "negotiable": { "type": "boolean" },
          "delivery": { "type": "object", "properties": { "pickup": { "type": "boolean" }, "courier": { "type": "boolean" } } },
          "weightKg": { "type": "number", "exclusiveMinimum": 0, "maximum": 500 },
          "images": { "type": "array", "maxItems": 3, "items": { "type": "string", "pattern": "^mkm_[a-f0-9]{32}$" } },
          "publish": { "type": "boolean", "description": "true — moderatsiyadan keyin darhol faol" }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "object": { "const": "product" }, "livemode": { "type": "boolean" }, "title": { "type": "string" }, "categoryId": { "type": "string" },
          "priceMinor": { "type": "integer" }, "currency": { "const": "UZS" }, "stockQuantity": { "type": "integer" }, "sku": { "type": "string" },
          "status": { "type": "string", "enum": ["draft", "active", "paused", "archived"] }, "moderation": { "type": "string", "enum": ["pending", "approved", "rejected"] },
          "moderationReason": { "type": ["string", "null"] }, "version": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }
        }
      },
      "ProductResponse": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Product" }, "requestId": { "type": "string" } } },
      "ProductList": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } }, "meta": { "$ref": "#/components/schemas/ListMeta" }, "requestId": { "type": "string" } } },
      "MarketplaceOrder": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "object": { "const": "order" }, "type": { "const": "marketplace" }, "livemode": { "type": "boolean" }, "role": { "type": "string", "enum": ["seller", "customer"] },
          "status": { "type": "string", "enum": ["created", "accepted", "preparing", "ready", "shipped", "completed", "cancelled"] }, "version": { "type": "integer" },
          "customerRef": { "type": "string", "description": "Faqat sotuvchiga: mijoz identifikatorining oxirgi 6 belgisi" },
          "items": { "type": "array", "items": { "type": "object", "properties": { "productId": { "type": "string" }, "title": { "type": "string" }, "quantity": { "type": "integer" }, "unitPriceMinor": { "type": "integer" }, "lineTotalMinor": { "type": "integer" } } } },
          "totalMinor": { "type": "integer" }, "currency": { "const": "UZS" }, "fulfillment": { "type": "string", "enum": ["pickup", "courier"] },
          "payment": { "type": "object", "properties": { "method": { "const": "cash" }, "status": { "type": "string" } } },
          "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }
        }
      },
      "FoodOrder": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "type": { "const": "food" }, "restaurantId": { "type": "string" }, "status": { "type": "string" }, "version": { "type": "integer" },
          "lines": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "qty": { "type": "integer" }, "options": { "type": "array", "items": { "type": "string" } } } } },
          "total": { "type": ["integer", "null"] }, "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "Stop": { "type": "object", "required": ["label", "lat", "lng"], "properties": { "label": { "type": "string", "minLength": 2, "maxLength": 160 }, "lat": { "type": "number" }, "lng": { "type": "number" }, "note": { "type": "string", "maxLength": 120 } } },
      "Shipment": {
        "type": "object", "required": ["vehicleType", "pickup", "dropoffs", "cargo"],
        "properties": {
          "vehicleType": { "type": "string", "enum": ["labo", "porter", "isuzu", "fura", "refrigerator", "tipper"] },
          "pickup": { "$ref": "#/components/schemas/Stop" },
          "dropoffs": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/Stop" } },
          "cargo": { "type": "object", "required": ["description", "weightKg"], "properties": { "description": { "type": "string", "minLength": 2, "maxLength": 300 }, "weightKg": { "type": "number", "exclusiveMinimum": 0, "maximum": 40000 }, "volumeM3": { "type": "number", "minimum": 0, "maximum": 120 } } },
          "loaders": { "type": "integer", "minimum": 0 },
          "schedule": { "type": "object", "properties": { "mode": { "type": "string", "enum": ["now", "scheduled"] }, "at": { "type": "string", "format": "date-time" } } },
          "payment": { "type": "object", "properties": { "method": { "type": "string", "enum": ["cash", "bank_transfer"] } } },
          "company": { "type": "object", "properties": { "name": { "type": "string" }, "stir": { "type": "string", "pattern": "^\\d{9}$" } } },
          "note": { "type": "string", "maxLength": 300 }
        }
      },
      "LogisticsQuote": {
        "type": "object",
        "properties": { "object": { "const": "logistics_quote" }, "livemode": { "type": "boolean" }, "vehicleType": { "type": "string" }, "distanceKm": { "type": "number" }, "intercity": { "type": "boolean" }, "totalSom": { "type": "integer" }, "etaMinutes": { "type": "integer" }, "pricingVersion": { "type": "string" }, "components": { "type": "object" } }
      },
      "LogisticsOrder": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "object": { "const": "order" }, "type": { "const": "logistics" }, "livemode": { "type": "boolean" },
          "status": { "type": "string", "enum": ["created", "searching", "assigned", "loading", "in_transit", "unloading", "delivered", "cancelled"] }, "version": { "type": "integer" },
          "vehicleType": { "type": "string" }, "stops": { "type": "array", "items": { "type": "object" } },
          "quote": { "type": "object", "properties": { "totalSom": { "type": "integer" }, "distanceKm": { "type": "number" }, "etaMinutes": { "type": "integer" } } },
          "driverAssigned": { "type": "boolean" }, "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "Order": { "oneOf": [{ "$ref": "#/components/schemas/MarketplaceOrder" }, { "$ref": "#/components/schemas/LogisticsOrder" }, { "$ref": "#/components/schemas/FoodOrder" }] },
      "OrderList": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Order" } }, "meta": { "$ref": "#/components/schemas/ListMeta" }, "requestId": { "type": "string" } } },
      "AnalyticsSummary": { "type": "object", "properties": { "object": { "const": "analytics_summary" }, "periodDays": { "type": "integer" }, "totalOrders": { "type": "integer" }, "byType": { "type": "object", "additionalProperties": { "type": "object", "properties": { "count": { "type": "integer" }, "byStatus": { "type": "object" }, "completedAmountMinor": { "type": "integer" } } } } } },
      "EventType": { "type": "string", "enum": ["order.created", "order.updated", "delivery.status", "food.order.status", "product.moderated", "payout.recorded", "ping"] },
      "WebhookEndpointInput": { "type": "object", "required": ["url", "events"], "properties": { "url": { "type": "string", "format": "uri", "pattern": "^https://" }, "events": { "type": "array", "items": { "oneOf": [{ "$ref": "#/components/schemas/EventType" }, { "const": "*" }] } }, "description": { "type": "string", "maxLength": 120 } } },
      "WebhookEndpoint": { "type": "object", "properties": { "id": { "type": "string" }, "url": { "type": "string" }, "mode": { "type": "string", "enum": ["live", "test"] }, "events": { "type": "array", "items": { "type": "string" } }, "status": { "type": "string", "enum": ["enabled", "disabled"] }, "secretPrefix": { "type": "string" }, "consecutiveFailures": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" } } },
      "Event": { "type": "object", "required": ["id", "type", "createdAt", "data"], "properties": { "id": { "type": "string" }, "type": { "$ref": "#/components/schemas/EventType" }, "mode": { "type": "string", "enum": ["live", "test"] }, "createdAt": { "type": "string", "format": "date-time" }, "apiVersion": { "type": "string" }, "data": { "type": "object" } } }
    }
  }
}
