{
  "openapi": "3.1.0",
  "info": {
    "title": "MotherStock API",
    "description": "Read your MotherStock products, stock, units (serials), orders and returns from your own systems. Every call needs an API key made by an Admin on Settings > API keys, sent as `Authorization: Bearer ms_live_...`. A key sees only its own company's data, and only what its scopes allow. Lists are oldest change first; poll with `updated_since` and follow `nextCursor`.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://api.motherstock.app/v1"
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "tags": [
          "Key"
        ],
        "summary": "Key Me",
        "operationId": "key_me_me_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Key Me Me Get"
                }
              }
            }
          }
        },
        "x-scopes": []
      }
    },
    "/token": {
      "get": {
        "tags": [
          "Key"
        ],
        "summary": "Token Check",
        "description": "Is this token live? The MCP server asks before serving an AI app connection, so an\nexpired one gets HTTP 401 and the app refreshes it (AI assistant plan PR 13). Not counted\nas a call.",
        "operationId": "token_check_token_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Token Check Token Get"
                }
              }
            }
          }
        },
        "x-scopes": []
      }
    },
    "/products": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "List Products",
        "operationId": "list_products_products_get",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "description": "Rows per page, 1 to 200.",
              "default": 50,
              "title": "Limit"
            },
            "description": "Rows per page, 1 to 200."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "`nextCursor` from the previous page.",
              "title": "Cursor"
            },
            "description": "`nextCursor` from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late.",
              "title": "Updated Since"
            },
            "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late."
          },
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exact SKU.",
              "title": "Sku"
            },
            "description": "Exact SKU."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "description": "SKU or name contains this text (any case).",
              "title": "Q"
            },
            "description": "SKU or name contains this text (any case)."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Product_"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "catalog:read"
        ]
      }
    },
    "/products/{product_id}": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "Get Product",
        "operationId": "get_product_products__product_id__get",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Product Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "catalog:read"
        ]
      }
    },
    "/brands": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "List Brands",
        "operationId": "list_brands_brands_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Brand"
                  },
                  "type": "array",
                  "title": "Response List Brands Brands Get"
                }
              }
            }
          }
        },
        "x-scopes": [
          "catalog:read"
        ]
      }
    },
    "/types": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "List Types",
        "operationId": "list_types_types_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ProductType"
                  },
                  "type": "array",
                  "title": "Response List Types Types Get"
                }
              }
            }
          }
        },
        "x-scopes": [
          "catalog:read"
        ]
      }
    },
    "/stock": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "List Stock",
        "description": "Units on hand per product: in stock and not reserved by an open order.",
        "operationId": "list_stock_stock_get",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "description": "Rows per page, 1 to 200.",
              "default": 50,
              "title": "Limit"
            },
            "description": "Rows per page, 1 to 200."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "`nextCursor` from the previous page.",
              "title": "Cursor"
            },
            "description": "`nextCursor` from the previous page."
          },
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exact SKU.",
              "title": "Sku"
            },
            "description": "Exact SKU."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_StockRow_"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:read"
        ]
      }
    },
    "/stock/low": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "List Low Stock",
        "description": "Products down to their low-stock level, fewest first, with days of cover (as on Reports >\nLow stock). Nobody's \"dismiss\" applies here: a key belongs to the company, not a person.",
        "operationId": "list_low_stock_stock_low_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LowStock"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:read"
        ]
      }
    },
    "/units": {
      "get": {
        "tags": [
          "Units"
        ],
        "summary": "List Units",
        "operationId": "list_units_units_get",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "description": "Rows per page, 1 to 200.",
              "default": 50,
              "title": "Limit"
            },
            "description": "Rows per page, 1 to 200."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "`nextCursor` from the previous page.",
              "title": "Cursor"
            },
            "description": "`nextCursor` from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late.",
              "title": "Updated Since"
            },
            "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late."
          },
          {
            "name": "productId",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 50
                },
                {
                  "type": "null"
                }
              ],
              "title": "Productid"
            }
          },
          {
            "name": "serial",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exact serial or IMEI.",
              "title": "Serial"
            },
            "description": "Exact serial or IMEI."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "in_stock",
                "sold",
                "deleted",
                "all"
              ],
              "type": "string",
              "default": "all",
              "title": "Status"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Unit_"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:read"
        ]
      },
      "post": {
        "tags": [
          "Writes"
        ],
        "summary": "Add Units",
        "description": "Add serials to one product, all or none: any bad row refuses the call and lists every problem.",
        "operationId": "add_units_units_post",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddUnits"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddUnitsResult"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:write"
        ]
      }
    },
    "/units/{unit_id}": {
      "get": {
        "tags": [
          "Units"
        ],
        "summary": "Get Unit",
        "operationId": "get_unit_units__unit_id__get",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unit"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:read"
        ]
      },
      "patch": {
        "tags": [
          "Writes"
        ],
        "summary": "Change Unit",
        "description": "Change bin, condition and (with costs:write) cost. Fields left out stay as they are.",
        "operationId": "change_unit_units__unit_id__patch",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnitChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unit"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:write"
        ]
      },
      "delete": {
        "tags": [
          "Writes"
        ],
        "summary": "Delete Unit",
        "description": "The app's soft delete. Sold units stay on their order. The API can't undo a delete.",
        "operationId": "delete_unit_units__unit_id__delete",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unit"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:delete"
        ]
      }
    },
    "/units/{unit_id}/history": {
      "get": {
        "tags": [
          "Units"
        ],
        "summary": "Get Unit History",
        "description": "The unit and what happened to it, newest first. No people's names or emails; changed\nfields only (never the old or new values), and cost changes only with costs:read.",
        "operationId": "get_unit_history_units__unit_id__history_get",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnitHistory"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:read"
        ]
      }
    },
    "/orders": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "List Orders",
        "operationId": "list_orders_orders_get",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "description": "Rows per page, 1 to 200.",
              "default": 50,
              "title": "Limit"
            },
            "description": "Rows per page, 1 to 200."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "`nextCursor` from the previous page.",
              "title": "Cursor"
            },
            "description": "`nextCursor` from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late.",
              "title": "Updated Since"
            },
            "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 50
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exact status, e.g. pending or completed.",
              "title": "Status"
            },
            "description": "Exact status, e.g. pending or completed."
          },
          {
            "name": "orderNo",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "title": "Orderno"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Order_"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "orders:read"
        ]
      }
    },
    "/orders/recent": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "List Recent Orders",
        "description": "Newest orders first by order date, for questions like \"what sold this week\". For syncing,\npage through GET /orders with updated_since instead.",
        "operationId": "list_recent_orders_orders_recent_get",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 90,
              "minimum": 1,
              "description": "Orders placed in the last this many days.",
              "default": 7,
              "title": "Days"
            },
            "description": "Orders placed in the last this many days."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 50
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exact status, e.g. pending or completed.",
              "title": "Status"
            },
            "description": "Exact status, e.g. pending or completed."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 25,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Order"
                  },
                  "title": "Response List Recent Orders Orders Recent Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "orders:read"
        ]
      }
    },
    "/orders/{order_id}": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "Get Order",
        "operationId": "get_order_orders__order_id__get",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Order Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "orders:read"
        ]
      }
    },
    "/returns": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "List Returns",
        "operationId": "list_returns_returns_get",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "description": "Rows per page, 1 to 200.",
              "default": 50,
              "title": "Limit"
            },
            "description": "Rows per page, 1 to 200."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "`nextCursor` from the previous page.",
              "title": "Cursor"
            },
            "description": "`nextCursor` from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late.",
              "title": "Updated Since"
            },
            "description": "Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Return_"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "returns:read"
        ]
      }
    },
    "/returns/{return_id}": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "Get Return",
        "operationId": "get_return_returns__return_id__get",
        "parameters": [
          {
            "name": "return_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Return Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Return"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "returns:read"
        ]
      }
    },
    "/units/{unit_id}/sold": {
      "post": {
        "tags": [
          "Writes"
        ],
        "summary": "Mark Sold",
        "description": "A unit sold outside the app (e.g. a store the app doesn't pull orders from). A unit on an\norder in the app is sold when that order is packed, so it is refused here.",
        "operationId": "mark_sold_units__unit_id__sold_post",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/MarkSold"
                  },
                  {
                    "type": "null"
                  }
                ],
                "title": "Payload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unit"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:write"
        ]
      }
    },
    "/units/{unit_id}/in-stock": {
      "post": {
        "tags": [
          "Writes"
        ],
        "summary": "Mark In Stock",
        "description": "Undo ``sold``. A unit sold on an order in the app comes back through a return instead.",
        "operationId": "mark_in_stock_units__unit_id__in_stock_post",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unit"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "inventory:write"
        ]
      }
    },
    "/orders/{order_id}/notes": {
      "post": {
        "tags": [
          "Writes"
        ],
        "summary": "Add Order Note",
        "description": "A note on an order line, shown in the app as written by \"API key: name\".",
        "operationId": "add_order_note_orders__order_id__notes_post",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Order Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewOrderNote"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderNote"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "orders:write"
        ]
      }
    },
    "/reports/sales": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Sales Report",
        "description": "Sales & Gross Profit and its breakdowns (Reports > Profit breakdown) for the range.",
        "operationId": "sales_report_reports_sales_get",
        "parameters": [
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "7days",
                "14days",
                "30days",
                "mtd",
                "ytd",
                "all"
              ],
              "type": "string",
              "description": "Date range by order date, as on the screens.",
              "default": "30days",
              "title": "Interval"
            },
            "description": "Date range by order date, as on the screens."
          },
          {
            "name": "rows",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "description": "Rows per section at most.",
              "default": 50,
              "title": "Rows"
            },
            "description": "Rows per section at most."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "profit:read"
        ]
      }
    },
    "/reports/money-losers": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Money Losers",
        "description": "Units sold at a loss, by supplier, model and marketplace, worst first (Reports > Money losers).",
        "operationId": "money_losers_reports_money_losers_get",
        "parameters": [
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "7days",
                "14days",
                "30days",
                "mtd",
                "ytd",
                "all"
              ],
              "type": "string",
              "description": "Date range by order date, as on the screens.",
              "default": "30days",
              "title": "Interval"
            },
            "description": "Date range by order date, as on the screens."
          },
          {
            "name": "rows",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "description": "Rows per section at most.",
              "default": 50,
              "title": "Rows"
            },
            "description": "Rows per section at most."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "profit:read"
        ]
      }
    },
    "/units/{unit_id}/pnl": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Unit Pnl",
        "description": "The unit's Unit P&L for every sale, newest first, as on the unit page.",
        "operationId": "unit_pnl_units__unit_id__pnl_get",
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Unit Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnitPnl"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-scopes": [
          "profit:read"
        ]
      }
    },
    "/reports/buy-list": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Buy List",
        "description": "What to reorder, grouped by the supplier each product last came from, with costs (Reports > Buy list).",
        "operationId": "buy_list_reports_buy_list_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BuyList"
                }
              }
            }
          }
        },
        "x-scopes": [
          "profit:read"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AddUnits": {
        "properties": {
          "productId": {
            "type": "string",
            "maxLength": 50,
            "title": "Productid"
          },
          "units": {
            "items": {
              "$ref": "#/components/schemas/NewUnit"
            },
            "type": "array",
            "maxItems": 500,
            "minItems": 1,
            "title": "Units"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "productId",
          "units"
        ],
        "title": "AddUnits"
      },
      "AddUnitsResult": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Unit"
            },
            "type": "array",
            "title": "Data"
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "AddUnitsResult"
      },
      "Brand": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "Brand"
      },
      "BuyList": {
        "properties": {
          "groups": {
            "items": {
              "$ref": "#/components/schemas/BuyListGroup"
            },
            "type": "array",
            "title": "Groups"
          },
          "coverLookbackDays": {
            "type": "integer",
            "title": "Coverlookbackdays"
          }
        },
        "type": "object",
        "required": [
          "groups",
          "coverLookbackDays"
        ],
        "title": "BuyList"
      },
      "BuyListGroup": {
        "properties": {
          "supplier": {
            "type": "string",
            "title": "Supplier"
          },
          "totalCost": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Totalcost"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/BuyListItem"
            },
            "type": "array",
            "title": "Items"
          }
        },
        "type": "object",
        "required": [
          "supplier",
          "items"
        ],
        "title": "BuyListGroup"
      },
      "BuyListItem": {
        "properties": {
          "productId": {
            "type": "string",
            "title": "Productid"
          },
          "sku": {
            "type": "string",
            "title": "Sku"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "available": {
            "type": "integer",
            "title": "Available"
          },
          "lowStockAt": {
            "type": "integer",
            "title": "Lowstockat"
          },
          "soldRecent": {
            "type": "integer",
            "title": "Soldrecent"
          },
          "daysOfCover": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Daysofcover"
          },
          "suggestedQty": {
            "type": "integer",
            "title": "Suggestedqty"
          },
          "alsoFrom": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Alsofrom"
          },
          "unitCost": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Unitcost"
          },
          "totalCost": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Totalcost"
          },
          "amazon": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amazon",
            "description": "Amazon price check when connected. Never sent to AI assistants."
          }
        },
        "type": "object",
        "required": [
          "productId",
          "sku",
          "name",
          "available",
          "lowStockAt",
          "soldRecent",
          "suggestedQty"
        ],
        "title": "BuyListItem"
      },
      "Buyer": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "address1": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address1"
          },
          "address2": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address2"
          },
          "address3": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address3"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "zip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Zip"
          },
          "country": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Country"
          }
        },
        "type": "object",
        "title": "Buyer"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "LowStock": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/LowStockRow"
            },
            "type": "array",
            "title": "Data"
          },
          "coverLookbackDays": {
            "type": "integer",
            "title": "Coverlookbackdays"
          }
        },
        "type": "object",
        "required": [
          "data",
          "coverLookbackDays"
        ],
        "title": "LowStock"
      },
      "LowStockRow": {
        "properties": {
          "productId": {
            "type": "string",
            "title": "Productid"
          },
          "sku": {
            "type": "string",
            "title": "Sku"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "available": {
            "type": "integer",
            "title": "Available",
            "description": "Units in stock and not reserved by an open order."
          },
          "lowStockAt": {
            "type": "integer",
            "title": "Lowstockat",
            "description": "Flagged low at this many available units or fewer."
          },
          "soldRecent": {
            "type": "integer",
            "title": "Soldrecent",
            "description": "Units sold in the last `coverLookbackDays` days."
          },
          "daysOfCover": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Daysofcover",
            "description": "Days the available units last at the recent rate of sale; null when none sold."
          }
        },
        "type": "object",
        "required": [
          "productId",
          "sku",
          "name",
          "available",
          "lowStockAt",
          "soldRecent"
        ],
        "title": "LowStockRow"
      },
      "MarkSold": {
        "properties": {
          "orderNo": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderno",
            "description": "Where it sold, e.g. a marketplace order number."
          },
          "soldAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Soldat",
            "description": "When it sold, with a time zone. Defaults to now."
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "MarkSold"
      },
      "NewOrderNote": {
        "properties": {
          "note": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 1,
            "title": "Note"
          },
          "lineId": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Lineid",
            "description": "The order line; needed when the order has more than one."
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "note"
        ],
        "title": "NewOrderNote"
      },
      "NewUnit": {
        "properties": {
          "serial": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Serial"
          },
          "bin": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Bin"
          },
          "condition": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Condition",
            "description": "A Condition option's name, e.g. \"A Stock\"."
          },
          "cost": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost",
            "description": "Needs the costs:write scope."
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "serial"
        ],
        "title": "NewUnit"
      },
      "Order": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "orderNo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderno"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "marketplace": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketplace"
          },
          "storeId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Storeid"
          },
          "orderedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderedat"
          },
          "shipBy": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Shipby"
          },
          "deliverBy": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deliverby"
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completedat"
          },
          "cancelledAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cancelledat"
          },
          "total": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Total"
          },
          "currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Currency"
          },
          "trackingNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Trackingnumber"
          },
          "carrier": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Carrier"
          },
          "deliveredAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deliveredat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          },
          "buyer": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Buyer"
              },
              {
                "type": "null"
              }
            ],
            "description": "Only with the orders:read_buyer scope."
          },
          "lines": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/OrderLine"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lines",
            "description": "On GET /orders/{id} only."
          },
          "packages": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/Package"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Packages",
            "description": "On GET /orders/{id} only."
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "updatedAt"
        ],
        "title": "Order"
      },
      "OrderLine": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "sku": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sku"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "qty": {
            "type": "integer",
            "title": "Qty"
          },
          "unitPrice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Unitprice"
          },
          "serials": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Serials",
            "description": "Serials packed on this line."
          },
          "packed": {
            "type": "boolean",
            "title": "Packed"
          },
          "cancelled": {
            "type": "boolean",
            "title": "Cancelled"
          },
          "returned": {
            "type": "boolean",
            "title": "Returned"
          }
        },
        "type": "object",
        "required": [
          "id",
          "qty",
          "packed",
          "cancelled",
          "returned"
        ],
        "title": "OrderLine"
      },
      "OrderNote": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "orderId": {
            "type": "string",
            "title": "Orderid"
          },
          "lineId": {
            "type": "string",
            "title": "Lineid"
          },
          "note": {
            "type": "string",
            "title": "Note"
          },
          "author": {
            "type": "string",
            "title": "Author"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "orderId",
          "lineId",
          "note",
          "author",
          "createdAt"
        ],
        "title": "OrderNote"
      },
      "Package": {
        "properties": {
          "trackingNumber": {
            "type": "string",
            "title": "Trackingnumber"
          },
          "carrier": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Carrier"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "deliveredAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deliveredat"
          }
        },
        "type": "object",
        "required": [
          "trackingNumber"
        ],
        "title": "Package"
      },
      "Page_Order_": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Order"
            },
            "type": "array",
            "title": "Data"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Pass as `cursor` for the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "Page[Order]"
      },
      "Page_Product_": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Product"
            },
            "type": "array",
            "title": "Data"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Pass as `cursor` for the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "Page[Product]"
      },
      "Page_Return_": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Return"
            },
            "type": "array",
            "title": "Data"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Pass as `cursor` for the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "Page[Return]"
      },
      "Page_StockRow_": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/StockRow"
            },
            "type": "array",
            "title": "Data"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Pass as `cursor` for the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "Page[StockRow]"
      },
      "Page_Unit_": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Unit"
            },
            "type": "array",
            "title": "Data"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Pass as `cursor` for the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "Page[Unit]"
      },
      "PnlLine": {
        "properties": {
          "key": {
            "type": "string",
            "title": "Key"
          },
          "label": {
            "type": "string",
            "title": "Label"
          },
          "amount": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amount"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "description": "actual, estimate or missing."
          },
          "note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Note"
          }
        },
        "type": "object",
        "required": [
          "key",
          "label",
          "source"
        ],
        "title": "PnlLine"
      },
      "Product": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "sku": {
            "type": "string",
            "title": "Sku"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "brand": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Brand"
          },
          "type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Type"
          },
          "model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Model"
          },
          "modelNo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Modelno"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "lowStockAt": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lowstockat",
            "description": "Flagged low at this many available units or fewer."
          },
          "onHand": {
            "type": "integer",
            "title": "Onhand",
            "description": "Units in stock and not reserved by an open order."
          },
          "cost": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost",
            "description": "Default cost. Only with the costs:read scope."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "sku",
          "name",
          "status",
          "onHand",
          "updatedAt"
        ],
        "title": "Product"
      },
      "ProductType": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "ProductType"
      },
      "Report": {
        "properties": {
          "title": {
            "type": "string",
            "title": "Title"
          },
          "start": {
            "type": "string",
            "format": "date",
            "title": "Start"
          },
          "end": {
            "type": "string",
            "format": "date",
            "title": "End"
          },
          "cards": {
            "items": {
              "$ref": "#/components/schemas/ReportCard"
            },
            "type": "array",
            "title": "Cards"
          },
          "sections": {
            "items": {
              "$ref": "#/components/schemas/ReportSection"
            },
            "type": "array",
            "title": "Sections"
          },
          "notes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Notes"
          }
        },
        "type": "object",
        "required": [
          "title",
          "start",
          "end",
          "cards",
          "sections"
        ],
        "title": "Report"
      },
      "ReportCard": {
        "properties": {
          "label": {
            "type": "string",
            "title": "Label"
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Value"
          },
          "kind": {
            "type": "string",
            "title": "Kind"
          }
        },
        "type": "object",
        "required": [
          "label",
          "kind"
        ],
        "title": "ReportCard"
      },
      "ReportColumn": {
        "properties": {
          "key": {
            "type": "string",
            "title": "Key"
          },
          "label": {
            "type": "string",
            "title": "Label"
          },
          "kind": {
            "type": "string",
            "title": "Kind"
          }
        },
        "type": "object",
        "required": [
          "key",
          "label",
          "kind"
        ],
        "title": "ReportColumn"
      },
      "ReportSection": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "columns": {
            "items": {
              "$ref": "#/components/schemas/ReportColumn"
            },
            "type": "array",
            "title": "Columns"
          },
          "rows": {
            "items": {
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "type": "object"
            },
            "type": "array",
            "title": "Rows",
            "description": "One object per row, keyed by column key."
          },
          "totalRows": {
            "type": "integer",
            "title": "Totalrows",
            "description": "Rows before the per-section limit."
          },
          "note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Note"
          },
          "takeaway": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Takeaway"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title",
          "columns",
          "rows",
          "totalRows"
        ],
        "title": "ReportSection"
      },
      "Return": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "The order line's id."
          },
          "orderId": {
            "type": "string",
            "title": "Orderid"
          },
          "orderNo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderno"
          },
          "sku": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sku"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "shippedSerials": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Shippedserials"
          },
          "returnedSerial": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Returnedserial"
          },
          "condition": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Condition"
          },
          "returned": {
            "type": "boolean",
            "title": "Returned"
          },
          "returnedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Returnedat"
          },
          "refundedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Refundedat"
          },
          "statusCode": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statuscode",
            "description": "The return status code shown on the Returns page."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "orderId",
          "returned",
          "updatedAt"
        ],
        "title": "Return"
      },
      "StockRow": {
        "properties": {
          "productId": {
            "type": "string",
            "title": "Productid"
          },
          "sku": {
            "type": "string",
            "title": "Sku"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "onHand": {
            "type": "integer",
            "title": "Onhand"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          }
        },
        "type": "object",
        "required": [
          "productId",
          "sku",
          "name",
          "onHand",
          "updatedAt"
        ],
        "title": "StockRow"
      },
      "Unit": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "productId": {
            "type": "string",
            "title": "Productid"
          },
          "serial": {
            "type": "string",
            "title": "Serial"
          },
          "bin": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Bin"
          },
          "condition": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Condition"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "in_stock, sold or deleted."
          },
          "addedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Addedat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          },
          "cost": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost",
            "description": "Unit cost. Only with the costs:read scope."
          }
        },
        "type": "object",
        "required": [
          "id",
          "productId",
          "serial",
          "status",
          "updatedAt"
        ],
        "title": "Unit"
      },
      "UnitChange": {
        "properties": {
          "bin": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Bin",
            "description": "Empty string clears the bin."
          },
          "condition": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Condition",
            "description": "A Condition option's name; empty clears it."
          },
          "cost": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost",
            "description": "Needs the costs:write scope."
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "UnitChange"
      },
      "UnitEvent": {
        "properties": {
          "action": {
            "type": "string",
            "title": "Action",
            "description": "What happened, e.g. imported, sold, returned, restocked, unit_updated."
          },
          "label": {
            "type": "string",
            "title": "Label"
          },
          "at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "At"
          },
          "orderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderid"
          },
          "detail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Detail",
            "description": "Short note, e.g. the invoice or order number."
          },
          "changed": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Changed",
            "description": "Fields changed (unit_updated only). Cost only with costs:read."
          }
        },
        "type": "object",
        "required": [
          "action",
          "label"
        ],
        "title": "UnitEvent"
      },
      "UnitHistory": {
        "properties": {
          "unit": {
            "$ref": "#/components/schemas/Unit"
          },
          "events": {
            "items": {
              "$ref": "#/components/schemas/UnitEvent"
            },
            "type": "array",
            "title": "Events",
            "description": "Newest first."
          }
        },
        "type": "object",
        "required": [
          "unit",
          "events"
        ],
        "title": "UnitHistory"
      },
      "UnitPnl": {
        "properties": {
          "unitId": {
            "type": "integer",
            "title": "Unitid"
          },
          "serial": {
            "type": "string",
            "title": "Serial"
          },
          "sales": {
            "items": {
              "$ref": "#/components/schemas/UnitSale"
            },
            "type": "array",
            "title": "Sales",
            "description": "Every sale of this unit, newest first."
          }
        },
        "type": "object",
        "required": [
          "unitId",
          "serial",
          "sales"
        ],
        "title": "UnitPnl"
      },
      "UnitSale": {
        "properties": {
          "orderNo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orderno"
          },
          "orderId": {
            "type": "string",
            "title": "Orderid"
          },
          "marketplace": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketplace"
          },
          "soldOn": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Soldon"
          },
          "lines": {
            "items": {
              "$ref": "#/components/schemas/PnlLine"
            },
            "type": "array",
            "title": "Lines"
          },
          "grossProfit": {
            "type": "number",
            "title": "Grossprofit"
          },
          "netProfit": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Netprofit",
            "description": "Null when a line is left out for AI assistants."
          },
          "complete": {
            "type": "boolean",
            "title": "Complete"
          },
          "final": {
            "type": "boolean",
            "title": "Final"
          },
          "notes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Notes"
          }
        },
        "type": "object",
        "required": [
          "orderId",
          "lines",
          "grossProfit",
          "complete",
          "final"
        ],
        "title": "UnitSale"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: ms_live_..."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}
