{
  "openapi": "3.0.3",
  "info": {
    "title": "ADSWAR Reseller API",
    "version": "1.3.0",
    "description": "Contract revision 2026-11-05. Additive UID audit and asynchronous recheck for authenticated owned API orders. Existing data[], delivery counts, purchase recovery, price ceilings and raw credential delivery remain compatible. UID results are public-picture heuristics, not login or ownership guarantees. GET reads stored evidence only. New eligible orders are checked asynchronously after full fulfillment; historical orders are not_checked until explicitly queued and are marked retrospective. No automatic refund, cancellation API or delivery webhook. Require the four purchase safety flags and the facebook_uid_audit/facebook_uid_recheck flags for UID features. Header authentication preferred; never log keys or credentials. Per-reseller integration acceptance remains necessary."
  },
  "servers": [
    {
      "url": "https://adswar.shop/api",
      "description": "Production ADSWAR API; verify authenticated capabilities and each shop integration before enabling new behavior."
    }
  ],
  "security": [
    {
      "ResellerHeader": []
    },
    {
      "ResellerQuery": []
    }
  ],
  "paths": {
    "/reseller_capabilities.php": {
      "get": {
        "operationId": "getResellerCapabilities",
        "summary": "ตรวจความพร้อมก่อนซื้ออัตโนมัติ / Automation readiness",
        "description": "Authenticated read-only no-store handshake. Require durable_idempotency, client_order_lookup, delivery_snapshot and price_ceiling for purchases; additionally require facebook_uid_audit and facebook_uid_recheck when using UID audit. Do not infer readiness from the version label alone.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/profile.php": {
      "get": {
        "operationId": "getProfile",
        "summary": "ยอดเงินและสกุลเงิน / Wallet and currency",
        "description": "",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/products.php": {
      "get": {
        "operationId": "getProducts",
        "summary": "หมวดหมู่และสินค้าทั้งหมด / Flat catalog",
        "description": "",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Catalog"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/products_child.php": {
      "get": {
        "operationId": "getChildProducts",
        "summary": "หมวดหมู่แม่–ลูก / Legacy category tree",
        "description": "Legacy two-level category view. Prefer products.php for complete offer synchronization.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChildCatalog"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/product.php": {
      "get": {
        "operationId": "getProduct",
        "summary": "ตรวจสินค้าหนึ่งรายการ / Offer lookup",
        "description": "",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          },
          {
            "name": "product",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 999999999
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductLookup"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/buy_product": {
      "post": {
        "operationId": "buyProduct",
        "summary": "ซื้อด้วยยอดกระเป๋า / Purchase with wallet",
        "description": "Real charge. POST only. New integrations MUST use a stable persisted client_order_id (body) or Idempotency-Key (header), AND a persisted decimal-string max_total cost ceiling. max_total is optional only for legacy compatibility. Reject malformed/conflicting supplied caps; 409 PRICE_CEILING_EXCEEDED must never trigger automatic cap increases. Same reseller/reference/payload replays the original order without another charge; changed payload returns 409. Existing committed references are resolved before current stock/price checks; keep product, quantity, coupon and canonical max_total unchanged. Do not automatically retry POST after timeout; lookup order_status.php by the same reference first.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
              "example": "RS-DEMO-0001"
            },
            "description": "Alias for client_order_id. If both supplied, values must match. Not a credential."
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderSnapshot"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Purchase"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Purchase"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Purchase"
              }
            }
          }
        }
      }
    },
    "/order_status.php": {
      "get": {
        "operationId": "getOrderStatus",
        "summary": "ติดตามด้วยรหัสใดรหัสหนึ่ง / Recover order status",
        "description": "Authenticated own API order only. Remains readable while new purchases are disabled; key, member and IP checks still apply. Known pending orders return 200 success with an empty data array. 404 means no matching committed order found at this instant, not proof that an in-flight purchase failed. Keep the same reference.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,64}$"
            },
            "description": "ADSWAR trans_id. Provide order or client_order_id."
          },
          {
            "name": "client_order_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
              "example": "RS-DEMO-0001"
            },
            "description": "Persisted reseller reference. If both identifiers supplied they must identify the same order."
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderSnapshot"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/order_uid_check.php": {
      "post": {
        "operationId": "queueOrderUidCheck",
        "summary": "ขอตรวจ UID ของออเดอร์เดิม / Queue owned-order UID audit",
        "description": "Queues asynchronous checks for stored UID/code pairs in an authenticated owned source=api order. Supply order or client_order_id; when both are supplied they must identify the same order. Optional item_id must belong to the order. Uses the same API-key/member/IP checks, no caller-supplied UID or credentials. HTTP 200 means queue request accepted, not a completed check. Poll order_status.php for uid_check. No purchase, wallet debit, replacement, refund or delivery pause. Limit 6 requests per minute; repeated queue requests do not imply additional completed checks. Owned-history lookup/recheck remains available when new purchases are disabled. Unknown fields are rejected with INVALID_CHECK_INPUT; invalid item UUID uses INVALID_ITEM_ID. Duplicated query/body values must be matching strings. Historical first checks retain their actual timestamp and origin=retrospective. Do not repeatedly POST while pending/checking; honor HTTP 429. After a timeout read the same order, never buy again.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UidCheckQueued"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UidCheckRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/UidCheckRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UidCheckRequest"
              }
            }
          }
        }
      }
    },
    "/order.php": {
      "get": {
        "operationId": "getLegacyOrder",
        "summary": "อ่านข้อมูลออเดอร์เดิม / Legacy order snapshot",
        "description": "Remains readable while new purchases are disabled, with normal authentication. Legacy behavior retained: 404 when no delivered items, with order metadata for a known order. Use order_status.php for new integrations. data is a full snapshot, not a delta.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Only query lang controls language for this API; examples use th/en.",
            "schema": {
              "type": "string",
              "example": "th"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success does not by itself mean delivery is complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderSnapshot"
                }
              }
            }
          },
          "400": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "API error. See error_code and order context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Inspect error_code: price ceiling exceeded, or same client_order_id with different product/amount/coupon/max_total. Never raise cap or change reference automatically.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; honor Retry-After and retry_after_seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before the next allowed request."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The result of a purchase may be uncertain. Recover by the same reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ResellerHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Reseller member key, never an admin key or JWT. Preferred to keep credentials out of URLs."
      },
      "ResellerQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "api_key",
        "description": "Legacy compatibility only; redact query credentials in all logs."
      }
    },
    "schemas": {
      "UidEvidence": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "httpStatus": {
            "type": "integer"
          },
          "graphCode": {
            "type": "integer"
          },
          "graphSubcode": {
            "type": "integer"
          },
          "isSilhouette": {
            "type": "boolean"
          },
          "pictureHost": {
            "type": "string"
          },
          "width": {
            "type": "integer"
          },
          "height": {
            "type": "integer"
          },
          "availabilityHeuristic": {
            "type": "boolean"
          },
          "retryAfterSeconds": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "UidAccount": {
        "type": "object",
        "required": [
          "code_id",
          "uid",
          "status",
          "checked_at",
          "reason",
          "method"
        ],
        "properties": {
          "code_id": {
            "type": "string",
            "format": "uuid"
          },
          "uid": {
            "type": "string",
            "description": "Stored numeric UID, or empty when the stored account has no valid UID. Never a submitted credential line."
          },
          "status": {
            "type": "string",
            "enum": [
              "LIVE",
              "DIE",
              "UNKNOWN"
            ]
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string",
            "nullable": true,
            "description": "Machine-readable reason. UNKNOWN includes timeout, restrictions and rate limiting; never convert UNKNOWN to DIE."
          },
          "method": {
            "type": "string",
            "nullable": true,
            "description": "Public-profile availability heuristic, not a login or ownership check."
          },
          "evidence": {
            "$ref": "#/components/schemas/UidEvidence"
          }
        }
      },
      "UidCheck": {
        "type": "object",
        "required": [
          "id",
          "checked_at",
          "live",
          "die",
          "unknown",
          "accounts"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "live": {
            "type": "integer",
            "minimum": 0
          },
          "die": {
            "type": "integer",
            "minimum": 0
          },
          "unknown": {
            "type": "integer",
            "minimum": 0
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UidAccount"
            }
          }
        }
      },
      "UidAuditItem": {
        "type": "object",
        "required": [
          "item_id",
          "requested_amount",
          "status",
          "review_required",
          "matches_current_delivery",
          "origin",
          "requested_at",
          "initial_check",
          "latest_check"
        ],
        "properties": {
          "item_id": {
            "type": "string",
            "format": "uuid"
          },
          "requested_amount": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "not_applicable",
              "not_checked",
              "pending",
              "checking",
              "completed"
            ]
          },
          "review_required": {
            "type": "boolean"
          },
          "matches_current_delivery": {
            "type": "boolean",
            "description": "True only when latest_check is bound to the current delivered code IDs and UIDs. Replacement makes previous evidence stale."
          },
          "origin": {
            "type": "string",
            "enum": [
              "checkout",
              "retrospective"
            ],
            "nullable": true,
            "description": "retrospective is a later check and never proves the UID status at time of sale."
          },
          "requested_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "initial_check": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UidCheck"
              }
            ],
            "nullable": true
          },
          "latest_check": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UidCheck"
              }
            ],
            "nullable": true
          }
        }
      },
      "UidAudit": {
        "type": "object",
        "required": [
          "version",
          "status",
          "review_required",
          "items"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "not_applicable",
              "not_checked",
              "pending",
              "checking",
              "completed"
            ]
          },
          "review_required": {
            "type": "boolean"
          },
          "error_code": {
            "type": "string",
            "enum": [
              "UID_AUDIT_UNAVAILABLE"
            ],
            "description": "When stored audit evidence cannot be read: pending + review_required=true + items=[]. Raw delivery remains available; do not treat missing evidence as a passed check."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UidAuditItem"
            }
          }
        }
      },
      "UidCheckRequest": {
        "type": "object",
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "order"
            ]
          },
          {
            "required": [
              "client_order_id"
            ]
          }
        ],
        "properties": {
          "order": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,64}$"
          },
          "client_order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
            "example": "RS-DEMO-0001"
          },
          "api_key": {
            "type": "string",
            "writeOnly": true,
            "description": "Legacy body key; prefer X-API-Key. Supplied keys must agree."
          },
          "lang": {
            "type": "string",
            "description": "Accepted for compatibility; query lang selects response language."
          },
          "item_id": {
            "type": "string",
            "format": "uuid",
            "description": "Optional eligible order-item ID from uid_check.items. Omit to queue eligible items in this order."
          }
        }
      },
      "UidCheckQueued": {
        "type": "object",
        "required": [
          "status",
          "trans_id",
          "uid_check"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "trans_id": {
            "type": "string"
          },
          "uid_check": {
            "$ref": "#/components/schemas/UidAudit"
          }
        }
      },
      "Capabilities": {
        "type": "object",
        "required": [
          "status",
          "api_version",
          "capabilities",
          "currency",
          "buy_interval_seconds",
          "poll_after_seconds"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "api_version": {
            "type": "string",
            "example": "1.3"
          },
          "currency": {
            "type": "string",
            "example": "THB"
          },
          "capabilities": {
            "type": "object",
            "required": [
              "durable_idempotency",
              "client_order_lookup",
              "delivery_snapshot",
              "price_ceiling",
              "facebook_uid_audit",
              "facebook_uid_recheck"
            ],
            "properties": {
              "durable_idempotency": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "client_order_lookup": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "delivery_snapshot": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "price_ceiling": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "facebook_uid_audit": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "facebook_uid_recheck": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            }
          },
          "buy_interval_seconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 3600
          },
          "poll_after_seconds": {
            "type": "integer",
            "minimum": 1,
            "example": 5
          }
        }
      },
      "Profile": {
        "type": "object",
        "required": [
          "status",
          "data"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "msg": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "username",
              "money",
              "currency"
            ],
            "properties": {
              "username": {
                "type": "string"
              },
              "money": {
                "type": "string",
                "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
                "example": "1000.5",
                "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
              },
              "currency": {
                "type": "string",
                "example": "THB"
              }
            }
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "id",
          "name",
          "price",
          "amount",
          "min",
          "max"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "1234"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
          },
          "amount": {
            "type": "integer",
            "minimum": 0
          },
          "description": {
            "type": "string"
          },
          "flag": {
            "type": "string"
          },
          "price_quantity_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "description": "Flash quota for the advertised unit price, not reserved stock. Quantity above this needs a new approved cost."
          },
          "price_valid_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "min": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              {
                "type": "integer",
                "minimum": 1
              }
            ]
          },
          "max": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              {
                "type": "integer",
                "minimum": 1
              }
            ]
          }
        }
      },
      "Category": {
        "type": "object",
        "required": [
          "id",
          "name",
          "products"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "parent_id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          }
        }
      },
      "ChildCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "keywords": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "stt": {
            "type": "integer"
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          }
        }
      },
      "ParentCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "keywords": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "stt": {
            "type": "integer"
          },
          "child_categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChildCategory"
            }
          }
        }
      },
      "Catalog": {
        "type": "object",
        "required": [
          "status",
          "categories"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "msg": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          }
        }
      },
      "ChildCatalog": {
        "type": "object",
        "required": [
          "status",
          "categories"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "msg": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParentCategory"
            }
          }
        }
      },
      "ProductLookup": {
        "type": "object",
        "required": [
          "status",
          "product"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "msg": {
            "type": "string"
          },
          "product": {
            "type": "array",
            "maxItems": 1,
            "items": {
              "$ref": "#/components/schemas/Product"
            },
            "description": "An empty array means no currently available API offer."
          }
        }
      },
      "OrderSnapshot": {
        "type": "object",
        "required": [
          "status",
          "trans_id",
          "client_order_id",
          "replayed",
          "order_status",
          "payment_status",
          "delivery_status",
          "requested_amount",
          "delivered_amount",
          "remaining_amount",
          "currency",
          "total",
          "refunded_total",
          "wallet_refunded_total",
          "created_at",
          "updated_at",
          "poll_after_seconds",
          "uid_check",
          "data"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "msg": {
            "type": "string"
          },
          "trans_id": {
            "type": "string",
            "example": "IK261018DEMO1234"
          },
          "client_order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
            "example": "RS-DEMO-0001",
            "nullable": true
          },
          "replayed": {
            "type": "boolean",
            "description": "True when replaying a matching existing purchase, without a second debit."
          },
          "order_status": {
            "type": "string",
            "enum": [
              "PENDING",
              "CONFIRMED",
              "PROCESSING",
              "SHIPPING",
              "COMPLETED",
              "CANCELLED",
              "REFUNDED"
            ]
          },
          "payment_status": {
            "type": "string",
            "enum": [
              "UNPAID",
              "PAID",
              "PARTIALLY_REFUNDED",
              "REFUNDED",
              "FAILED"
            ]
          },
          "delivery_status": {
            "type": "string",
            "enum": [
              "pending",
              "partial",
              "delivered",
              "cancelled",
              "refunded",
              "needs_review"
            ]
          },
          "requested_amount": {
            "type": "integer",
            "minimum": 1
          },
          "delivered_amount": {
            "type": "integer",
            "minimum": 0
          },
          "remaining_amount": {
            "type": "integer",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "THB"
          },
          "total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
          },
          "refunded_total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
          },
          "wallet_refunded_total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Actual refund credits to this reseller wallet for this order. Not a refund to the reseller customer."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "poll_after_seconds": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "example": 5
          },
          "uid_check": {
            "$ref": "#/components/schemas/UidAudit",
            "description": "Stored UID audit, separate from delivery. GET does not contact Facebook. Existing credentials and delivery semantics stay unchanged."
          },
          "data": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Full current snapshot of delivered items, not a delta. Items may contain credentials: store securely and never log."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "status",
          "msg",
          "error_code"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "msg": {
            "type": "string",
            "description": "Human message, localized. Do not parse this for business decisions."
          },
          "error_code": {
            "type": "string",
            "enum": [
              "INVALID_PRICE_CEILING",
              "PRICE_CEILING_EXCEEDED",
              "INVALID_REQUEST",
              "API_KEY_REQUIRED",
              "API_KEY_INVALID",
              "IP_NOT_ALLOWED",
              "API_DISABLED",
              "RATE_LIMITED",
              "PRODUCT_NOT_FOUND",
              "INVALID_QUANTITY",
              "INSUFFICIENT_STOCK",
              "INSUFFICIENT_BALANCE",
              "ORDER_NOT_FOUND",
              "ORDER_CLOSED",
              "IDEMPOTENCY_CONFLICT",
              "DELIVERY_PENDING",
              "DELIVERY_UNAVAILABLE",
              "INTERNAL_ERROR",
              "METHOD_NOT_ALLOWED",
              "INVALID_CHECK_INPUT",
              "INVALID_ITEM_ID"
            ]
          },
          "retry_after_seconds": {
            "type": "integer",
            "minimum": 1
          },
          "client_ip": {
            "type": "string"
          },
          "trans_id": {
            "type": "string",
            "example": "IK261018DEMO1234"
          },
          "client_order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
            "example": "RS-DEMO-0001",
            "nullable": true
          },
          "replayed": {
            "type": "boolean",
            "description": "True when replaying a matching existing purchase, without a second debit."
          },
          "order_status": {
            "type": "string",
            "enum": [
              "PENDING",
              "CONFIRMED",
              "PROCESSING",
              "SHIPPING",
              "COMPLETED",
              "CANCELLED",
              "REFUNDED"
            ]
          },
          "payment_status": {
            "type": "string",
            "enum": [
              "UNPAID",
              "PAID",
              "PARTIALLY_REFUNDED",
              "REFUNDED",
              "FAILED"
            ]
          },
          "delivery_status": {
            "type": "string",
            "enum": [
              "pending",
              "partial",
              "delivered",
              "cancelled",
              "refunded",
              "needs_review"
            ]
          },
          "requested_amount": {
            "type": "integer",
            "minimum": 1
          },
          "delivered_amount": {
            "type": "integer",
            "minimum": 0
          },
          "remaining_amount": {
            "type": "integer",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "THB"
          },
          "total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
          },
          "refunded_total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Decimal in the returned currency. Keep as decimal or minor units, never binary floating point."
          },
          "wallet_refunded_total": {
            "type": "string",
            "pattern": "^-?[0-9]+(?:\\.[0-9]{1,2})?$",
            "example": "1000.5",
            "description": "Actual refund credits to this reseller wallet for this order. Not a refund to the reseller customer."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "poll_after_seconds": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "example": 5
          },
          "uid_check": {
            "$ref": "#/components/schemas/UidAudit",
            "description": "Stored UID audit, separate from delivery. GET does not contact Facebook. Existing credentials and delivery semantics stay unchanged."
          },
          "data": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Full current snapshot of delivered items, not a delta. Items may contain credentials: store securely and never log."
          }
        }
      },
      "Purchase": {
        "type": "object",
        "required": [
          "action",
          "id",
          "amount"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "buyProduct"
            ]
          },
          "id": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^[0-9]{1,9}$"
              },
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 999999999
              }
            ]
          },
          "amount": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^[0-9]{1,9}$"
              },
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 999999999
              }
            ]
          },
          "max_total": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,12})(?:\\.[0-9]{1,2})?$",
            "example": "75.00",
            "description": "Optional legacy-compatible total cost ceiling. New integrations must persist and send a nonnegative decimal string; retain exact canonical ceiling on retries."
          },
          "coupon": {
            "type": "string",
            "maxLength": 50,
            "description": "Optional coupon. Send ASCII letters/digits, underscore or hyphen; keep unchanged for a reference."
          },
          "client_order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
            "example": "RS-DEMO-0001"
          },
          "api_key": {
            "type": "string",
            "writeOnly": true,
            "description": "Legacy body authentication. Prefer X-API-Key; if both are supplied they must match."
          }
        }
      }
    }
  }
}
