{
  "openapi": "3.0.3",
  "info": {
    "title": "Origela Store API",
    "version": "v1",
    "description": "Read products, stock, orders, customers and shipment tracking of an Origela store, and write five things back: stock quantities, prices, new products (always as drafts), the shipment of an order, and the document number another program keeps for an order.\n\nRules that hold for every request:\n- HTTPS only. A key sent over plain HTTP is revoked.\n- Authentication: `Authorization: Bearer <key>` (or `X-Api-Key: <key>`). Never put the key in the address.\n- The API is switched on per store by its owner and works only while the store's licence is active.\n- Answers are JSON. Text values are raw (not HTML-escaped): escape them yourself before you show them.\n- Amounts are decimal text (\"149.90\") and always come with a currency. Dates are ISO 8601 in UTC.\n- Lists are paged by `limit` and `cursor`; there is no total count. To follow changes, poll with `updated_since` and overlap your last poll by a few minutes.\n- Unknown query parameters and unknown body members are refused (422).\n- Every write needs an `Idempotency-Key` header (16 to 64 characters of A-Z a-z 0-9 _ -). Repeating a request with the same key returns the recorded answer and changes nothing twice.\n- Limits per key: 120 requests a minute, 20 a minute for answers with personal data, 30 writes a minute. Over the limit: 429 with `Retry-After`."
  },
  "servers": [
    {
      "url": "https://{store}/api",
      "description": "Your store. If the server does not rewrite addresses, use https://{store}/api/index.php?r=/v1/... instead.",
      "variables": { "store": { "default": "example.com", "description": "Domain (and folder, if any) of the store" } }
    }
  ],
  "security": [ { "bearerKey": [] } ],
  "tags": [
    { "name": "Store" }, { "name": "Products" }, { "name": "Stock" }, { "name": "Orders" }, { "name": "Shipping" }, { "name": "Customers" }
  ],
  "paths": {
    "/v1/store": {
      "get": {
        "tags": ["Store"], "operationId": "getStore", "summary": "The store this key belongs to",
        "description": "Any key may call this. Use it to check that you are connected to the right store. Software version and licence end date need the scope `store:read`.",
        "x-scope": null,
        "responses": {
          "200": { "description": "Store", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Store" } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/products": {
      "get": {
        "tags": ["Products"], "operationId": "listProducts", "summary": "List products", "x-scope": "products:read",
        "description": "Products with their variants. Products in the recycle bin are never returned; drafts only with `status=draft`. Cost prices are never included.",
        "parameters": [
          { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/cursor" }, { "$ref": "#/components/parameters/updated_since" },
          { "name": "status", "in": "query", "schema": { "type": "string", "enum": ["active", "inactive", "draft", "archived"] } },
          { "name": "sku", "in": "query", "description": "Exact stock code of the product or of one of its variants", "schema": { "type": "string", "maxLength": 100 } }
        ],
        "responses": {
          "200": { "description": "Page of products", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } }, "next_cursor": { "type": "string", "nullable": true } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      },
      "post": {
        "tags": ["Products"], "operationId": "createProduct", "summary": "Create a product (draft)", "x-scope": "products:write",
        "description": "Creates ONE simple product without images or variants. It is always saved as a draft: it is not visible in the store, the sitemap, the feeds or the search until the owner publishes it in the admin panel. The API cannot publish, change or delete a product. `currency` must be the store's currency (`GET /v1/store`). Amounts are decimal text with exactly two decimals; JSON numbers are refused. Text is plain: no `<` or `>`, no control or invisible characters, no blank at either end; line breaks only in `short_description`. `stock: null` means the quantity is not tracked. The stock code must not exist on any product (recycle bin included) or variant: 409 `sku_exists`. The product limit of the store's plan applies: 409 `product_limit`. At most 500 products a day per key: 429 `daily_limit`. A `category_id` or `brand_id` that does not exist, and a `gtin` another product already carries, are refused with 422. The answer is the product as `GET /v1/products/{id}?status=draft` returns it.",
        "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductCreate" },
          "example": { "name": "PLA filament 1 kg, red", "sku": "PLA-1KG-RED", "currency": "TRY", "price": "649.90", "sale_price": "599.90", "stock": 25, "tax_rate": "20.00", "weight_kg": "1.200", "category_id": 3 } } } },
        "responses": {
          "201": { "description": "Created as a draft", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Product" } } } } } },
          "400": { "$ref": "#/components/responses/Error" }, "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" },
          "409": { "description": "`sku_exists`, `product_limit`, `idempotency_conflict` or `request_in_progress`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "413": { "$ref": "#/components/responses/Error" }, "415": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/prices": {
      "patch": {
        "tags": ["Products"], "operationId": "updatePrices", "summary": "Write prices", "x-scope": "prices:write",
        "description": "Sets the price and / or the sale price of up to 100 stock codes, in the store's own currency only (`currency` is required and must equal `GET /v1/store` → `currency`). Hand-set prices of other currencies are not changed; a changed row lists them in `currency_overrides`. Amounts are decimal text with exactly two decimals (`0.01` to `9999999.99`); JSON numbers are refused. Each row needs `price`, `sale_price` or both; a member that is left out stays as it is. `sale_price: null` removes the sale price. A sale price must be lower than the price the row ends up with, otherwise the row is refused (`sale_not_lower`); this also holds when only `price` is sent and the stored sale price would no longer be lower, and for variants that follow the product's price. A variant without a price of its own follows its product: writing a price gives it its own, `price: null` makes it follow again (`not_a_variant` on a product). With `expected_price` a row is refused (`expected_mismatch`) when the store's price is no longer that value; for a variant that follows its product this is the product's price. Guard against runaway changes: the price a unit sells at (its sale price when it has one, else its price) may not leave the range of one tenth to ten times the price it sold at before the first change made through the API within the last 24 hours (`change_too_large`); such a change has to be made in the admin panel. Rows that change nothing are reported as `unchanged`. Mode `all` (default): one refused row and nothing is changed (409 `price_rejected` with the result of every row). Mode `partial`: good rows are applied. Refusals `expected_mismatch`, `sale_not_lower` and `change_too_large` report the store's current figures. Drafts and inactive products can be written; products in the recycle bin cannot. Every change is listed in the history of the store's price manager, where the owner can undo it. At most 20,000 rows a day per key: 429 `daily_limit`.",
        "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PriceUpdate" },
          "example": { "currency": "TRY", "items": [ { "sku": "A-100", "price": "149.90", "sale_price": "129.90", "expected_price": "139.90" }, { "sku": "A-200-RED", "sale_price": null } ] } } } },
        "responses": {
          "200": { "description": "Applied", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/PriceResult" } } } } } },
          "400": { "$ref": "#/components/responses/Error" }, "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" },
          "409": { "description": "`price_rejected` (nothing changed; see `results`), `idempotency_conflict` or `request_in_progress`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PriceRejected" } } } },
          "413": { "$ref": "#/components/responses/Error" }, "415": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/products/{id}": {
      "get": {
        "tags": ["Products"], "operationId": "getProduct", "summary": "One product", "x-scope": "products:read",
        "parameters": [
          { "$ref": "#/components/parameters/id" },
          { "name": "status", "in": "query", "description": "A draft is returned only with status=draft", "schema": { "type": "string", "enum": ["draft"] } }
        ],
        "responses": {
          "200": { "description": "Product", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Product" } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/stock": {
      "get": {
        "tags": ["Stock"], "operationId": "listStock", "summary": "Stock quantities", "x-scope": "stock:read",
        "description": "One row per unit that can be counted: the product itself and each of its variants. When variants keep their own quantity the product row is left out (it is only their sum). `stock: null` means the quantity is not tracked (a variant then follows its product). `updated_since` follows any change of the row, so a row may come back although its quantity did not change; it never misses a change.",
        "parameters": [
          { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/cursor" }, { "$ref": "#/components/parameters/updated_since" },
          { "name": "sku", "in": "query", "schema": { "type": "string", "maxLength": 100 } }
        ],
        "responses": {
          "200": { "description": "Page of stock rows (paged by product)", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/StockRow" } }, "next_cursor": { "type": "string", "nullable": true } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      },
      "patch": {
        "tags": ["Stock"], "operationId": "updateStock", "summary": "Write stock quantities", "x-scope": "stock:write",
        "description": "Sets (`quantity`) or adjusts (`delta`) the quantity of up to 100 stock codes. Nothing else of a product can be changed. With `expected` a row is refused when the store's figure is no longer the one you counted from, so a sale in between is not overwritten. Mode `all` (default): one refused row and nothing is changed (409 `stock_rejected` with the result of every row). Mode `partial`: good rows are applied. Refusal reasons: `unknown_sku`, `ambiguous_sku`, `duplicate_sku`, `has_variants` (write the variants instead), `not_tracked`, `expected_mismatch`, `insufficient`, `too_large`. Refusals `expected_mismatch`, `insufficient` and `too_large` report the store's current figure. Drafts and inactive variants can be written; products in the recycle bin cannot.",
        "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StockUpdate" },
          "example": { "items": [ { "sku": "A-100", "quantity": 12, "expected": 15 }, { "sku": "A-200-RED", "delta": -3 } ] } } } },
        "responses": {
          "200": { "description": "Applied", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/StockResult" } } } } } },
          "400": { "$ref": "#/components/responses/Error" }, "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" },
          "409": { "description": "`stock_rejected` (nothing changed; see `results`), `idempotency_conflict` or `request_in_progress`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StockRejected" } } } },
          "413": { "$ref": "#/components/responses/Error" }, "415": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/orders": {
      "get": {
        "tags": ["Orders"], "operationId": "listOrders", "summary": "List orders", "x-scope": "orders:read",
        "description": "With `orders:read` alone an order carries amounts, lines, statuses, city and country: no personal data. `orders:billing` adds names, addresses, company and tax fields. `customers:read` adds `customer_id`, `customers:contact` adds e-mail and phone. Never returned: payment provider references, internal notes, cost.",
        "parameters": [
          { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/cursor" }, { "$ref": "#/components/parameters/updated_since" },
          { "name": "created_since", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "status", "in": "query", "description": "awaiting_payment, payment_failed, pending, on_hold, processing, shipped, delivered, completed, cancelled, refunded", "schema": { "type": "string" } },
          { "name": "payment_status", "in": "query", "schema": { "type": "string", "enum": ["pending", "paid", "failed", "refunded", "partially_refunded"] } }
        ],
        "responses": {
          "200": { "description": "Page of orders", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Order" } }, "next_cursor": { "type": "string", "nullable": true } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/orders/{id}": {
      "get": {
        "tags": ["Orders"], "operationId": "getOrder", "summary": "One order", "x-scope": "orders:read",
        "parameters": [ { "$ref": "#/components/parameters/id" } ],
        "responses": {
          "200": { "description": "Order", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Order" } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/orders/{id}/tracking": {
      "get": {
        "tags": ["Orders"], "operationId": "getOrderTracking", "summary": "Shipment tracking of an order", "x-scope": "orders:read",
        "parameters": [ { "$ref": "#/components/parameters/id" } ],
        "responses": {
          "200": { "description": "Tracking", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Tracking" } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/orders/{id}/shipment": {
      "post": {
        "tags": ["Orders"], "operationId": "shipOrder", "summary": "Mark an order as shipped", "x-scope": "orders:shipment",
        "description": "Writes carrier and tracking number and sets the order to `shipped`. Works once, and only for an order that is being prepared (`processing`) and whose payment is in (`paid` or `partially_refunded`) or is collected at the door (cash on delivery: payment method `cash_on_delivery` with payment status `pending`); otherwise 409 `order_not_shippable`. No other status can be changed through the API. The carrier must be one of the store's active carriers (see `/v1/shipping/carriers`). The customer gets the store's \"shipped\" e-mail unless `notify_customer` is false or the key is set not to notify. A key can ship at most 500 orders a day.",
        "parameters": [ { "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/IdempotencyKey" } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShipmentRequest" },
          "example": { "carrier_code": "yurtici", "tracking_number": "1234567890" } } } },
        "responses": {
          "200": { "description": "Shipped", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/ShipmentResult" } } } } } },
          "400": { "$ref": "#/components/responses/Error" }, "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" },
          "409": { "$ref": "#/components/responses/Error" }, "413": { "$ref": "#/components/responses/Error" }, "415": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/orders/{id}/reference": {
      "put": {
        "tags": ["Orders"], "operationId": "putOrderReference", "summary": "Write the document number of another program", "x-scope": "orders:reference",
        "description": "Notes the number your program keeps for this order, for example the invoice number of the accounting program. One reference per order and program name; sending it again replaces it. At most 5 programs per order. Plain text only. Changes nothing else of the order. The references come back in `references` of the order.",
        "parameters": [ { "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/IdempotencyKey" } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReferenceRequest" },
          "example": { "system": "Accounting", "number": "INV-2026-000123", "date": "2026-12-01" } } } },
        "responses": {
          "200": { "description": "Stored", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/ReferenceResult" } } } } } },
          "400": { "$ref": "#/components/responses/Error" }, "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" },
          "409": { "$ref": "#/components/responses/Error" }, "413": { "$ref": "#/components/responses/Error" }, "415": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/shipping/carriers": {
      "get": {
        "tags": ["Shipping"], "operationId": "listCarriers", "summary": "Active shipping carriers", "x-scope": "shipping:read",
        "responses": {
          "200": { "description": "Carriers", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Carrier" } }, "next_cursor": { "type": "string", "nullable": true } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/customers": {
      "get": {
        "tags": ["Customers"], "operationId": "listCustomers", "summary": "List customers", "x-scope": "customers:read",
        "description": "Personal data. `customers:read`: id, name, e-mail, language, status, dates. `customers:contact` adds phone, marketing consent and addresses. Customers cannot be searched by e-mail or any other personal value. Limit: 20 requests a minute.",
        "parameters": [ { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/cursor" }, { "$ref": "#/components/parameters/updated_since" } ],
        "responses": {
          "200": { "description": "Page of customers", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Customer" } }, "next_cursor": { "type": "string", "nullable": true } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "422": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/v1/customers/{id}": {
      "get": {
        "tags": ["Customers"], "operationId": "getCustomer", "summary": "One customer", "x-scope": "customers:read",
        "parameters": [ { "$ref": "#/components/parameters/id" } ],
        "responses": {
          "200": { "description": "Customer", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Customer" } } } } } },
          "401": { "$ref": "#/components/responses/Error" }, "403": { "$ref": "#/components/responses/Error" }, "404": { "$ref": "#/components/responses/Error" }, "429": { "$ref": "#/components/responses/Error" }, "503": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": { "type": "http", "scheme": "bearer", "description": "API key made by the store owner in the store panel (System > API keys). Starts with osk_ and is shown once." }
    },
    "parameters": {
      "id": { "name": "id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1 } },
      "limit": { "name": "limit", "in": "query", "description": "Rows per page", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50 } },
      "cursor": { "name": "cursor", "in": "query", "description": "Value of next_cursor of the previous page", "schema": { "type": "string" } },
      "updated_since": { "name": "updated_since", "in": "query", "description": "Only rows changed at or after this instant (ISO 8601 with time zone, e.g. 2026-12-01T10:00:00Z)", "schema": { "type": "string", "format": "date-time" } },
      "IdempotencyKey": { "name": "Idempotency-Key", "in": "header", "required": true, "description": "Your own unique value for this request (16 to 64 characters of A-Z a-z 0-9 _ -). Kept for 24 hours.", "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{16,64}$" } }
    },
    "responses": {
      "Error": { "description": "Error. `code` is fixed; `message` is a translation of it in the language of Accept-Language.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "object", "properties": {
          "code": { "type": "string", "enum": ["bad_request", "https_required", "unauthorized", "forbidden", "license_inactive", "not_found", "method_not_allowed", "idempotency_conflict", "request_in_progress", "order_not_shippable", "stock_rejected", "reference_limit", "price_rejected", "sku_exists", "product_limit", "payload_too_large", "unsupported_media_type", "invalid_parameter", "rate_limited", "daily_limit", "server_error", "maintenance", "unavailable"] },
          "message": { "type": "string" }, "request_id": { "type": "string" }, "field": { "type": "string", "description": "Name of the parameter or member that was refused (422)" } } } }
      },
      "Store": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "nullable": true }, "domain": { "type": "string" }, "store_ref": { "type": "string", "description": "Opaque, stable reference of this installation" },
          "api_version": { "type": "string" }, "currency": { "type": "string" }, "default_language": { "type": "string" }, "languages": { "type": "array", "items": { "type": "string" } },
          "time_zone": { "type": "string" }, "server_time": { "type": "string", "format": "date-time" },
          "key": { "type": "object", "properties": { "name": { "type": "string" }, "scopes": { "type": "array", "items": { "type": "string" } }, "expires_at": { "type": "string", "format": "date-time", "nullable": true } } },
          "software_version": { "type": "string", "nullable": true, "description": "Only with store:read" }, "license_expires_at": { "type": "string", "format": "date-time", "nullable": true, "description": "Only with store:read" }
        }
      },
      "Variant": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" }, "sku": { "type": "string", "nullable": true }, "label": { "type": "string" },
          "options": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "value": { "type": "string" } } } },
          "price": { "type": "string", "nullable": true, "description": "null: the product's price" }, "sale_price": { "type": "string", "nullable": true },
          "stock": { "type": "integer", "nullable": true }, "status": { "type": "string", "enum": ["active", "inactive"] }, "updated_at": { "type": "string", "format": "date-time", "nullable": true }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" }, "sku": { "type": "string", "nullable": true }, "gtin": { "type": "string", "nullable": true }, "mpn": { "type": "string", "nullable": true },
          "name": { "type": "string" }, "slug": { "type": "string" }, "status": { "type": "string", "enum": ["active", "inactive", "draft", "archived"] },
          "price": { "type": "string" }, "sale_price": { "type": "string", "nullable": true }, "tax_rate": { "type": "string", "nullable": true }, "currency": { "type": "string" },
          "stock": { "type": "integer", "nullable": true }, "weight_kg": { "type": "string", "nullable": true }, "category_id": { "type": "integer", "nullable": true }, "brand_id": { "type": "integer", "nullable": true },
          "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" },
          "variants": { "type": "array", "items": { "$ref": "#/components/schemas/Variant" } }
        }
      },
      "StockRow": {
        "type": "object",
        "properties": {
          "sku": { "type": "string", "nullable": true }, "product_id": { "type": "integer" }, "variant_id": { "type": "integer", "nullable": true },
          "stock": { "type": "integer", "nullable": true }, "tracked": { "type": "boolean" }, "status": { "type": "string" }, "updated_at": { "type": "string", "format": "date-time", "nullable": true }
        }
      },
      "StockUpdate": {
        "type": "object", "required": ["items"], "additionalProperties": false,
        "properties": {
          "mode": { "type": "string", "enum": ["all", "partial"], "default": "all" },
          "items": { "type": "array", "minItems": 1, "maxItems": 100, "items": {
            "type": "object", "required": ["sku"], "additionalProperties": false,
            "description": "Exactly one of quantity and delta. expected only with quantity.",
            "properties": {
              "sku": { "type": "string", "maxLength": 100 },
              "quantity": { "type": "integer", "minimum": 0, "maximum": 1000000 },
              "expected": { "type": "integer", "minimum": 0, "maximum": 1000000 },
              "delta": { "type": "integer", "minimum": -1000000, "maximum": 1000000 }
            } } }
        }
      },
      "StockResultRow": {
        "type": "object",
        "properties": {
          "sku": { "type": "string" }, "status": { "type": "string", "enum": ["updated", "rejected", "not_applied"] },
          "reason": { "type": "string", "enum": ["unknown_sku", "ambiguous_sku", "duplicate_sku", "has_variants", "not_tracked", "expected_mismatch", "insufficient", "too_large"] },
          "previous": { "type": "integer" }, "stock": { "type": "integer" }, "product_id": { "type": "integer" }, "variant_id": { "type": "integer", "nullable": true }
        }
      },
      "StockResult": {
        "type": "object",
        "properties": { "updated": { "type": "integer" }, "rejected": { "type": "integer" }, "results": { "type": "array", "items": { "$ref": "#/components/schemas/StockResultRow" } } }
      },
      "StockRejected": {
        "allOf": [ { "$ref": "#/components/schemas/Error" }, { "type": "object", "properties": { "results": { "type": "array", "items": { "$ref": "#/components/schemas/StockResultRow" } } } } ]
      },
      "Amount": { "type": "string", "pattern": "^(0|[1-9][0-9]{0,6})\\.[0-9]{2}$", "description": "Decimal text with exactly two decimals, 0.01 to 9999999.99", "example": "149.90" },
      "PriceUpdate": {
        "type": "object", "required": ["currency", "items"], "additionalProperties": false,
        "properties": {
          "currency": { "type": "string", "description": "Must equal the store's currency", "example": "TRY" },
          "mode": { "type": "string", "enum": ["all", "partial"], "default": "all" },
          "items": { "type": "array", "minItems": 1, "maxItems": 100, "items": {
            "type": "object", "required": ["sku"], "additionalProperties": false,
            "properties": {
              "sku": { "type": "string", "maxLength": 100 },
              "price": { "allOf": [ { "$ref": "#/components/schemas/Amount" } ], "nullable": true, "description": "null only on a variant: follow the product's price again" },
              "sale_price": { "allOf": [ { "$ref": "#/components/schemas/Amount" } ], "nullable": true, "description": "null removes the sale price" },
              "expected_price": { "$ref": "#/components/schemas/Amount" }
            } } }
        }
      },
      "PriceResultRow": {
        "type": "object",
        "properties": {
          "sku": { "type": "string" }, "status": { "type": "string", "enum": ["updated", "unchanged", "rejected", "not_applied"] },
          "reason": { "type": "string", "enum": ["unknown_sku", "ambiguous_sku", "duplicate_sku", "not_a_variant", "variant_not_recorded", "expected_mismatch", "sale_not_lower", "change_too_large"] },
          "previous_price": { "type": "string", "nullable": true }, "price": { "type": "string", "nullable": true, "description": "The unit's own price; null on a variant that follows its product. On a refused row: the price in force now" },
          "previous_sale_price": { "type": "string", "nullable": true }, "sale_price": { "type": "string", "nullable": true },
          "product_id": { "type": "integer" }, "variant_id": { "type": "integer", "nullable": true },
          "currency_overrides": { "type": "array", "items": { "type": "string" }, "description": "Currencies in which the store keeps a hand-set price for this unit; those were NOT changed" }
        }
      },
      "PriceResult": {
        "type": "object",
        "properties": { "updated": { "type": "integer" }, "unchanged": { "type": "integer" }, "rejected": { "type": "integer" }, "results": { "type": "array", "items": { "$ref": "#/components/schemas/PriceResultRow" } } }
      },
      "PriceRejected": {
        "allOf": [ { "$ref": "#/components/schemas/Error" }, { "type": "object", "properties": { "results": { "type": "array", "items": { "$ref": "#/components/schemas/PriceResultRow" } } } } ]
      },
      "ProductCreate": {
        "type": "object", "required": ["name", "sku", "currency", "price"], "additionalProperties": false,
        "properties": {
          "name": { "type": "string", "minLength": 2, "maxLength": 255, "description": "Plain text with at least one letter or digit" },
          "sku": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Printable ASCII, no blank at either end" },
          "currency": { "type": "string", "description": "Must equal the store's currency", "example": "TRY" },
          "price": { "$ref": "#/components/schemas/Amount" },
          "sale_price": { "allOf": [ { "$ref": "#/components/schemas/Amount" } ], "nullable": true, "description": "Must be lower than price" },
          "stock": { "type": "integer", "minimum": 0, "maximum": 1000000, "nullable": true, "default": 0, "description": "null: quantity not tracked" },
          "tax_rate": { "type": "string", "pattern": "^[0-9]{1,3}\\.[0-9]{2}$", "description": "0.00 to 100.00; default 20.00", "example": "20.00" },
          "weight_kg": { "type": "string", "description": "Decimal text, up to three decimals, 0 to 100000", "example": "1.250" },
          "gtin": { "type": "string", "description": "GTIN of 8, 12 or 13 digits with a valid check digit, not used by another product" },
          "mpn": { "type": "string", "maxLength": 64, "description": "Printable ASCII" },
          "category_id": { "type": "integer", "minimum": 1 }, "brand_id": { "type": "integer", "minimum": 1 },
          "short_description": { "type": "string", "maxLength": 1000, "description": "Plain text; line breaks allowed" }
        }
      },
      "OrderItem": {
        "type": "object",
        "properties": {
          "product_id": { "type": "integer", "nullable": true }, "variation_id": { "type": "integer", "nullable": true }, "sku": { "type": "string", "nullable": true },
          "name": { "type": "string" }, "variation_label": { "type": "string", "nullable": true }, "qty": { "type": "integer" },
          "price": { "type": "string" }, "total": { "type": "string" }, "tax_rate": { "type": "string", "nullable": true }, "discount_amount": { "type": "string" }
        }
      },
      "Reference": {
        "type": "object",
        "properties": { "system": { "type": "string" }, "number": { "type": "string" }, "date": { "type": "string", "format": "date", "nullable": true }, "updated_at": { "type": "string", "format": "date-time" } }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" }, "order_number": { "type": "string" }, "status": { "type": "string" }, "payment_status": { "type": "string", "nullable": true }, "payment_method": { "type": "string", "nullable": true },
          "currency": { "type": "string", "description": "Currency of the amounts of this order" }, "subtotal": { "type": "string" }, "discount_amount": { "type": "string" }, "shipping_amount": { "type": "string" },
          "total": { "type": "string" }, "refunded_amount": { "type": "string" }, "base_currency": { "type": "string" }, "base_total": { "type": "string", "description": "Total in the store's base currency" }, "currency_rate": { "type": "string", "nullable": true },
          "locale": { "type": "string", "nullable": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "paid_at": { "type": "string", "format": "date-time", "nullable": true },
          "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItem" } },
          "references": { "type": "array", "items": { "$ref": "#/components/schemas/Reference" } },
          "shipping": { "type": "object", "properties": {
            "city": { "type": "string", "nullable": true }, "country": { "type": "string", "nullable": true }, "method": { "type": "string", "nullable": true }, "carrier_code": { "type": "string", "nullable": true }, "tracking_number": { "type": "string", "nullable": true },
            "name": { "type": "string", "nullable": true, "description": "Only with orders:billing" }, "address": { "type": "string", "nullable": true, "description": "Only with orders:billing" },
            "district": { "type": "string", "nullable": true, "description": "Only with orders:billing" }, "postal_code": { "type": "string", "nullable": true, "description": "Only with orders:billing" }, "subdivision_code": { "type": "string", "nullable": true, "description": "Only with orders:billing" } } },
          "billing": { "type": "object", "description": "Only with orders:billing", "properties": {
            "invoice_type": { "type": "string", "enum": ["individual", "corporate"] }, "name": { "type": "string", "nullable": true }, "company_name": { "type": "string", "nullable": true },
            "tax_office": { "type": "string", "nullable": true }, "tax_number": { "type": "string", "nullable": true }, "address": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "district": { "type": "string", "nullable": true } } },
          "customer_id": { "type": "integer", "nullable": true, "description": "Only with customers:read or customers:contact" },
          "contact": { "type": "object", "description": "Only with customers:contact", "properties": { "email": { "type": "string", "nullable": true }, "phone": { "type": "string", "nullable": true } } }
        }
      },
      "Tracking": {
        "type": "object",
        "properties": {
          "order_id": { "type": "integer" }, "order_number": { "type": "string" }, "status": { "type": "string" }, "carrier_code": { "type": "string", "nullable": true }, "carrier_name": { "type": "string", "nullable": true },
          "tracking_number": { "type": "string", "nullable": true }, "tracking_url": { "type": "string", "nullable": true }, "shipped_at": { "type": "string", "format": "date-time", "nullable": true }
        }
      },
      "ShipmentRequest": {
        "type": "object", "required": ["carrier_code", "tracking_number"], "additionalProperties": false,
        "properties": {
          "carrier_code": { "type": "string", "description": "Code of an active carrier of the store" },
          "tracking_number": { "type": "string", "pattern": "^[A-Za-z0-9._-]{3,64}$", "description": "Letters, digits, dot, underscore, hyphen. Values that read as a web address are refused." },
          "notify_customer": { "type": "boolean", "default": true }
        }
      },
      "ShipmentResult": {
        "type": "object",
        "properties": {
          "order_id": { "type": "integer" }, "status": { "type": "string", "enum": ["shipped"] }, "carrier_code": { "type": "string" }, "carrier_name": { "type": "string" },
          "tracking_number": { "type": "string" }, "tracking_url": { "type": "string", "nullable": true }, "email_sent": { "type": "boolean" }
        }
      },
      "ReferenceRequest": {
        "type": "object", "required": ["system", "number"], "additionalProperties": false,
        "properties": {
          "system": { "type": "string", "maxLength": 40, "description": "Name of your program: Latin letters, digits, blank, dot, underscore, hyphen" },
          "number": { "type": "string", "maxLength": 64, "description": "Letters, digits, blank and . _ / # -; no web address" },
          "date": { "type": "string", "format": "date", "nullable": true }
        }
      },
      "ReferenceResult": {
        "type": "object",
        "properties": { "order_id": { "type": "integer" }, "system": { "type": "string" }, "number": { "type": "string" }, "date": { "type": "string", "format": "date", "nullable": true }, "updated_at": { "type": "string", "format": "date-time" } }
      },
      "Carrier": {
        "type": "object",
        "properties": { "code": { "type": "string" }, "name": { "type": "string" }, "has_tracking_link": { "type": "boolean" } }
      },
      "Address": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" }, "title": { "type": "string" }, "first_name": { "type": "string" }, "last_name": { "type": "string" }, "phone": { "type": "string", "nullable": true },
          "address_line1": { "type": "string" }, "address_line2": { "type": "string", "nullable": true }, "city": { "type": "string" }, "district": { "type": "string", "nullable": true }, "postal_code": { "type": "string", "nullable": true },
          "country": { "type": "string" }, "subdivision_code": { "type": "string", "nullable": true }, "is_default": { "type": "boolean" }, "invoice_type": { "type": "string" },
          "company_name": { "type": "string", "nullable": true }, "tax_office": { "type": "string", "nullable": true }, "tax_number": { "type": "string", "nullable": true }, "updated_at": { "type": "string", "format": "date-time", "nullable": true }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" }, "first_name": { "type": "string" }, "last_name": { "type": "string" }, "email": { "type": "string" }, "status": { "type": "string", "enum": ["active", "inactive"] },
          "locale": { "type": "string", "nullable": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" },
          "phone": { "type": "string", "nullable": true, "description": "Only with customers:contact" }, "marketing_consent": { "type": "boolean", "description": "Only with customers:contact" },
          "addresses": { "type": "array", "description": "Only with customers:contact", "items": { "$ref": "#/components/schemas/Address" } }
        }
      }
    }
  }
}
