{
  "openapi": "3.0.3",
  "info": {
    "title": "SPACE Developer API",
    "version": "1.0.0-alpha.2",
    "description": "Private Alpha. Business-scoped, read-only synchronization for menus, orders and reservations. Existing menu endpoints remain unchanged."
  },
  "servers": [
    {
      "url": "https://space.techgamesitalia.it"
    }
  ],
  "components": {
    "securitySchemes": {
      "SpaceApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-SPACE-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "UpdatedAfter": {
        "name": "updated_after",
        "in": "query",
        "required": false,
        "description": "ISO-8601 timestamp.",
        "schema": {
          "type": "string",
          "format": "date-time"
        }
      },
      "EntityId": {
        "name": "id",
        "in": "query",
        "required": true,
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      },
      "OrderCode": {
        "name": "code",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "OrderSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "channel": {
            "type": "string",
            "enum": [
              "takeaway",
              "table"
            ]
          },
          "status": {
            "type": "string"
          },
          "customer": {
            "type": "object"
          },
          "service": {
            "type": "object"
          },
          "payment": {
            "type": "object"
          },
          "totals": {
            "type": "object"
          },
          "changed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ReservationSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "customer": {
            "type": "object"
          },
          "schedule": {
            "type": "object"
          },
          "table_assignment": {
            "type": [
              "object",
              "null"
            ]
          },
          "changed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "security": [
    {
      "SpaceApiKey": []
    },
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/api/integrations/v1/whoami.php": {
      "get": {
        "summary": "Current API key identity and capability",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    },
    "/api/integrations/v1/menus/manifest.php": {
      "get": {
        "summary": "Lightweight menu version manifest",
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "No source menu"
          }
        }
      }
    },
    "/api/integrations/v1/menus/current.php": {
      "get": {
        "summary": "Full current source menu",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full menu document"
          },
          "304": {
            "description": "Menu unchanged"
          },
          "404": {
            "description": "No source menu"
          }
        }
      }
    },
    "/api/integrations/v1/orders/index.php": {
      "get": {
        "summary": "List business orders",
        "description": "Requires orders.read. Read-only. Customer and operational data are returned.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/UpdatedAfter"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV: pending,confirmed,preparing,ready,completed,cancelled,rejected,no_show."
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV: takeaway,table."
          }
        ],
        "responses": {
          "200": {
            "description": "Paginazione ordini",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Missing orders.read scope"
          }
        }
      }
    },
    "/api/integrations/v1/orders/view.php": {
      "get": {
        "summary": "Get a complete order",
        "description": "Requires orders.read. Use id or code, not both.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/OrderCode"
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order with items and modifiers"
          },
          "304": {
            "description": "Order unchanged"
          },
          "404": {
            "description": "Order not found"
          }
        }
      }
    },
    "/api/integrations/v1/reservations/index.php": {
      "get": {
        "summary": "List business reservations",
        "description": "Requires reservations.read. Read-only. Customer and operational data are returned.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/UpdatedAfter"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV: pending,confirmed,cancelled,rejected,completed,no_show."
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginazione prenotazioni"
          },
          "403": {
            "description": "Missing reservations.read scope"
          }
        }
      }
    },
    "/api/integrations/v1/reservations/view.php": {
      "get": {
        "summary": "Get a complete reservation",
        "description": "Requires reservations.read.",
        "parameters": [
          {
            "$ref": "#/components/parameters/EntityId"
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reservation with current table assignment"
          },
          "304": {
            "description": "Reservation unchanged"
          },
          "404": {
            "description": "Reservation not found"
          }
        }
      }
    }
  }
}
