{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "JP Digital Public Catalog API",
    "version": "1.0.0",
    "description": "Read-only discovery and product-catalog API for JP Digital Ecuador. Use it to check API availability, search published products, retrieve public product details, and list product categories. Prices are expressed in the smallest currency unit inside the prices object. Availability and prices must be reconfirmed before a purchase.",
    "termsOfService": "https://jpdigital.com.ec/terminos-y-condiciones/"
  },
  "servers": [
    {
      "url": "https://jpdigital.com.ec",
      "description": "JP Digital production site"
    }
  ],
  "externalDocs": {
    "description": "Human-readable API documentation",
    "url": "https://jpdigital.com.ec/docs/"
  },
  "tags": [
    {
      "name": "Discovery",
      "description": "Machine-readable service discovery."
    },
    {
      "name": "Products",
      "description": "Public, published WooCommerce catalog data."
    },
    {
      "name": "Categories",
      "description": "Public product category data."
    }
  ],
  "paths": {
    "/wp-json/jpdigital/v1/status": {
      "get": {
        "operationId": "getAgentApiStatus",
        "summary": "Check public API availability",
        "description": "Returns discovery URLs and confirms that the anonymous public API is available. No authentication is required.",
        "tags": ["Discovery"],
        "security": [],
        "responses": {
          "200": {
            "description": "The public API is available.",
            "headers": {
              "Cache-Control": {
                "description": "Short public cache policy.",
                "schema": {"type": "string"}
              }
            },
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/ApiStatus"}
              }
            }
          },
          "500": {"$ref": "#/components/responses/ApiError"}
        }
      }
    },
    "/wp-json/wc/store/v1/products": {
      "get": {
        "operationId": "searchPublishedProducts",
        "summary": "Search published products",
        "description": "Returns public catalog products. Use search for natural-language product names, sku for an exact SKU, or category and brand for catalog filtering. Collection responses are paginated with X-WP-Total and X-WP-TotalPages headers.",
        "tags": ["Products"],
        "security": [],
        "parameters": [
          {"$ref": "#/components/parameters/Page"},
          {"$ref": "#/components/parameters/PerPage"},
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Limit results to products matching this search string.",
            "schema": {"type": "string", "minLength": 1, "maxLength": 200}
          },
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "description": "Limit results to one or more comma-separated SKUs.",
            "schema": {"type": "string", "minLength": 1, "maxLength": 200}
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category ID or slug; separate multiple values with commas.",
            "schema": {"type": "string", "minLength": 1, "maxLength": 300}
          },
          {
            "name": "brand",
            "in": "query",
            "required": false,
            "description": "Brand ID or slug; separate multiple values with commas.",
            "schema": {"type": "string", "minLength": 1, "maxLength": 300}
          },
          {
            "name": "orderby",
            "in": "query",
            "required": false,
            "description": "Product ordering field.",
            "schema": {
              "type": "string",
              "enum": ["date", "modified", "id", "title", "slug", "price", "popularity", "rating", "menu_order"],
              "default": "date"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "Sort direction.",
            "schema": {"type": "string", "enum": ["asc", "desc"], "default": "desc"}
          },
          {
            "name": "stock_status",
            "in": "query",
            "required": false,
            "description": "Limit results to one or more stock states.",
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {"type": "string", "enum": ["instock", "outofstock", "onbackorder"]}
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of public products.",
            "headers": {
              "X-WP-Total": {
                "description": "Total matching products.",
                "schema": {"type": "integer", "minimum": 0}
              },
              "X-WP-TotalPages": {
                "description": "Total result pages.",
                "schema": {"type": "integer", "minimum": 0}
              },
              "Link": {
                "description": "Pagination links when another page is available.",
                "schema": {"type": "string"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {"$ref": "#/components/schemas/Product"}
                }
              }
            }
          },
          "400": {"$ref": "#/components/responses/ApiError"}
        }
      }
    },
    "/wp-json/wc/store/v1/products/{id}": {
      "get": {
        "operationId": "getPublishedProductById",
        "summary": "Retrieve one published product",
        "description": "Returns one public product by its numeric WooCommerce product ID. Draft, private, missing, and non-published products return a JSON 404 response.",
        "tags": ["Products"],
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric product identifier returned by the product collection.",
            "schema": {"type": "integer", "minimum": 1}
          }
        ],
        "responses": {
          "200": {
            "description": "The requested public product.",
            "content": {
              "application/json": {"schema": {"$ref": "#/components/schemas/Product"}}
            }
          },
          "404": {"$ref": "#/components/responses/ApiError"}
        }
      }
    },
    "/wp-json/wc/store/v1/products/categories": {
      "get": {
        "operationId": "listProductCategories",
        "summary": "List product categories",
        "description": "Returns public product categories for discovery and catalog filtering. Pass a returned category ID or slug to the product search operation.",
        "tags": ["Categories"],
        "security": [],
        "parameters": [
          {"$ref": "#/components/parameters/Page"},
          {"$ref": "#/components/parameters/PerPage"},
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Limit categories to names matching this search string.",
            "schema": {"type": "string", "minLength": 1, "maxLength": 200}
          },
          {
            "name": "hide_empty",
            "in": "query",
            "required": false,
            "description": "Hide categories that contain no published products.",
            "schema": {"type": "boolean", "default": true}
          }
        ],
        "responses": {
          "200": {
            "description": "A page of public product categories.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {"$ref": "#/components/schemas/ProductCategory"}
                }
              }
            }
          },
          "400": {"$ref": "#/components/responses/ApiError"}
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Page": {
        "name": "page",
        "in": "query",
        "required": false,
        "description": "One-based result page.",
        "schema": {"type": "integer", "minimum": 1, "default": 1}
      },
      "PerPage": {
        "name": "per_page",
        "in": "query",
        "required": false,
        "description": "Maximum records per page.",
        "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 10}
      }
    },
    "responses": {
      "ApiError": {
        "description": "A structured JSON error with an HTTP status and recovery hint.",
        "content": {
          "application/json": {
            "schema": {"$ref": "#/components/schemas/ApiError"}
          },
          "application/problem+json": {
            "schema": {"$ref": "#/components/schemas/ProblemDetails"}
          }
        }
      }
    },
    "schemas": {
      "ApiStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "status", "api_version", "openapi_url", "docs_url", "llms_url", "catalog_url", "generated_at"],
        "properties": {
          "name": {"type": "string", "const": "JP Digital Agent API"},
          "status": {"type": "string", "const": "ok"},
          "api_version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
          "openapi_url": {"type": "string", "format": "uri"},
          "docs_url": {"type": "string", "format": "uri"},
          "llms_url": {"type": "string", "format": "uri"},
          "catalog_url": {"type": "string", "format": "uri"},
          "generated_at": {"type": "string", "format": "date-time"}
        }
      },
      "Product": {
        "type": "object",
        "additionalProperties": true,
        "required": ["id", "name", "slug", "permalink", "sku", "prices", "is_in_stock", "categories"],
        "properties": {
          "id": {"type": "integer", "minimum": 1},
          "name": {"type": "string"},
          "slug": {"type": "string"},
          "permalink": {"type": "string", "format": "uri"},
          "sku": {"type": "string"},
          "short_description": {"type": "string", "description": "Sanitized HTML supplied by WooCommerce."},
          "description": {"type": "string", "description": "Sanitized HTML supplied by WooCommerce."},
          "on_sale": {"type": "boolean"},
          "prices": {"$ref": "#/components/schemas/ProductPrices"},
          "is_purchasable": {"type": "boolean"},
          "is_in_stock": {"type": "boolean"},
          "stock_availability": {
            "type": ["object", "null"],
            "additionalProperties": true,
            "properties": {"text": {"type": "string"}, "class": {"type": "string"}}
          },
          "categories": {
            "type": "array",
            "items": {"$ref": "#/components/schemas/ProductTerm"}
          },
          "brands": {
            "type": "array",
            "items": {"$ref": "#/components/schemas/ProductTerm"}
          },
          "images": {
            "type": "array",
            "items": {"$ref": "#/components/schemas/ProductImage"}
          }
        }
      },
      "ProductPrices": {
        "type": "object",
        "additionalProperties": true,
        "required": ["price", "regular_price", "sale_price", "currency_code", "currency_minor_unit"],
        "properties": {
          "price": {"type": "string", "pattern": "^[0-9]+$", "description": "Current price in the smallest currency unit."},
          "regular_price": {"type": "string", "pattern": "^[0-9]+$"},
          "sale_price": {"type": "string", "pattern": "^[0-9]+$"},
          "currency_code": {"type": "string", "pattern": "^[A-Z]{3}$", "example": "USD"},
          "currency_symbol": {"type": "string", "example": "$"},
          "currency_minor_unit": {"type": "integer", "minimum": 0, "maximum": 4, "example": 2}
        }
      },
      "ProductTerm": {
        "type": "object",
        "additionalProperties": true,
        "required": ["id", "name", "slug", "link"],
        "properties": {
          "id": {"type": "integer", "minimum": 1},
          "name": {"type": "string"},
          "slug": {"type": "string"},
          "link": {"type": "string", "format": "uri"}
        }
      },
      "ProductImage": {
        "type": "object",
        "additionalProperties": true,
        "required": ["id", "src", "thumbnail", "name", "alt"],
        "properties": {
          "id": {"type": "integer", "minimum": 0},
          "src": {"type": "string", "format": "uri"},
          "thumbnail": {"type": "string", "format": "uri"},
          "name": {"type": "string"},
          "alt": {"type": "string"}
        }
      },
      "ProductCategory": {
        "type": "object",
        "additionalProperties": true,
        "required": ["id", "name", "slug", "description", "parent", "count", "permalink"],
        "properties": {
          "id": {"type": "integer", "minimum": 1},
          "name": {"type": "string"},
          "slug": {"type": "string"},
          "description": {"type": "string"},
          "parent": {"type": "integer", "minimum": 0},
          "count": {"type": "integer", "minimum": 0},
          "permalink": {"type": "string", "format": "uri"}
        }
      },
      "ApiError": {
        "type": "object",
        "additionalProperties": true,
        "required": ["code", "message", "data"],
        "properties": {
          "code": {"type": "string", "description": "Stable machine-readable error code."},
          "message": {"type": "string", "description": "Human-readable error summary."},
          "data": {
            "type": "object",
            "additionalProperties": true,
            "required": ["status", "resolution"],
            "properties": {
              "status": {"type": "integer", "minimum": 400, "maximum": 599},
              "resolution": {"type": "string", "description": "Action an agent can take before retrying."}
            }
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "additionalProperties": true,
        "required": ["type", "title", "status", "error"],
        "properties": {
          "type": {"type": "string", "format": "uri"},
          "title": {"type": "string"},
          "status": {"type": "integer", "minimum": 400, "maximum": 599},
          "error": {
            "type": "object",
            "required": ["code", "message", "resolution"],
            "properties": {
              "code": {"type": "string"},
              "message": {"type": "string"},
              "resolution": {"type": "string"}
            }
          }
        }
      }
    }
  }
}
