{
    "openapi": "3.0.3",
    "info": {
        "title": "Logical Menu — POS Integration API",
        "version": "1.1.0",
        "description": "Endpoints the POS provider uses to push menu data into Logical Menu Admin, and to read back the last push for a store.\n\n**Authentication — push** (`POST /api/menus`): Bearer token (Laravel Sanctum). Generate one in the admin UI at `/admin/api-tokens` and include it as `Authorization: Bearer <token>`.\n\n**Authentication — read** (`GET /api/menus/{storeId}`): a read-only API key sent as `X-API-Key: <key>`. Read keys are issued by the Hebs team and can only read; they cannot push or change menus.\n\n**Idempotency**: Menus are identified by `external_source`. Categories by `external_id`, items/options/values by `external_data`. Rerunning the same payload is safe — rows not present in the payload are removed."
    },
    "servers": [
        {
            "url": "https://dev.hebskosova.com",
            "description": "Development"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Sanctum personal access token"
            },
            "menuReadKey": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key",
                "description": "Read-only API key for GET /api/menus/{storeId}. Cannot be used to push menus."
            }
        },
        "schemas": {
            "Translation": {
                "type": "object",
                "required": [
                    "lang",
                    "value"
                ],
                "properties": {
                    "lang": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2,
                        "example": "en"
                    },
                    "value": {
                        "type": "string",
                        "example": "Cheeseburger"
                    }
                }
            },
            "ProductInformation": {
                "type": "object",
                "description": "Optional nutritional / regulatory metadata. Each key holds a list of translations.",
                "properties": {
                    "ingredients": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "additives": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "allergens": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "distributor_information": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "country_of_origin": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "conditions_of_use_and_storage": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    }
                }
            },
            "SelectionRange": {
                "type": "object",
                "properties": {
                    "min": {
                        "type": "integer",
                        "example": 0
                    },
                    "max": {
                        "type": "integer",
                        "example": 3
                    }
                }
            },
            "OptionValue": {
                "type": "object",
                "required": [
                    "external_data",
                    "price",
                    "enabled",
                    "name"
                ],
                "properties": {
                    "external_data": {
                        "type": "string",
                        "description": "POS ID for this value",
                        "example": "1373"
                    },
                    "merchant_sku": {
                        "type": "string",
                        "nullable": true,
                        "example": "1373"
                    },
                    "price": {
                        "type": "number",
                        "format": "float",
                        "example": 40.0
                    },
                    "vat_percentage": {
                        "type": "number",
                        "format": "float",
                        "nullable": true,
                        "example": 20.0
                    },
                    "enabled": {
                        "type": "boolean",
                        "example": true
                    },
                    "default": {
                        "type": "boolean",
                        "example": false
                    },
                    "selection_range": {
                        "$ref": "#/components/schemas/SelectionRange"
                    },
                    "name": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "product_information": {
                        "$ref": "#/components/schemas/ProductInformation"
                    }
                }
            },
            "Option": {
                "type": "object",
                "required": [
                    "external_data",
                    "type",
                    "name"
                ],
                "properties": {
                    "external_data": {
                        "type": "string",
                        "example": "19"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "SingleChoice",
                            "MultiChoice"
                        ],
                        "description": "SingleChoice allows exactly one value; MultiChoice allows multiple."
                    },
                    "selection_range": {
                        "$ref": "#/components/schemas/SelectionRange"
                    },
                    "name": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "values": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/OptionValue"
                        }
                    }
                }
            },
            "Item": {
                "type": "object",
                "required": [
                    "external_data",
                    "price",
                    "enabled",
                    "name"
                ],
                "properties": {
                    "external_data": {
                        "type": "string",
                        "description": "POS ID for this item",
                        "example": "#MENU2-135"
                    },
                    "merchant_sku": {
                        "type": "string",
                        "nullable": true
                    },
                    "price": {
                        "type": "number",
                        "format": "float",
                        "example": 530.0
                    },
                    "sales_tax_percentage": {
                        "type": "number",
                        "format": "float",
                        "nullable": true,
                        "example": 20.0
                    },
                    "enabled": {
                        "type": "boolean",
                        "example": true
                    },
                    "image_url": {
                        "type": "string",
                        "nullable": true,
                        "example": "https://.../item.jpg"
                    },
                    "name": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "description": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "delivery_methods": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "example": "homedelivery"
                        },
                        "description": "e.g. homedelivery, takeaway, eatin"
                    },
                    "product_information": {
                        "$ref": "#/components/schemas/ProductInformation"
                    },
                    "options": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Option"
                        }
                    }
                }
            },
            "Category": {
                "type": "object",
                "required": [
                    "id",
                    "name",
                    "items"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Unique identifier for this category within the menu",
                        "example": "MENU"
                    },
                    "name": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Translation"
                        }
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Item"
                        }
                    }
                }
            },
            "MenuPayload": {
                "type": "object",
                "required": [
                    "external_source",
                    "currency",
                    "primary_language",
                    "categories"
                ],
                "properties": {
                    "external_source": {
                        "type": "string",
                        "description": "Stable identifier for the menu (e.g. the venue ID in the POS). Used as the upsert key.",
                        "example": "hebs-venue-1"
                    },
                    "currency": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 3,
                        "example": "ALL"
                    },
                    "primary_language": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2,
                        "example": "en"
                    },
                    "categories": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Category"
                        }
                    }
                }
            },
            "ImportResponse": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean",
                        "example": true
                    },
                    "summary": {
                        "type": "object",
                        "properties": {
                            "menu_id": {
                                "type": "integer",
                                "example": 23
                            },
                            "categories": {
                                "type": "integer",
                                "example": 2
                            },
                            "items": {
                                "type": "integer",
                                "example": 2
                            },
                            "options": {
                                "type": "integer",
                                "example": 2
                            },
                            "values": {
                                "type": "integer",
                                "example": 2
                            }
                        }
                    }
                }
            },
            "ValidationError": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Unauthenticated": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string",
                        "example": "Unauthenticated."
                    }
                }
            },
            "MenuNotFound": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string",
                        "example": "No menu push found for store '999'."
                    },
                    "available_store_ids": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Store IDs that currently have a recorded push.",
                        "example": [
                            "62",
                            "66",
                            "HESBORDERAPP-1"
                        ]
                    }
                }
            }
        }
    },
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "paths": {
        "/api/menus": {
            "post": {
                "summary": "Push a menu from the POS",
                "description": "Upserts the entire menu. Existing categories/items/options/values whose natural key (`external_id` / `external_data`) is **not** present in the payload are **deleted**. The raw request body is stored in `menus.raw_json` for audit.",
                "operationId": "menus.store",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MenuPayload"
                            },
                            "example": {
                                "external_source": "hebs-venue-1",
                                "currency": "ALL",
                                "primary_language": "en",
                                "categories": [
                                    {
                                        "id": "MENU",
                                        "name": [
                                            {
                                                "lang": "en",
                                                "value": "MENU"
                                            }
                                        ],
                                        "items": [
                                            {
                                                "external_data": "#MENU2-135",
                                                "price": 530.0,
                                                "sales_tax_percentage": 20.0,
                                                "enabled": true,
                                                "name": [
                                                    {
                                                        "lang": "en",
                                                        "value": "Home Alone"
                                                    }
                                                ],
                                                "description": [
                                                    {
                                                        "lang": "en",
                                                        "value": "1x Cheese Burger + sides"
                                                    }
                                                ],
                                                "delivery_methods": [
                                                    "homedelivery",
                                                    "takeaway",
                                                    "eatin"
                                                ],
                                                "image_url": "https://example.com/img.jpg",
                                                "product_information": {
                                                    "ingredients": [
                                                        {
                                                            "lang": "en",
                                                            "value": "Tomato, Onion"
                                                        }
                                                    ],
                                                    "allergens": [
                                                        {
                                                            "lang": "en",
                                                            "value": "Contains wheat"
                                                        }
                                                    ]
                                                },
                                                "options": [
                                                    {
                                                        "external_data": "626",
                                                        "type": "SingleChoice",
                                                        "name": [
                                                            {
                                                                "lang": "en",
                                                                "value": "Burger variant"
                                                            }
                                                        ],
                                                        "values": [
                                                            {
                                                                "external_data": "626",
                                                                "price": 0.0,
                                                                "enabled": true,
                                                                "default": true,
                                                                "vat_percentage": 20.0,
                                                                "name": [
                                                                    {
                                                                        "lang": "en",
                                                                        "value": "Cheese Chicken Burger"
                                                                    }
                                                                ]
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Menu imported",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ImportResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer token"
                    },
                    "422": {
                        "description": "Validation failed",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/menus/{storeId}": {
            "get": {
                "summary": "Get the last menu push for a store",
                "description": "Returns the most recent menu that Logical pushed (via `POST /api/menus`) for the given store, **byte for byte exactly as it was received** — the response body is the original request body, never decoded or re-formatted, so its shape is the `MenuPayload` schema.\n\nEvery new push replaces the previous one, so this always reflects the latest push.\n\n**Caching**: the response carries an `ETag`. Send it back in `If-None-Match` and you get `304 Not Modified` with an empty body while the menu is unchanged — a cheap way to poll for new pushes.\n\n**Note**: if a menu's raw JSON is edited by hand in the admin panel, that edited version is returned until Logical's next push.",
                "operationId": "getMenuByStore",
                "security": [
                    {
                        "menuReadKey": []
                    }
                ],
                "parameters": [
                    {
                        "name": "storeId",
                        "in": "path",
                        "required": true,
                        "description": "The store's `external_source` as used by Logical (e.g. `66` Çagllavicë, `62` Mitrovica e Jugut, `HESBORDERAPP-1` test venue).",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9._-]+$",
                            "example": "62"
                        }
                    },
                    {
                        "name": "If-None-Match",
                        "in": "header",
                        "required": false,
                        "description": "The `ETag` from a previous response. If the menu is unchanged the server replies `304` with an empty body.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The last push for the store, exactly as Logical sent it.",
                        "headers": {
                            "ETag": {
                                "description": "Fingerprint of this exact push. Changes whenever a new push differs.",
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "Last-Modified": {
                                "description": "When the stored menu was last updated (normally the time of the last push).",
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "Cache-Control": {
                                "description": "`no-cache, private` — always revalidated, never stored by shared caches.",
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MenuPayload"
                                }
                            }
                        }
                    },
                    "304": {
                        "description": "Not modified — the `If-None-Match` ETag still matches the last push. Empty body."
                    },
                    "401": {
                        "description": "Missing or invalid X-API-Key",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Unauthenticated"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No push has been recorded for this store. The body lists the store IDs that do have one.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MenuNotFound"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
