{
  "openapi": "3.1.0",
  "info": {
    "title": "VenueGain AI POS API",
    "version": "1.0.0",
    "description": "Venue-specific bearer keys; complete snapshots, 10\u201320000 rows and 8 MB per import. 60 requests and 5 imports per key per minute. Keys expire after 90 days."
  },
  "servers": [
    {
      "url": "https://venuegainai.com/api/v1"
    }
  ],
  "security": [
    {
      "venueKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "venueKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "vg_pos_<64 lowercase hex characters>"
      }
    },
    "schemas": {
      "SalesReport": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "externalReportId",
          "currency",
          "rows"
        ],
        "properties": {
          "externalReportId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD",
              "THB",
              "EUR",
              "GBP",
              "SGD",
              "AUD"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "default": "POS API import"
          },
          "rows": {
            "type": "array",
            "minItems": 10,
            "maxItems": 20000,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "lineId",
                "date",
                "item",
                "netSales"
              ],
              "properties": {
                "lineId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 120
                },
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "item": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 150
                },
                "netSales": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1000000000
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1000000,
                  "default": 1
                },
                "lineCost": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "minimum": 0,
                  "maximum": 1000000000
                },
                "time": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "pattern": "^(?:[01][0-9]|2[0-3]):[0-5][0-9]$"
                },
                "orderId": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "minLength": 1,
                  "maxLength": 120
                },
                "category": {
                  "type": "string",
                  "enum": [
                    "Food",
                    "Beverage",
                    "Unclassified"
                  ],
                  "default": "Unclassified"
                }
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/venue": {
      "get": {
        "summary": "Get the key\u2019s venue",
        "responses": {
          "200": {
            "description": "Success or duplicate replay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Report created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Subscription or agreement required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Report not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "External identifier has different payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "415": {
            "description": "Use application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "Invalid sales data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; Retry-After 60",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/reports": {
      "get": {
        "summary": "List reports or get one by id",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success or duplicate replay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Report created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Subscription or agreement required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Report not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "External identifier has different payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "415": {
            "description": "Use application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "Invalid sales data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; Retry-After 60",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Import a complete immutable sales snapshot",
        "description": "externalReportId is unique per venue. Identical retry returns the existing report; changed payload returns 409. No transaction append or cross-snapshot line deduplication. The report must have positive total sales and cover at most one year. lineId must be unique within each snapshot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesReport"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success or duplicate replay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Report created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Subscription or agreement required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Report not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "External identifier has different payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "415": {
            "description": "Use application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "Invalid sales data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; Retry-After 60",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}
