{
  "openapi": "3.1.0",
  "info": {
    "title": "DroneFactory.ch Public Shop Discovery API",
    "version": "1.1.0",
    "description": "Public read-only discovery surface for DroneFactory.ch product browsing, product search and MCP-based agent access."
  },
  "servers": [
    {
      "url": "https://www.dronefactory.ch"
    }
  ],
  "paths": {
    "/wp-json/": {
      "get": {
        "summary": "WordPress REST API index",
        "operationId": "getWpRestIndex",
        "responses": {
          "200": {
            "description": "REST API discovery document"
          }
        }
      }
    },
    "/wp-json/df-agent/v1/products": {
      "get": {
        "summary": "Search public DroneFactory.ch products for AI agents",
        "operationId": "searchDroneFactoryProducts",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Product name, SKU, GTIN/EAN, brand, category or part number."
          },
          {
            "name": "query",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Alias for search."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public product search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/wp-json/df-agent/v1/products/{id}": {
      "get": {
        "summary": "Read one public DroneFactory.ch product by ID",
        "operationId": "getDroneFactoryProduct",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public product details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "404": {
            "description": "Product not found"
          }
        }
      }
    },
    "/wp-json/df-agent/v1/categories": {
      "get": {
        "summary": "List public DroneFactory.ch product categories",
        "operationId": "listDroneFactoryProductCategories",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Optional category search term."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public product categories",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Category"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/wp-json/df-agent/v1/carts": {
      "post": {
        "summary": "Create a public cart handoff URL for human checkout",
        "operationId": "createDroneFactoryCartHandoff",
        "description": "Creates a DroneFactory.ch cart handoff response. The returned continue_url must be opened by the user to review the cart and complete checkout on the normal website. This endpoint does not authorize payment or place an order.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CartHandoffRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cart handoff response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CartHandoff"
                }
              }
            }
          },
          "400": {
            "description": "No valid purchasable cart items were provided"
          }
        }
      }
    },
    "/wp-json/df-agent/v1/cart-transfer": {
      "get": {
        "summary": "Browser cart transfer URL",
        "operationId": "openDroneFactoryCartTransfer",
        "description": "User-facing URL that adds selected products to the WooCommerce cart and redirects to the normal DroneFactory.ch cart page.",
        "parameters": [
          {
            "name": "items",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated product IDs and quantities, for example 96677:2,96671:1."
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to DroneFactory.ch cart"
          },
          "400": {
            "description": "Invalid cart transfer request"
          }
        }
      }
    },
    "/wp-json/wc/store/v1/products": {
      "get": {
        "summary": "WooCommerce Store API public products",
        "operationId": "searchStoreProducts",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Search term for public product names and descriptions."
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of public WooCommerce Store API products"
          }
        }
      }
    },
    "/wp-json/wc/store/v1/products/{id}": {
      "get": {
        "summary": "WooCommerce Store API public product by ID",
        "operationId": "getStoreProduct",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public product details"
          },
          "404": {
            "description": "Product not found"
          }
        }
      }
    },
    "/wp-json/df-agent/v1/mcp": {
      "get": {
        "summary": "Read public DroneFactory.ch MCP discovery summary",
        "operationId": "getDroneFactoryMcpSummary",
        "responses": {
          "200": {
            "description": "MCP endpoint summary with tools and related REST URLs"
          }
        }
      },
      "post": {
        "summary": "Public read-only MCP JSON-RPC endpoint for product search, product lookup and category browsing",
        "operationId": "postDroneFactoryMcp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CartHandoffRequest": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CartHandoffRequestItem"
            }
          },
          "line_items": {
            "type": "array",
            "description": "UCP-style alias for items.",
            "items": {
              "$ref": "#/components/schemas/CartHandoffRequestItem"
            }
          }
        }
      },
      "CartHandoffRequestItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "product_id": {
            "type": "integer"
          },
          "sku": {
            "type": "string"
          },
          "gtin": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99,
            "default": 1
          },
          "item": {
            "type": "object",
            "description": "UCP-style nested item object. It can contain id, sku, gtin or url."
          }
        }
      },
      "CartHandoff": {
        "type": "object",
        "properties": {
          "ucp": {
            "type": "object"
          },
          "id": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "const": "CHF"
          },
          "line_items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "totals": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "continue_url": {
            "type": "string",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "sku": {
            "type": "string"
          },
          "price": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "const": "CHF"
          },
          "stock_status": {
            "type": "string"
          },
          "is_in_stock": {
            "type": "boolean"
          },
          "is_on_backorder": {
            "type": "boolean"
          },
          "availability": {
            "type": "string",
            "format": "uri"
          },
          "brand": {
            "type": "string"
          },
          "gtin": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          },
          "image": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "Category": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "count": {
            "type": "integer"
          }
        }
      }
    }
  }
}
