{
  "openapi": "3.1.0",
  "info": {
    "title": "Inventrackr API",
    "version": "1.2.0",
    "summary": "Read and update a Pro storage's products and suppliers, read purchase orders, counts and reports, and receive signed webhooks.",
    "description": "Each API key belongs to one storage. Keys are created by the storage owner in the web app (Storage settings → Integrations) and work while the owner's plan is Pro. Full guide: https://inventrackr.com/developers",
    "contact": {
      "name": "Inventrackr support",
      "email": "support@inventrackr.com",
      "url": "https://inventrackr.com/support"
    },
    "termsOfService": "https://inventrackr.com/terms"
  },
  "externalDocs": {
    "description": "API & webhooks documentation",
    "url": "https://inventrackr.com/developers"
  },
  "servers": [
    {
      "url": "https://api-production-c3ca.up.railway.app/api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Storage",
      "description": "The key's storage, its settings and custom fields."
    },
    {
      "name": "Items",
      "description": "Products in the key's storage."
    },
    {
      "name": "Suppliers"
    },
    {
      "name": "Purchasing",
      "description": "Purchase orders (read only)."
    },
    {
      "name": "Counts",
      "description": "Counting sessions (read only)."
    },
    {
      "name": "Reports",
      "description": "Reports and the audit log export."
    },
    {
      "name": "Automation",
      "description": "REST-hook subscriptions and sample events for Zapier, Make and similar tools."
    }
  ],
  "paths": {
    "/items": {
      "get": {
        "tags": [
          "Items"
        ],
        "operationId": "listItems",
        "summary": "List items",
        "description": "Items ordered by `updatedAt`, then `id` (oldest first). Deleted items are not listed. Filters combine with each other and with paging. With `includeDeleted=true`, deletion tombstones (kept 90 days) are merged into the same (time, id) paging.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "The `nextCursor` of the previous page (opaque)."
          },
          {
            "name": "updatedSince",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only items with `updatedAt` at or after this moment (inclusive). ISO 8601 with `Z` or an offset."
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Matches name, barcodes, description, location, tags and custom field values."
          },
          {
            "name": "barcode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match on any of the item's barcodes."
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive."
          },
          {
            "name": "location",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact, case-insensitive."
          },
          {
            "name": "supplierId",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "string",
                  "const": "none"
                }
              ]
            }
          },
          {
            "name": "includeDeleted",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "description": "Merge deletion tombstones into the page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "nextCursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "$ref": "#/components/schemas/Item"
                          },
                          {
                            "$ref": "#/components/schemas/Tombstone"
                          }
                        ]
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      },
      "post": {
        "tags": [
          "Items"
        ],
        "operationId": "createItem",
        "summary": "Create an item",
        "description": "Needs a write key. Sends an `item.created` webhook. Not idempotent.",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemCreate"
              },
              "example": {
                "name": "Espresso beans",
                "barcode": "8714789120045",
                "quantity": 12,
                "minimumQuantity": 5,
                "unit": "kg",
                "priceCents": 1899
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. An unknown supplierId is ignored (for compatibility) and reported in `warnings`.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Item"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "const": "SUPPLIER_NOT_FOUND"
                              },
                              "field": {
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/items/{id}": {
      "get": {
        "tags": [
          "Items"
        ],
        "operationId": "getItem",
        "summary": "Get an item",
        "parameters": [
          {
            "$ref": "#/components/parameters/ItemId"
          }
        ],
        "responses": {
          "200": {
            "description": "The item.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      },
      "patch": {
        "tags": [
          "Items"
        ],
        "operationId": "updateItem",
        "summary": "Update an item",
        "description": "Needs a write key. Partial: omitted fields are unchanged; `customFields` replaces the whole map. A large stock decrease under the storage's approval rules → 409 APPROVAL_REQUIRED (use PATCH …/quantity, which can wait for approval).",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemPatch"
              },
              "example": {
                "version": 7,
                "location": "Aisle 4 / A1",
                "tags": [
                  "Coffee"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated item.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      },
      "delete": {
        "tags": [
          "Items"
        ],
        "operationId": "deleteItem",
        "summary": "Delete an item",
        "description": "Needs a write key. Sends `item.deleted`. Under an item-deletion approval rule it answers 202 instead.",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "202": {
            "$ref": "#/components/responses/PendingApproval"
          },
          "204": {
            "description": "Deleted.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/items/{id}/quantity": {
      "patch": {
        "tags": [
          "Items"
        ],
        "operationId": "updateItemQuantity",
        "summary": "Change stock",
        "description": "Needs a write key. Send either `quantity` (absolute) or `delta` (relative; the result is clamped at 0), plus an optional `reason`. If both are sent, `quantity` is used. Batch items lose stock first-expiring first unless `batchId` is given. Sends `item.quantityChanged` (and `item.lowStock` on the crossing). Under the storage's approval rules it answers 202.",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuantityChange"
              },
              "examples": {
                "delta": {
                  "value": {
                    "delta": -2,
                    "reason": "sold",
                    "note": "Sold at the counter"
                  }
                },
                "absolute": {
                  "value": {
                    "quantity": 40,
                    "expectedQuantity": 3.5,
                    "reason": "count",
                    "note": "Stock count"
                  }
                },
                "receive": {
                  "value": {
                    "delta": 10,
                    "reason": "received",
                    "unitCostCents": 1150,
                    "batch": {
                      "code": "L43",
                      "expiresOn": "2027-06-30"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated item plus the change.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Item"
                    },
                    {
                      "type": "object",
                      "required": [
                        "previousQuantity"
                      ],
                      "properties": {
                        "previousQuantity": {
                          "type": "number"
                        },
                        "reason": {
                          "$ref": "#/components/schemas/StockReason"
                        },
                        "delta": {
                          "type": "number"
                        },
                        "batchMovements": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "batchId": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "code": {
                                "type": "string"
                              },
                              "expiresOn": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "format": "date"
                              },
                              "delta": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "202": {
            "$ref": "#/components/responses/PendingApproval"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/suppliers": {
      "get": {
        "tags": [
          "Suppliers"
        ],
        "operationId": "listSuppliers",
        "summary": "List suppliers",
        "description": "All suppliers of the storage, sorted by name (case-insensitive), as a plain array. Pass `limit` to page in name order: the `X-Next-Cursor` header is set when there are more; pass it back as `cursor`.",
        "responses": {
          "200": {
            "description": "Suppliers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Supplier"
                  }
                }
              }
            },
            "headers": {
              "X-Next-Cursor": {
                "$ref": "#/components/headers/NextCursor"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The X-Next-Cursor of the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Suppliers"
        ],
        "operationId": "createSupplier",
        "summary": "Create a supplier",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupplierInput"
                  },
                  {
                    "required": [
                      "name"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/storage": {
      "get": {
        "tags": [
          "Storage"
        ],
        "operationId": "getStorage",
        "summary": "Get the storage",
        "description": "The key's storage with its settings, custom field definitions and the key's name and scope. Also a handy auth check.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Storage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/items/{id}/image": {
      "get": {
        "tags": [
          "Items"
        ],
        "operationId": "getItemImage",
        "summary": "Get an item's photo",
        "parameters": [
          {
            "$ref": "#/components/parameters/ItemId"
          }
        ],
        "responses": {
          "200": {
            "description": "The image bytes.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/jpeg"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/png"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/webp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/suppliers/{supplierId}": {
      "patch": {
        "tags": [
          "Suppliers"
        ],
        "operationId": "updateSupplier",
        "summary": "Update a supplier",
        "description": "Partial: omitted fields are unchanged.",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupplierId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated supplier.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      },
      "delete": {
        "tags": [
          "Suppliers"
        ],
        "operationId": "deleteSupplier",
        "summary": "Delete a supplier",
        "description": "Its items lose the supplier (version and updatedAt bumped) and each sends `item.updated`.",
        "security": [
          {
            "apiKey": [
              "write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupplierId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/purchase-orders": {
      "get": {
        "tags": [
          "Purchasing"
        ],
        "operationId": "listPurchaseOrders",
        "summary": "List purchase orders",
        "description": "Newest number first.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "draft",
                "sent",
                "partially_received",
                "received",
                "cancelled"
              ]
            },
            "description": "`open` = sent or partially received."
          },
          {
            "name": "supplierId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PurchaseOrderSummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/purchase-orders/{poId}": {
      "get": {
        "tags": [
          "Purchasing"
        ],
        "operationId": "getPurchaseOrder",
        "summary": "Get a purchase order",
        "description": "With lines, totals and receipts.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PoId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/counts": {
      "get": {
        "tags": [
          "Counts"
        ],
        "operationId": "listCounts",
        "summary": "List counting sessions",
        "description": "Newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CountSession"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/counts/{countId}": {
      "get": {
        "tags": [
          "Counts"
        ],
        "operationId": "getCount",
        "summary": "Get a counting session",
        "description": "The session plus its lines.",
        "parameters": [
          {
            "$ref": "#/components/parameters/CountId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/CountSession"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "lines": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/CountLine"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/reports/{name}": {
      "get": {
        "tags": [
          "Reports"
        ],
        "operationId": "getReport",
        "summary": "Get a report",
        "description": "JSON only; the same as the app's reports. Money in cents. `from`/`to` apply to stock-value (default 90 days), movements (30), shrinkage (90) and purchases (90); `days` to dead-stock (30/60/90/180/365, default 90), abc (30/90/180/365, default 90) and expiring (default: the storage's warning window).",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "stock-value",
                "movements",
                "shrinkage",
                "dead-stock",
                "abc",
                "at-risk",
                "expiring",
                "purchases"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/activity/export": {
      "get": {
        "tags": [
          "Reports"
        ],
        "operationId": "exportActivity",
        "summary": "Export the audit log",
        "description": "The whole activity history, oldest first, streamed. CSV columns (and JSON keys): id, createdAt, type, entityType, entityId, itemName, actorUserId, actorName, reason, delta, quantity, previousQuantity, note, payload.",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "csv",
                "json"
              ],
              "default": "csv"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Date or date-time."
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Date or date-time."
          },
          {
            "name": "userId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "itemId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "reason",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/StockReason"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated event types."
          }
        ],
        "responses": {
          "200": {
            "description": "The export.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/me": {
      "get": {
        "tags": [
          "Storage"
        ],
        "operationId": "getMe",
        "summary": "Who am I",
        "description": "The key's storage and the key itself. Use it to test a key and label a connection.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/hooks": {
      "get": {
        "tags": [
          "Automation"
        ],
        "operationId": "listHooks",
        "summary": "List hook subscriptions",
        "description": "Hooks created through the API (webhooks added in the app aren't listed).",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiHook"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      },
      "post": {
        "tags": [
          "Automation"
        ],
        "operationId": "createHook",
        "summary": "Subscribe a hook",
        "description": "Creates a webhook endpoint owned by this API key (revoking the key deletes its hooks). Deliveries, signatures, retries, replay and `sequence` behave like app webhooks. Up to 50 API hooks per storage; they don't count toward the app's 10 webhooks.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiHookInput"
              },
              "example": {
                "url": "https://hooks.zapier.com/hooks/standard/123/abc",
                "event": "item.lowStock"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. The `secret` is shown only once.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiHookCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/hooks/{hookId}": {
      "parameters": [
        {
          "name": "hookId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "delete": {
        "tags": [
          "Automation"
        ],
        "operationId": "deleteHook",
        "summary": "Unsubscribe a hook",
        "description": "404 when the hook is already gone (treat it as success). App webhooks can't be deleted here.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    },
    "/samples/{event}": {
      "get": {
        "tags": [
          "Automation"
        ],
        "operationId": "listSamples",
        "summary": "Sample events",
        "description": "Recent deliveries of that type (last 72 hours), newest first; when there are none, samples built from current data with ids `sample:<type>:<id>` and `sequence: null`.",
        "parameters": [
          {
            "name": "event",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Busy"
          }
        }
      }
    }
  },
  "webhooks": {
    "item.created": {
      "post": {
        "summary": "item.created",
        "description": "A product was added (apps, CSV import or API).",
        "operationId": "webhook_item_created",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "item.created"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "item.created"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "item"
                        ],
                        "properties": {
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "item.updated": {
      "post": {
        "summary": "item.updated",
        "description": "A product's details were edited in the apps or updated by CSV import.",
        "operationId": "webhook_item_updated",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "item.updated"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "item.updated"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "item"
                        ],
                        "properties": {
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "item.deleted": {
      "post": {
        "summary": "item.deleted",
        "description": "A product was deleted.",
        "operationId": "webhook_item_deleted",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "item.deleted"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "item.deleted"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "item"
                        ],
                        "properties": {
                          "item": {
                            "type": "object",
                            "required": [
                              "id",
                              "name"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "item.quantityChanged": {
      "post": {
        "summary": "item.quantityChanged",
        "description": "Stock changed.",
        "operationId": "webhook_item_quantityChanged",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "item.quantityChanged"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "item.quantityChanged"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "item",
                          "previousQuantity",
                          "delta"
                        ],
                        "properties": {
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          },
                          "previousQuantity": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "delta": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "note": {
                            "type": "string"
                          },
                          "reason": {
                            "$ref": "#/components/schemas/StockReason"
                          },
                          "batches": {
                            "type": "array",
                            "items": {
                              "type": "object"
                            }
                          },
                          "purchaseOrderId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "transferId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "countId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "approvalRequestId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "approvedBy": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            }
                          },
                          "kitItemId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "source": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "item.lowStock": {
      "post": {
        "summary": "item.lowStock",
        "description": "An item crossed to at or below its minimum: a stock change, creation with a minimum at or above the stock, or the minimum raised to or above the stock.",
        "operationId": "webhook_item_lowStock",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "item.lowStock"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "item.lowStock"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "item"
                        ],
                        "properties": {
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "supplier.created": {
      "post": {
        "summary": "supplier.created",
        "description": "A supplier was added.",
        "operationId": "webhook_supplier_created",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "supplier.created"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "supplier.created"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "supplier"
                        ],
                        "properties": {
                          "supplier": {
                            "$ref": "#/components/schemas/Supplier"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "supplier.updated": {
      "post": {
        "summary": "supplier.updated",
        "description": "A supplier was edited.",
        "operationId": "webhook_supplier_updated",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "supplier.updated"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "supplier.updated"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "supplier"
                        ],
                        "properties": {
                          "supplier": {
                            "$ref": "#/components/schemas/Supplier"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "supplier.deleted": {
      "post": {
        "summary": "supplier.deleted",
        "description": "A supplier was deleted.",
        "operationId": "webhook_supplier_deleted",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "supplier.deleted"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "supplier.deleted"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "supplier"
                        ],
                        "properties": {
                          "supplier": {
                            "type": "object",
                            "required": [
                              "id",
                              "name"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "webhook.test": {
      "post": {
        "summary": "webhook.test",
        "description": "Sent by \"Send test\" in the app (one attempt, no retries). Can't be subscribed to.",
        "operationId": "webhook_webhook_test",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "webhook.test"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "webhook.test"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "message"
                        ],
                        "properties": {
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "batch.expiringSoon": {
      "post": {
        "summary": "batch.expiringSoon",
        "description": "A batch entered the storage's expiry warning window (once per expiry date; daily job at 06:00 UTC).",
        "operationId": "webhook_batch_expiringSoon",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "batch.expiringSoon"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "batch.expiringSoon"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "batch",
                          "item"
                        ],
                        "properties": {
                          "batch": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "code": {
                                "type": "string"
                              },
                              "expiresOn": {
                                "type": "string",
                                "format": "date"
                              },
                              "quantity": {
                                "type": "number"
                              },
                              "daysLeft": {
                                "type": "integer"
                              }
                            }
                          },
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "batch.expired": {
      "post": {
        "summary": "batch.expired",
        "description": "A batch expired (once, the day after expiry).",
        "operationId": "webhook_batch_expired",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "batch.expired"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "batch.expired"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "batch",
                          "item"
                        ],
                        "properties": {
                          "batch": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "code": {
                                "type": "string"
                              },
                              "expiresOn": {
                                "type": "string",
                                "format": "date"
                              },
                              "quantity": {
                                "type": "number"
                              },
                              "daysLeft": {
                                "type": "integer"
                              }
                            }
                          },
                          "item": {
                            "$ref": "#/components/schemas/Item"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "purchaseOrder.created": {
      "post": {
        "summary": "purchaseOrder.created",
        "description": "A purchase order was created.",
        "operationId": "webhook_purchaseOrder_created",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "purchaseOrder.created"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "purchaseOrder.created"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "purchaseOrder"
                        ],
                        "properties": {
                          "purchaseOrder": {
                            "$ref": "#/components/schemas/PurchaseOrder"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "purchaseOrder.sent": {
      "post": {
        "summary": "purchaseOrder.sent",
        "description": "A purchase order was sent (emailed or marked sent).",
        "operationId": "webhook_purchaseOrder_sent",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "purchaseOrder.sent"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "purchaseOrder.sent"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "purchaseOrder"
                        ],
                        "properties": {
                          "purchaseOrder": {
                            "$ref": "#/components/schemas/PurchaseOrder"
                          },
                          "emailed": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "purchaseOrder.received": {
      "post": {
        "summary": "purchaseOrder.received",
        "description": "Stock was received on a purchase order (every receipt).",
        "operationId": "webhook_purchaseOrder_received",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "purchaseOrder.received"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "purchaseOrder.received"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "purchaseOrder",
                          "receipt",
                          "fullyReceived"
                        ],
                        "properties": {
                          "purchaseOrder": {
                            "$ref": "#/components/schemas/PurchaseOrder"
                          },
                          "receipt": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "lines": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "lineId": {
                                      "type": "string"
                                    },
                                    "itemId": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "quantity": {
                                      "type": "number"
                                    },
                                    "unitCostCents": {
                                      "type": "integer"
                                    },
                                    "batch": {
                                      "type": [
                                        "object",
                                        "null"
                                      ]
                                    }
                                  }
                                }
                              },
                              "valueCents": {
                                "type": "integer"
                              }
                            }
                          },
                          "fullyReceived": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "transfer.completed": {
      "post": {
        "summary": "transfer.completed",
        "description": "Stock moved between storages. Sent to both; `direction` is relative to the receiving storage.",
        "operationId": "webhook_transfer_completed",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "transfer.completed"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "transfer.completed"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "transfer"
                        ],
                        "properties": {
                          "transfer": {
                            "$ref": "#/components/schemas/Transfer"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "count.completed": {
      "post": {
        "summary": "count.completed",
        "description": "A counting session was applied.",
        "operationId": "webhook_count_completed",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "count.completed"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "count.completed"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "count"
                        ],
                        "properties": {
                          "count": {
                            "type": "object",
                            "properties": {
                              "countId": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string"
                              },
                              "linesCounted": {
                                "type": "integer"
                              },
                              "adjustments": {
                                "type": "integer"
                              },
                              "varianceValueCents": {
                                "type": "integer"
                              },
                              "items": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "itemId": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "delta": {
                                      "type": "number"
                                    },
                                    "valueCents": {
                                      "type": "integer"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "approval.requested": {
      "post": {
        "summary": "approval.requested",
        "description": "An action was held for approval.",
        "operationId": "webhook_approval_requested",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "approval.requested"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "approval.requested"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "request"
                        ],
                        "properties": {
                          "request": {
                            "$ref": "#/components/schemas/ApprovalRequest"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    },
    "approval.resolved": {
      "post": {
        "summary": "approval.resolved",
        "description": "A request was approved, declined, withdrawn or failed.",
        "operationId": "webhook_approval_resolved",
        "parameters": [
          {
            "name": "Inventrackr-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>`. The key is the whole signing secret (`whsec_…`). During a secret rotation (24 h) a second `,v1=` signed with the previous secret follows: accept the request if any v1 matches."
          },
          {
            "name": "Inventrackr-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "approval.resolved"
            }
          },
          {
            "name": "Inventrackr-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per endpoint and event; unchanged across retries."
          },
          {
            "name": "User-Agent",
            "in": "header",
            "schema": {
              "type": "string",
              "const": "Inventrackr-Webhooks/1.0"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "approval.resolved"
                      },
                      "data": {
                        "type": "object",
                        "required": [
                          "request"
                        ],
                        "properties": {
                          "request": {
                            "$ref": "#/components/schemas/ApprovalRequest"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledged. Respond within 10 seconds; anything else (other statuses, redirects, timeouts) is retried, up to 8 attempts over about 30 hours."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "itk_live_…",
        "description": "`Authorization: Bearer itk_live_…`. Read keys can call the GET endpoints; write keys can call everything."
      }
    },
    "parameters": {
      "ItemId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "pattern": "^[\\x21-\\x7e]+$"
        },
        "description": "Optional. The first response (status < 500) is stored for 24 h per API key and replayed for repeats with `Idempotent-Replayed: true`. The same key with a different method, path or body → 422 IDEMPOTENCY_MISMATCH; while the first request runs → 409 IDEMPOTENCY_IN_PROGRESS."
      },
      "SupplierId": {
        "name": "supplierId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "PoId": {
        "name": "poId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "CountId": {
        "name": "countId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "From": {
        "name": "from",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Period start, YYYY-MM-DD (inclusive, UTC). Periods are at most 2 years."
      },
      "To": {
        "name": "to",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Period end, YYYY-MM-DD (inclusive, UTC)."
      }
    },
    "headers": {
      "RetryAfter": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      },
      "RateLimitLimit": {
        "description": "Requests allowed per window for this key.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitRemaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitReset": {
        "description": "When the window resets (Unix seconds).",
        "schema": {
          "type": "integer"
        }
      },
      "IdempotentReplayed": {
        "description": "`true` when this is a stored response replayed for a repeated Idempotency-Key.",
        "schema": {
          "type": "string",
          "const": "true"
        }
      },
      "NextCursor": {
        "description": "Present when more suppliers follow: pass it as `cursor`.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Validation failed (`VALIDATION_FAILED`, with `details`), or INVALID_ID, INVALID_JSON, INVALID_CURSOR, INVALID_VALUE, IDEMPOTENCY_KEY_INVALID and endpoint-specific codes.",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ValidationError"
                },
                {
                  "$ref": "#/components/schemas/Error"
                }
              ]
            },
            "example": {
              "error": "Invalid request",
              "code": "VALIDATION_FAILED",
              "details": [
                {
                  "path": "quantity",
                  "message": "Use at most 3 decimal places",
                  "code": "custom"
                }
              ]
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, malformed or revoked key (`API_KEY_INVALID`), or the storage owner's plan isn't Pro (`PLAN_REQUIRED`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "This API key is invalid or was revoked",
              "code": "API_KEY_INVALID"
            }
          }
        }
      },
      "Forbidden": {
        "description": "A read-only key called a write endpoint.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "This API key is read-only",
              "code": "INSUFFICIENT_SCOPE"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found in this key's storage (`NOT_FOUND`), or the storage was deleted (`STORAGE_GONE`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Item not found",
              "code": "NOT_FOUND"
            }
          }
        }
      },
      "TooLarge": {
        "description": "Request body larger than 256 KB.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Request is too large",
              "code": "PAYLOAD_TOO_LARGE"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded: 120 requests/min per key, 600/min per client IP (fixed one-minute windows).",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Too many attempts. Please wait a moment and try again.",
              "code": "RATE_LIMITED"
            }
          }
        }
      },
      "Busy": {
        "description": "A conflicting change happened at the same moment; safe to retry.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Busy with a conflicting change. Try again.",
              "code": "BUSY"
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict: VERSION_CONFLICT, STOCK_CHANGED, UNIT_CHANGED, APPROVAL_REQUIRED, BATCH_NOT_FOUND, KIT_NOT_STOCKED, BATCHES_REQUIRE_ADJUSTMENT, IDEMPOTENCY_IN_PROGRESS, DUPLICATE or REFERENCE_REMOVED.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "The stock changed since expectedQuantity was read",
              "code": "STOCK_CHANGED"
            }
          }
        }
      },
      "IdempotencyMismatch": {
        "description": "The Idempotency-Key was used for a different request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "This Idempotency-Key was used for a different request",
              "code": "IDEMPOTENCY_MISMATCH"
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Unexpected server error",
              "code": "INTERNAL_ERROR"
            }
          }
        }
      },
      "PendingApproval": {
        "description": "Held for approval under the storage's rules (API keys are never approvers). Nothing changed yet.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PendingApproval"
            }
          }
        }
      }
    },
    "schemas": {
      "Unit": {
        "type": "string",
        "enum": [
          "each",
          "pack",
          "box",
          "case",
          "roll",
          "ml",
          "l",
          "g",
          "kg",
          "oz",
          "lb",
          "fl_oz",
          "gal",
          "cm",
          "m",
          "in",
          "ft"
        ]
      },
      "Item": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "barcode",
          "quantity",
          "minimumQuantity",
          "unit",
          "priceCents",
          "supplierId",
          "supplierName",
          "hasImage",
          "imageVersion",
          "version",
          "createdAt",
          "updatedAt",
          "stockStatus"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "maxLength": 160
          },
          "description": {
            "type": "string",
            "maxLength": 4000
          },
          "barcode": {
            "type": "string",
            "maxLength": 120
          },
          "quantity": {
            "type": "number",
            "minimum": 0
          },
          "minimumQuantity": {
            "type": "number",
            "minimum": 0
          },
          "unit": {
            "$ref": "#/components/schemas/Unit"
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "description": "In the smallest unit of the storage's currency (set in the app)."
          },
          "supplierId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "supplierName": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasImage": {
            "type": "boolean"
          },
          "imageVersion": {
            "type": "integer"
          },
          "version": {
            "type": "integer",
            "description": "Increases with every change."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "stockStatus": {
            "type": "string",
            "enum": [
              "inStock",
              "lowStock",
              "outOfStock"
            ],
            "description": "outOfStock when quantity is 0; lowStock when quantity ≤ minimumQuantity."
          },
          "costCents": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 2147483647,
            "description": "Unit purchase cost in cents; null = unknown. Receiving purchase orders updates it as a moving average."
          },
          "stockValueCents": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "round(quantity × costCents); null when costCents is null."
          },
          "retailValueCents": {
            "type": "integer",
            "readOnly": true,
            "description": "round(quantity × priceCents)."
          },
          "location": {
            "type": "string",
            "maxLength": 80,
            "description": "Bin location; empty when unset."
          },
          "barcodes": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 120
            },
            "description": "The primary barcode (`barcode`) first, then up to 9 more."
          },
          "tags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 30
            },
            "description": "Unique ignoring case."
          },
          "customFields": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/CustomFieldValue"
            },
            "description": "Values by custom field id (see GET /storage)."
          },
          "trackBatches": {
            "type": "boolean"
          },
          "batches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Batch"
            },
            "readOnly": true,
            "description": "First-expiring first; empty unless trackBatches."
          },
          "kit": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Kit"
              },
              {
                "type": "null"
              }
            ]
          },
          "onOrderQuantity": {
            "type": "number",
            "readOnly": true,
            "description": "Remaining on sent or partially received purchase orders."
          }
        },
        "example": {
          "id": "3f6c2a8e-6b1d-4c1e-9a52-2d8f0c7b9e10",
          "name": "Espresso beans",
          "description": "House blend, 1 kg bags",
          "barcode": "8714789120045",
          "quantity": 3.5,
          "minimumQuantity": 5,
          "unit": "kg",
          "priceCents": 1899,
          "supplierId": "9b2e7c44-1f0a-4d3b-8e6f-5a1c2d3e4f50",
          "supplierName": "Roastery Co.",
          "hasImage": false,
          "imageVersion": 0,
          "version": 7,
          "createdAt": "2026-10-02T14:05:11.482Z",
          "updatedAt": "2026-11-18T09:31:27.103Z",
          "stockStatus": "lowStock"
        }
      },
      "ItemCreate": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "description": "Trimmed."
              },
              "description": {
                "type": "string",
                "maxLength": 4000,
                "default": ""
              },
              "barcode": {
                "type": "string",
                "maxLength": 120,
                "default": "",
                "description": "Trimmed."
              },
              "quantity": {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999999,
                "multipleOf": 0.001,
                "description": "At most 3 decimal places.",
                "default": 0
              },
              "minimumQuantity": {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999999,
                "multipleOf": 0.001,
                "description": "At most 3 decimal places.",
                "default": 0
              },
              "unit": {
                "$ref": "#/components/schemas/Unit",
                "default": "each"
              },
              "priceCents": {
                "type": "integer",
                "minimum": 0,
                "maximum": 2147483647,
                "default": 0
              },
              "supplierId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid",
                "description": "A supplier of this storage; any other id is ignored (no supplier)."
              }
            }
          },
          {
            "$ref": "#/components/schemas/ItemExtrasInput"
          },
          {
            "type": "object",
            "properties": {
              "batch": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "expiresOn": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date"
                  }
                },
                "description": "With trackBatches: the batch for the initial quantity."
              }
            }
          }
        ]
      },
      "QuantityChange": {
        "type": "object",
        "properties": {
          "quantity": {
            "type": "number",
            "minimum": 0,
            "maximum": 999999999999,
            "multipleOf": 0.001,
            "description": "Sets the stock. At most 3 decimal places."
          },
          "delta": {
            "type": "number",
            "minimum": -1000000,
            "maximum": 1000000,
            "multipleOf": 0.001,
            "description": "Adds to the stock; the result never goes below 0."
          },
          "expectedQuantity": {
            "type": "number",
            "minimum": 0,
            "maximum": 999999999999,
            "multipleOf": 0.001,
            "description": "With either form: refuse with 409 STOCK_CHANGED unless the current stock equals this."
          },
          "note": {
            "type": "string",
            "maxLength": 280,
            "description": "Shown in the activity history and sent in the webhook."
          },
          "reason": {
            "$ref": "#/components/schemas/StockReason"
          },
          "unit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Unit"
              }
            ],
            "description": "The unit the amount is in; 409 UNIT_CHANGED if the item's unit differs."
          },
          "batchId": {
            "type": "string",
            "format": "uuid",
            "description": "Batch items. Stock out: take from this batch first (then FEFO). Stock in: add to it."
          },
          "batch": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "maxLength": 60
              },
              "expiresOn": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              }
            },
            "description": "Batch items, stock in: add to this batch (merged by code + expiry)."
          },
          "unitCostCents": {
            "type": "integer",
            "minimum": 0,
            "description": "Stock in: incoming unit cost (updates the moving-average cost for `received`)."
          }
        },
        "anyOf": [
          {
            "required": [
              "quantity"
            ]
          },
          {
            "required": [
              "delta"
            ]
          }
        ]
      },
      "Supplier": {
        "type": "object",
        "required": [
          "id",
          "name",
          "contactName",
          "contactEmail",
          "contactPhone",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "contactName": {
            "type": "string"
          },
          "contactEmail": {
            "type": "string"
          },
          "contactPhone": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "email": {
            "type": "string",
            "readOnly": true,
            "description": "Alias of contactEmail."
          },
          "phone": {
            "type": "string",
            "readOnly": true,
            "description": "Alias of contactPhone."
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "leadTimeDays": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365,
            "description": "Default 7."
          },
          "currencyCode": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Z]{3}$",
            "description": "null = the storage's currency."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message."
          },
          "code": {
            "type": "string",
            "description": "Machine-readable code. Every error has one; branch on it, never on the message. New codes may be added.",
            "examples": [
              "VALIDATION_FAILED",
              "INVALID_ID",
              "INVALID_JSON",
              "INVALID_CURSOR",
              "INVALID_VALUE",
              "IDEMPOTENCY_KEY_INVALID",
              "BAD_REQUEST",
              "SUPPLIER_NOT_FOUND",
              "CUSTOM_FIELD_INVALID",
              "KIT_INVALID",
              "KIT_CYCLE",
              "API_KEY_INVALID",
              "PLAN_REQUIRED",
              "INSUFFICIENT_SCOPE",
              "NOT_FOUND",
              "STORAGE_GONE",
              "VERSION_CONFLICT",
              "STOCK_CHANGED",
              "UNIT_CHANGED",
              "APPROVAL_REQUIRED",
              "BATCH_NOT_FOUND",
              "BATCH_MISMATCH",
              "KIT_NOT_STOCKED",
              "BATCHES_REQUIRE_ADJUSTMENT",
              "IDEMPOTENCY_IN_PROGRESS",
              "DUPLICATE",
              "REFERENCE_REMOVED",
              "PAYLOAD_TOO_LARGE",
              "IDEMPOTENCY_MISMATCH",
              "RATE_LIMITED",
              "INTERNAL_ERROR",
              "BUSY"
            ]
          }
        },
        "additionalProperties": true
      },
      "ValidationError": {
        "type": "object",
        "required": [
          "error",
          "code",
          "details"
        ],
        "properties": {
          "error": {
            "type": "string",
            "const": "Invalid request"
          },
          "code": {
            "type": "string",
            "const": "VALIDATION_FAILED"
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "message",
                "code"
              ],
              "properties": {
                "path": {
                  "type": "string",
                  "description": "Dotted path, e.g. `lines.0.quantity`."
                },
                "message": {
                  "type": "string"
                },
                "code": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "WebhookEnvelope": {
        "type": "object",
        "required": [
          "id",
          "type",
          "createdAt",
          "storageId",
          "data",
          "sequence"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Event ID: the same for every endpoint and every retry. Use it to drop duplicates."
          },
          "type": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "storageId": {
            "type": "string",
            "format": "uuid"
          },
          "data": {
            "type": "object"
          },
          "sequence": {
            "type": "integer",
            "description": "Increases with every event the storage produces. Deliveries can arrive out of order: use it (and item version) to discard stale updates. Redeliveries and replays keep the original id and sequence."
          }
        }
      },
      "StockReason": {
        "type": "string",
        "enum": [
          "received",
          "sold",
          "used",
          "damaged",
          "expired",
          "lost",
          "returned",
          "count",
          "transfer_in",
          "transfer_out",
          "kit",
          "other"
        ],
        "description": "Why stock changed. Default `other`."
      },
      "Batch": {
        "type": "object",
        "required": [
          "id",
          "code",
          "expiresOn",
          "quantity",
          "receivedAt",
          "costCents"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "maxLength": 60,
            "description": "Empty with no expiry = the unassigned batch."
          },
          "expiresOn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "quantity": {
            "type": "number"
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "costCents": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "Kit": {
        "type": "object",
        "required": [
          "stocked",
          "components",
          "buildableQuantity"
        ],
        "properties": {
          "stocked": {
            "type": "boolean",
            "description": "False: the kit isn't stocked; selling or using it consumes its components."
          },
          "components": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "itemId",
                "name",
                "unit",
                "quantity"
              ],
              "properties": {
                "itemId": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "unit": {
                  "$ref": "#/components/schemas/Unit"
                },
                "quantity": {
                  "type": "number",
                  "description": "Per kit."
                }
              }
            }
          },
          "buildableQuantity": {
            "type": "number",
            "description": "min(floor(component stock / per-kit quantity))."
          }
        }
      },
      "CustomFieldValue": {
        "type": [
          "string",
          "number",
          "boolean"
        ],
        "description": "text (≤ 500), number, date (YYYY-MM-DD), select option, or checkbox boolean."
      },
      "ItemExtrasInput": {
        "type": "object",
        "properties": {
          "costCents": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 2147483647,
            "description": "Unit purchase cost in cents; null = unknown. Receiving purchase orders updates it as a moving average."
          },
          "location": {
            "type": "string",
            "maxLength": 80,
            "description": "Bin location; empty when unset."
          },
          "barcodes": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 120
            },
            "description": "Authoritative when sent: `barcode` becomes `barcodes[0]`."
          },
          "tags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 30
            },
            "description": "Unique ignoring case."
          },
          "customFields": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/CustomFieldValue"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "By field id (or name). Replaces the whole map. Required fields must have a value when this is sent; null or \"\" removes a value."
          },
          "trackBatches": {
            "type": "boolean",
            "description": "true turns current stock into the unassigned batch; false drops batches and keeps the quantity."
          },
          "kit": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "components"
                ],
                "properties": {
                  "stocked": {
                    "type": "boolean",
                    "default": true
                  },
                  "components": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "itemId",
                        "quantity"
                      ],
                      "properties": {
                        "itemId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      }
                    }
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ItemPatch": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "description": "Trimmed."
              },
              "description": {
                "type": "string",
                "maxLength": 4000
              },
              "barcode": {
                "type": "string",
                "maxLength": 120,
                "description": "Trimmed."
              },
              "quantity": {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999999,
                "multipleOf": 0.001,
                "description": "At most 3 decimal places."
              },
              "minimumQuantity": {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999999,
                "multipleOf": 0.001,
                "description": "At most 3 decimal places."
              },
              "unit": {
                "$ref": "#/components/schemas/Unit"
              },
              "priceCents": {
                "type": "integer",
                "minimum": 0,
                "maximum": 2147483647
              },
              "supplierId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid",
                "description": "A supplier of this storage; any other id is ignored (no supplier)."
              }
            }
          },
          {
            "$ref": "#/components/schemas/ItemExtrasInput"
          },
          {
            "type": "object",
            "properties": {
              "version": {
                "type": "integer",
                "minimum": 1,
                "description": "409 VERSION_CONFLICT if the item's version is newer."
              },
              "reason": {
                "$ref": "#/components/schemas/StockReason"
              },
              "note": {
                "type": "string",
                "maxLength": 280,
                "description": "For a quantity change."
              }
            }
          }
        ],
        "description": "Partial: omitted fields are unchanged. An unknown supplierId → 400 SUPPLIER_NOT_FOUND."
      },
      "PendingApproval": {
        "type": "object",
        "required": [
          "status",
          "requestId"
        ],
        "properties": {
          "status": {
            "type": "string",
            "const": "pending_approval"
          },
          "requestId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "description": "The action waits for an approver; nothing changed yet."
      },
      "Tombstone": {
        "type": "object",
        "required": [
          "id",
          "deleted",
          "deletedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "description": "A deleted item (kept 90 days)."
      },
      "SupplierInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "contactName": {
            "type": "string",
            "maxLength": 120
          },
          "contactEmail": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "contactPhone": {
            "type": "string",
            "maxLength": 40
          },
          "leadTimeDays": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "currencyCode": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Z]{3}$"
          }
        }
      },
      "CustomField": {
        "type": "object",
        "required": [
          "id",
          "name",
          "type",
          "options",
          "required",
          "position"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "date",
              "select",
              "checkbox"
            ]
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required": {
            "type": "boolean"
          },
          "position": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StorageSettings": {
        "type": "object",
        "properties": {
          "expiryWarningDays": {
            "type": "integer"
          },
          "reviewPeriodDays": {
            "type": "integer"
          },
          "approvals": {
            "type": "object",
            "properties": {
              "stockDecreaseUnits": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "stockDecreaseValueCents": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "itemDelete": {
                "type": "boolean"
              },
              "countApply": {
                "type": "boolean"
              }
            }
          },
          "currencyCode": {
            "type": "string"
          },
          "pro": {
            "type": "boolean"
          }
        }
      },
      "Storage": {
        "type": "object",
        "required": [
          "id",
          "name",
          "currencyCode",
          "pro",
          "settings",
          "customFields",
          "apiKey"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "currencyCode": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "pro": {
            "type": "boolean"
          },
          "settings": {
            "$ref": "#/components/schemas/StorageSettings"
          },
          "customFields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomField"
            }
          },
          "apiKey": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "read",
                  "write"
                ]
              }
            }
          }
        }
      },
      "PurchaseOrderSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "number": {
            "type": "string",
            "examples": [
              "PO-0001"
            ]
          },
          "sequence": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "partially_received",
              "received",
              "cancelled"
            ]
          },
          "supplierId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "supplierName": {
            "type": [
              "string",
              "null"
            ]
          },
          "currencyCode": {
            "type": "string"
          },
          "expectedOn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "receivedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "version": {
            "type": "integer"
          },
          "lineCount": {
            "type": "integer"
          },
          "totalCents": {
            "type": "integer"
          }
        }
      },
      "PurchaseOrder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "number": {
            "type": "string"
          },
          "sequence": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "partially_received",
              "received",
              "cancelled"
            ]
          },
          "supplierId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "supplierName": {
            "type": [
              "string",
              "null"
            ]
          },
          "supplierEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "currencyCode": {
            "type": "string"
          },
          "expectedOn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "notes": {
            "type": "string"
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sentTo": {
            "type": [
              "string",
              "null"
            ]
          },
          "receivedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "cancelledAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "version": {
            "type": "integer"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "itemId": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid",
                  "description": "null if the product was deleted."
                },
                "itemName": {
                  "type": "string"
                },
                "unit": {
                  "type": "string"
                },
                "barcode": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "receivedQuantity": {
                  "type": "number"
                },
                "remainingQuantity": {
                  "type": "number"
                },
                "unitCostCents": {
                  "type": "integer"
                },
                "totalCents": {
                  "type": "integer"
                },
                "trackBatches": {
                  "type": "boolean"
                }
              }
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "lines": {
                "type": "integer"
              },
              "quantity": {
                "type": "number"
              },
              "totalCents": {
                "type": "integer"
              },
              "receivedCents": {
                "type": "integer"
              }
            }
          },
          "receipts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "lines": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "valueCents": {
                  "type": "integer"
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "receivedByName": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "CountSession": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "pending_approval",
              "applied",
              "cancelled"
            ]
          },
          "scope": {
            "type": "object",
            "description": "{type:\"all\"} | {type:\"filter\", tag?, location?, supplierId?} | {type:\"items\", itemIds}"
          },
          "assigneeIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "appliedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "appliedBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "appliedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "cancelledAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "approvalRequestId": {
            "type": [
              "string",
              "null"
            ]
          },
          "lineCount": {
            "type": "integer"
          },
          "countedCount": {
            "type": "integer"
          }
        }
      },
      "CountLine": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string",
            "format": "uuid"
          },
          "itemName": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "barcode": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "expectedQuantity": {
            "type": "number",
            "description": "Snapshot when the count was created."
          },
          "movementsSinceSnapshot": {
            "type": "number"
          },
          "expectedAtCount": {
            "type": "number"
          },
          "countedQuantity": {
            "type": [
              "number",
              "null"
            ]
          },
          "countedBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "countedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "countedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "entries": {
            "type": "integer"
          },
          "variance": {
            "type": [
              "number",
              "null"
            ],
            "description": "counted − expectedAtCount."
          },
          "varianceValueCents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "currentQuantity": {
            "type": "number"
          },
          "unitValueCents": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "ApprovalRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "stock_adjustment",
              "item_delete",
              "count_apply"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "declined",
              "cancelled",
              "failed"
            ]
          },
          "payload": {
            "type": "object"
          },
          "summary": {
            "type": "string"
          },
          "requestedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "requestedBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "resolvedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "resolvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "resolutionNote": {
            "type": "string"
          }
        }
      },
      "Transfer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "number": {
            "type": "string",
            "examples": [
              "TR-0001"
            ]
          },
          "sequence": {
            "type": "integer"
          },
          "direction": {
            "type": "string",
            "enum": [
              "out",
              "in"
            ]
          },
          "fromStorageId": {
            "type": [
              "string",
              "null"
            ]
          },
          "toStorageId": {
            "type": [
              "string",
              "null"
            ]
          },
          "fromStorageName": {
            "type": "string"
          },
          "toStorageName": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "storage",
          "apiKey"
        ],
        "properties": {
          "storage": {
            "type": "object",
            "required": [
              "id",
              "name",
              "currencyCode"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "currencyCode": {
                "type": "string",
                "example": "USD"
              }
            }
          },
          "apiKey": {
            "type": "object",
            "required": [
              "id",
              "name",
              "scope"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "read",
                  "write"
                ]
              }
            }
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "item.created",
          "item.updated",
          "item.deleted",
          "item.quantityChanged",
          "item.lowStock",
          "supplier.created",
          "supplier.updated",
          "supplier.deleted",
          "batch.expiringSoon",
          "batch.expired",
          "purchaseOrder.created",
          "purchaseOrder.sent",
          "purchaseOrder.received",
          "transfer.completed",
          "count.completed",
          "approval.requested",
          "approval.resolved"
        ]
      },
      "ApiHook": {
        "type": "object",
        "required": [
          "id",
          "url",
          "events",
          "enabled",
          "source",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "source": {
            "type": "string",
            "example": "zapier",
            "description": "zapier or make."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiHookCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiHook"
          },
          {
            "type": "object",
            "required": [
              "secret"
            ],
            "properties": {
              "secret": {
                "type": "string",
                "example": "whsec_…",
                "description": "The signing secret. Shown only once."
              }
            }
          }
        ]
      },
      "ApiHookInput": {
        "type": "object",
        "description": "Give `url` (or `targetUrl` / `target_url`) and `event` or `events`.",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "https on a public host."
          },
          "targetUrl": {
            "type": "string",
            "format": "uri"
          },
          "target_url": {
            "type": "string",
            "format": "uri"
          },
          "event": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "zapier",
              "make"
            ],
            "default": "zapier"
          }
        }
      }
    }
  }
}
