{
  "components": {
    "responses": {
      "BadRequest": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Invalid request payload or query parameters."
      },
      "Forbidden": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Caller lacks Admin role, warehouse access, or required ScannerPermissions."
      },
      "InternalError": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Unexpected server error."
      },
      "NotFound": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Requested resource does not exist in the caller's tenant workspace."
      },
      "Unauthorized": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Missing, expired, revoked, or invalid Bearer token."
      }
    },
    "schemas": {
      "AccountMember": {
        "properties": {
          "all_warehouses": {
            "type": "boolean"
          },
          "email": {
            "format": "email",
            "type": "string"
          },
          "full_name": {
            "type": "string"
          },
          "role": {
            "enum": [
              "admin",
              "standard"
            ],
            "type": "string"
          },
          "user_group_id": {
            "format": "int64",
            "type": "integer"
          },
          "user_group_name": {
            "type": "string"
          },
          "user_id": {
            "format": "int64",
            "type": "integer"
          },
          "warehouse_id": {
            "format": "int64",
            "type": "integer"
          },
          "warehouse_ids": {
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "warehouse_name": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Batch": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "doc_number": {
            "example": "PO-2026-0001",
            "type": "string"
          },
          "doc_type": {
            "enum": [
              "purchase_order",
              "goods_in"
            ],
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "line_count": {
            "type": "integer"
          },
          "lines": {
            "items": {
              "$ref": "#/components/schemas/BatchLine"
            },
            "type": "array"
          },
          "notes": {
            "type": "string"
          },
          "posted_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "price_type": {
            "enum": [
              "cost",
              "sales"
            ],
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "status": {
            "enum": [
              "draft",
              "submitted",
              "posted",
              "cancelled"
            ],
            "type": "string"
          },
          "supplier": {
            "type": "string"
          },
          "supplier_id": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "total_amt": {
            "format": "double",
            "type": "number"
          },
          "total_qty": {
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "warehouse_id": {
            "format": "int64",
            "type": "integer"
          },
          "warehouse_name": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "BatchLine": {
        "properties": {
          "barcode": {
            "type": "string"
          },
          "document_id": {
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "line_total": {
            "format": "double",
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "product_id": {
            "type": "string"
          },
          "product_pk": {
            "format": "int64",
            "type": "integer"
          },
          "qty": {
            "type": "integer"
          },
          "unit": {
            "type": "string"
          },
          "unit_price": {
            "format": "double",
            "type": "number"
          }
        },
        "type": "object"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "example": "unauthorized",
            "type": "string"
          },
          "message": {
            "example": "Missing or invalid Bearer token",
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "InventoryCount": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "applied_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "count_number": {
            "example": "CNT-2026-0001",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "line_count": {
            "type": "integer"
          },
          "lines": {
            "items": {
              "$ref": "#/components/schemas/InventoryCountLine"
            },
            "type": "array"
          },
          "location": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "status": {
            "enum": [
              "open",
              "applied",
              "cancelled"
            ],
            "type": "string"
          },
          "total_counted": {
            "type": "integer"
          },
          "total_variance": {
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "warehouse_id": {
            "format": "int64",
            "type": "integer"
          },
          "warehouse_name": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryCountLine": {
        "properties": {
          "barcode": {
            "type": "string"
          },
          "count_id": {
            "format": "int64",
            "type": "integer"
          },
          "counted_qty": {
            "type": "integer"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "product_id": {
            "type": "string"
          },
          "product_pk": {
            "format": "int64",
            "type": "integer"
          },
          "system_qty": {
            "type": "integer"
          },
          "unit": {
            "type": "string"
          },
          "variance": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Product": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "barcode": {
            "example": "4006381440042",
            "type": "string"
          },
          "category": {
            "example": "Apparel",
            "type": "string"
          },
          "color": {
            "description": "Optional variant color",
            "example": "Navy",
            "type": "string"
          },
          "cost_price": {
            "description": "Omitted when caller lacks `show_cost_price`.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "min_stock": {
            "type": "integer"
          },
          "name": {
            "example": "Cotton Crew T-Shirt",
            "type": "string"
          },
          "product_id": {
            "description": "SKU / internal product code",
            "example": "SKU-2001-NVY-L",
            "type": "string"
          },
          "sell_price": {
            "description": "Omitted when caller lacks `show_sales_price`.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "size": {
            "description": "Optional apparel/variant size",
            "example": "L",
            "type": "string"
          },
          "stock_qty": {
            "description": "Aggregate or scoped stock quantity (omitted when `show_warehouse_stock` is false).",
            "type": [
              "integer",
              "null"
            ]
          },
          "unit": {
            "example": "pcs",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "warehouse_stock": {
            "description": "Stock quantity in the requested warehouse.",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ProductInput": {
        "properties": {
          "barcode": {
            "example": "4006381440042",
            "type": "string"
          },
          "category": {
            "example": "Apparel",
            "type": "string"
          },
          "color": {
            "example": "Navy",
            "type": "string"
          },
          "cost_price": {
            "format": "double",
            "type": "number"
          },
          "min_stock": {
            "default": 0,
            "type": "integer"
          },
          "name": {
            "example": "Cotton Crew T-Shirt",
            "type": "string"
          },
          "product_id": {
            "example": "SKU-2001-NVY-L",
            "type": "string"
          },
          "sell_price": {
            "format": "double",
            "type": "number"
          },
          "size": {
            "example": "L",
            "type": "string"
          },
          "unit": {
            "default": "pcs",
            "type": "string"
          }
        },
        "required": [
          "product_id",
          "name"
        ],
        "type": "object"
      },
      "ProductLookupResponse": {
        "properties": {
          "product": {
            "$ref": "#/components/schemas/Product"
          },
          "variants": {
            "items": {
              "$ref": "#/components/schemas/Product"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "ProductPrice": {
        "properties": {
          "amount": {
            "format": "double",
            "type": "number"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "price_type": {
            "enum": [
              "sales",
              "cost"
            ],
            "type": "string"
          },
          "product_id": {
            "type": "string"
          },
          "product_pk": {
            "format": "int64",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "Supplier": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "address": {
            "type": "string"
          },
          "code": {
            "example": "SUP-ACME",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "example": "Acme Apparel Supply",
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupplierInput": {
        "properties": {
          "address": {
            "type": "string"
          },
          "code": {
            "example": "SUP-ACME",
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "name": {
            "example": "Acme Apparel Supply",
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "name"
        ],
        "type": "object"
      },
      "UserGroup": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "can_goods_in": {
            "type": "boolean"
          },
          "can_price_check": {
            "type": "boolean"
          },
          "can_purchase_order": {
            "type": "boolean"
          },
          "can_stock_take": {
            "type": "boolean"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "is_default": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "show_cost_price": {
            "type": "boolean"
          },
          "show_sales_price": {
            "type": "boolean"
          },
          "show_warehouse_stock": {
            "type": "boolean"
          },
          "user_count": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "UserGroupInput": {
        "properties": {
          "can_goods_in": {
            "type": "boolean"
          },
          "can_price_check": {
            "type": "boolean"
          },
          "can_purchase_order": {
            "type": "boolean"
          },
          "can_stock_take": {
            "type": "boolean"
          },
          "name": {
            "example": "Sales Floor Associates",
            "type": "string"
          },
          "show_cost_price": {
            "type": "boolean"
          },
          "show_sales_price": {
            "type": "boolean"
          },
          "show_warehouse_stock": {
            "type": "boolean"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "Warehouse": {
        "properties": {
          "account_id": {
            "format": "int64",
            "type": "integer"
          },
          "address": {
            "type": "string"
          },
          "code": {
            "example": "WH-MAIN",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "is_default": {
            "type": "boolean"
          },
          "name": {
            "example": "Main Warehouse",
            "type": "string"
          },
          "product_count": {
            "type": "integer"
          },
          "total_stock": {
            "type": "integer"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "ss_live_... API Key or OAuth 2.1 Access Token",
        "description": "Pass a workspace API Key (`ss_live_...` generated in Control Panel -\u003e Settings -\u003e API Keys) or an OAuth 2.1 access token in `Authorization: Bearer \u003ctoken\u003e`.",
        "scheme": "bearer",
        "type": "http"
      },
      "oauth2": {
        "description": "Built-in OAuth 2.1 Authorization Server with PKCE (S256) and Dynamic Client Registration.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://stockslip.app/oauth/authorize",
            "scopes": {
              "mcp:tools": "Invoke StockSlip MCP tools within the chosen workspace",
              "read": "Read catalog, stock, batches, counts, warehouses, and suppliers",
              "write": "Create and mutate products, batches, counts, and (for admins) settings"
            },
            "tokenUrl": "https://stockslip.app/oauth/token"
          }
        },
        "type": "oauth2"
      }
    }
  },
  "info": {
    "contact": {
      "name": "StockSlip Developer Portal",
      "url": "https://stockslip.app/docs"
    },
    "description": "Multi-tenant REST API for StockSlip inventory management, barcode scanning batches (Purchase Orders \u0026 Goods In), Inventory Counts, Products \u0026 Size/Color Variants, Prices, Warehouses, Suppliers, Users, and User Groups. Authenticate with a workspace API Key (`ss_live_...`) or an OAuth 2.1 access token via `Authorization: Bearer \u003ctoken\u003e`. All endpoints enforce tenant isolation, role permissions (`admin` vs `standard`), warehouse scoping, and user-group price visibility.",
    "title": "StockSlip Inventory SaaS API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/v1/batches": {
      "get": {
        "operationId": "listBatches",
        "parameters": [
          {
            "description": "Filter by document type: `purchase_order` or `goods_in`.",
            "in": "query",
            "name": "doc_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by warehouse ID (must be within caller's allowed warehouses).",
            "in": "query",
            "name": "warehouse_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "batches": {
                      "items": {
                        "$ref": "#/components/schemas/Batch"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "List of batches scoped to the caller's tenant and allowed warehouses."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List scanned document batches (Purchase Orders \u0026 Goods In)",
        "tags": [
          "Batches"
        ]
      },
      "post": {
        "operationId": "createBatch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "doc_type": {
                    "enum": [
                      "purchase_order",
                      "goods_in"
                    ],
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "price_type": {
                    "default": "cost",
                    "enum": [
                      "cost",
                      "sales"
                    ],
                    "type": "string"
                  },
                  "reference": {
                    "type": "string"
                  },
                  "supplier": {
                    "description": "Supplier name (optional if supplier_id is supplied).",
                    "type": "string"
                  },
                  "supplier_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "warehouse_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "doc_type"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Draft batch created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create a draft Purchase Order or Goods In batch",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/batches/{id}": {
      "get": {
        "operationId": "getBatch",
        "parameters": [
          {
            "description": "Batch document ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Batch with line items."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Get batch details including scanned lines",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/batches/{id}/lines/{lineId}": {
      "put": {
        "operationId": "updateBatchLine",
        "parameters": [
          {
            "description": "Batch document ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "Batch line ID.",
            "in": "path",
            "name": "lineId",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "qty": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "qty"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Updated batch."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update quantity for a batch line (0 removes the line)",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/batches/{id}/post": {
      "post": {
        "operationId": "postGoodsIn",
        "parameters": [
          {
            "description": "Goods In batch ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Goods In batch marked as `posted` and warehouse stock incremented."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Post a Goods In batch and increment warehouse stock",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/batches/{id}/scan": {
      "post": {
        "operationId": "scanBatchItem",
        "parameters": [
          {
            "description": "Batch document ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "description": "Product barcode or SKU (`product_id`).",
                    "type": "string"
                  },
                  "qty": {
                    "default": 1,
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Updated batch after scan."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Scan or add a product barcode/SKU into a draft batch",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/batches/{id}/submit": {
      "post": {
        "operationId": "submitPurchaseOrder",
        "parameters": [
          {
            "description": "Purchase Order batch ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            },
            "description": "Purchase Order marked as `submitted`."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Submit a draft Purchase Order",
        "tags": [
          "Batches"
        ]
      }
    },
    "/api/v1/counts": {
      "get": {
        "operationId": "listCounts",
        "parameters": [
          {
            "description": "Filter by warehouse ID.",
            "in": "query",
            "name": "warehouse_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "counts": {
                      "items": {
                        "$ref": "#/components/schemas/InventoryCount"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "List of inventory counts."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List inventory count sessions",
        "tags": [
          "Counts"
        ]
      },
      "post": {
        "operationId": "createCount",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "location": {
                    "description": "Aisle, zone, or bin label.",
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "warehouse_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryCount"
                }
              }
            },
            "description": "Open inventory count created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create an open inventory count session",
        "tags": [
          "Counts"
        ]
      }
    },
    "/api/v1/counts/{id}": {
      "get": {
        "operationId": "getCount",
        "parameters": [
          {
            "description": "Inventory count ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryCount"
                }
              }
            },
            "description": "Inventory count with lines."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Get inventory count details including counted lines and variance",
        "tags": [
          "Counts"
        ]
      }
    },
    "/api/v1/counts/{id}/apply": {
      "post": {
        "operationId": "applyCount",
        "parameters": [
          {
            "description": "Inventory count ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryCount"
                }
              }
            },
            "description": "Inventory count applied and warehouse stock reconciled."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Finalize and apply an inventory count to warehouse stock",
        "tags": [
          "Counts"
        ]
      }
    },
    "/api/v1/counts/{id}/lines/{lineId}": {
      "put": {
        "operationId": "updateCountLine",
        "parameters": [
          {
            "description": "Inventory count ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "Inventory count line ID.",
            "in": "path",
            "name": "lineId",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "counted_qty": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "counted_qty"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryCount"
                }
              }
            },
            "description": "Updated inventory count."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Set counted quantity on an inventory count line",
        "tags": [
          "Counts"
        ]
      }
    },
    "/api/v1/counts/{id}/scan": {
      "post": {
        "operationId": "scanCountItem",
        "parameters": [
          {
            "description": "Inventory count ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "description": "Product barcode or SKU.",
                    "type": "string"
                  },
                  "qty": {
                    "default": 1,
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryCount"
                }
              }
            },
            "description": "Updated inventory count."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Scan a barcode/SKU into an open inventory count",
        "tags": [
          "Counts"
        ]
      }
    },
    "/api/v1/products": {
      "get": {
        "operationId": "listProducts",
        "parameters": [
          {
            "description": "Search query matching product name, SKU, barcode, size, or color.",
            "in": "query",
            "name": "q",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Warehouse ID for per-warehouse stock figures.",
            "in": "query",
            "name": "warehouse_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "products": {
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "List of products (price/stock fields filtered by ScannerPermissions)."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List or search products in the tenant catalog",
        "tags": [
          "Products"
        ]
      },
      "post": {
        "operationId": "createProduct",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            },
            "description": "Product created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create a product (including optional size \u0026 color variant attributes)",
        "tags": [
          "Products"
        ]
      }
    },
    "/api/v1/products/lookup": {
      "get": {
        "operationId": "lookupProduct",
        "parameters": [
          {
            "description": "Exact barcode or SKU (`product_id`).",
            "in": "query",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Warehouse ID to scope stock quantities.",
            "in": "query",
            "name": "warehouse_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductLookupResponse"
                }
              }
            },
            "description": "Matched product and sibling size/color variants."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Look up a product by barcode or SKU, including sibling size \u0026 color variants",
        "tags": [
          "Products"
        ]
      }
    },
    "/api/v1/products/{id}": {
      "delete": {
        "operationId": "deleteProduct",
        "parameters": [
          {
            "description": "Product primary key ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Product deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Delete a product (Admin only)",
        "tags": [
          "Products"
        ]
      },
      "put": {
        "operationId": "updateProduct",
        "parameters": [
          {
            "description": "Product primary key ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            },
            "description": "Updated product."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update an existing product",
        "tags": [
          "Products"
        ]
      }
    },
    "/api/v1/products/{id}/prices": {
      "get": {
        "operationId": "getProductPrices",
        "parameters": [
          {
            "description": "Product primary key ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "prices": {
                      "items": {
                        "$ref": "#/components/schemas/ProductPrice"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Product prices filtered by caller's ScannerPermissions."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Get sales and cost prices for a product",
        "tags": [
          "Products"
        ]
      }
    },
    "/api/v1/products/{id}/prices/{priceType}": {
      "put": {
        "operationId": "upsertProductPrice",
        "parameters": [
          {
            "description": "Product primary key ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "Price type: `sales` or `cost`.",
            "in": "path",
            "name": "priceType",
            "required": true,
            "schema": {
              "enum": [
                "sales",
                "cost"
              ],
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "format": "double",
                    "minimum": 0,
                    "type": "number"
                  }
                },
                "required": [
                  "amount"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductPrice"
                }
              }
            },
            "description": "Updated product price."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Upsert sales or cost price for a product (Admin only)",
        "tags": [
          "Products"
        ]
      }
    },
    "/api/v1/suppliers": {
      "get": {
        "operationId": "listSuppliers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "suppliers": {
                      "items": {
                        "$ref": "#/components/schemas/Supplier"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "List of suppliers."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List suppliers in the tenant workspace",
        "tags": [
          "Suppliers"
        ]
      },
      "post": {
        "operationId": "createSupplier",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            },
            "description": "Supplier created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create a supplier (Admin only)",
        "tags": [
          "Suppliers"
        ]
      }
    },
    "/api/v1/suppliers/{id}": {
      "delete": {
        "operationId": "deleteSupplier",
        "parameters": [
          {
            "description": "Supplier ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Supplier deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Delete a supplier (Admin only)",
        "tags": [
          "Suppliers"
        ]
      },
      "put": {
        "operationId": "updateSupplier",
        "parameters": [
          {
            "description": "Supplier ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            },
            "description": "Updated supplier."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update a supplier (Admin only)",
        "tags": [
          "Suppliers"
        ]
      }
    },
    "/api/v1/user-groups": {
      "get": {
        "operationId": "listUserGroups",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "user_groups": {
                      "items": {
                        "$ref": "#/components/schemas/UserGroup"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "List of user groups."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List user groups and scanner permissions (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      },
      "post": {
        "operationId": "createUserGroup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserGroupInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserGroup"
                }
              }
            },
            "description": "User group created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create a user group (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      }
    },
    "/api/v1/user-groups/{id}": {
      "delete": {
        "operationId": "deleteUserGroup",
        "parameters": [
          {
            "description": "User Group ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "User group deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Delete a non-default user group (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      },
      "put": {
        "operationId": "updateUserGroup",
        "parameters": [
          {
            "description": "User Group ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserGroupInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserGroup"
                }
              }
            },
            "description": "Updated user group."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update a user group's permissions (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      }
    },
    "/api/v1/users": {
      "get": {
        "operationId": "listUsers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "users": {
                      "items": {
                        "$ref": "#/components/schemas/AccountMember"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tenant members with role, warehouse scope, and user group."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List tenant workspace users (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      },
      "post": {
        "operationId": "createUser",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "all_warehouses": {
                    "type": "boolean"
                  },
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "full_name": {
                    "type": "string"
                  },
                  "password": {
                    "minLength": 8,
                    "type": "string"
                  },
                  "role": {
                    "enum": [
                      "admin",
                      "standard"
                    ],
                    "type": "string"
                  },
                  "user_group_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "warehouse_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "warehouse_ids": {
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "email",
                  "full_name",
                  "role"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountMember"
                }
              }
            },
            "description": "User added to workspace."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create or add a user to the tenant workspace (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      }
    },
    "/api/v1/users/{id}": {
      "delete": {
        "operationId": "deleteUser",
        "parameters": [
          {
            "description": "User ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "User removed from workspace."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Remove a user from the tenant workspace (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      },
      "put": {
        "operationId": "updateUser",
        "parameters": [
          {
            "description": "User ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "all_warehouses": {
                    "type": "boolean"
                  },
                  "role": {
                    "enum": [
                      "admin",
                      "standard"
                    ],
                    "type": "string"
                  },
                  "user_group_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "warehouse_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "warehouse_ids": {
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountMember"
                }
              }
            },
            "description": "Updated tenant member."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update a tenant member's role, warehouses, or user group (Admin only)",
        "tags": [
          "Users \u0026 Groups"
        ]
      }
    },
    "/api/v1/warehouses": {
      "get": {
        "operationId": "listWarehouses",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "warehouses": {
                      "items": {
                        "$ref": "#/components/schemas/Warehouse"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Accessible warehouses."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "List warehouses accessible to the authenticated identity",
        "tags": [
          "Warehouses"
        ]
      },
      "post": {
        "operationId": "createWarehouse",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "address": {
                    "type": "string"
                  },
                  "code": {
                    "example": "WH-EAST",
                    "type": "string"
                  },
                  "name": {
                    "example": "East Distribution",
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "name"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Warehouse"
                }
              }
            },
            "description": "Warehouse created."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Create a warehouse (Admin only)",
        "tags": [
          "Warehouses"
        ]
      }
    },
    "/api/v1/warehouses/{id}": {
      "delete": {
        "operationId": "deleteWarehouse",
        "parameters": [
          {
            "description": "Warehouse ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Warehouse deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Delete a non-default warehouse (Admin only)",
        "tags": [
          "Warehouses"
        ]
      },
      "put": {
        "operationId": "updateWarehouse",
        "parameters": [
          {
            "description": "Warehouse ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "address": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Warehouse"
                }
              }
            },
            "description": "Updated warehouse."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "summary": "Update a warehouse (Admin only)",
        "tags": [
          "Warehouses"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    },
    {
      "oauth2": [
        "read",
        "write"
      ]
    }
  ],
  "servers": [
    {
      "description": "Current StockSlip instance",
      "url": "https://stockslip.app"
    }
  ],
  "tags": [
    {
      "description": "Purchase Orders (`purchase_order`) and Goods In (`goods_in`) scanned document batches.",
      "name": "Batches"
    },
    {
      "description": "Stock-take inventory count sessions, scanning, and stock reconciliation.",
      "name": "Counts"
    },
    {
      "description": "Product catalog CRUD, barcode/SKU lookup with size \u0026 color variants, and pricing.",
      "name": "Products"
    },
    {
      "description": "Multi-warehouse locations and stock scopes.",
      "name": "Warehouses"
    },
    {
      "description": "Supplier directory for Purchase Orders and Goods In.",
      "name": "Suppliers"
    },
    {
      "description": "Admin-only tenant member management and scanner permission groups.",
      "name": "Users \u0026 Groups"
    }
  ]
}
