{
  "openapi": "3.0.1",
  "info": {
    "title": "Inventory Management",
    "description": "This portion of the API provides endpoints for managing inventory records, including products, purchase orders, and inventory levels",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.ezyvet.com",
      "description": "ezyVet production environment"
    },
    {
      "url": "https://api.trial.ezyvet.com",
      "description": "ezyVet trial environment"
    }
  ],
  "security": [],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api.ezyvet.com/v1/oauth/access_token",
            "scopes": {
              "inventory-management": "Access inventory management resources",
              "practice-management": "Access practice management resources",
              "read-barcode": "Read barcode resources",
              "read-batch": "Read batch resources",
              "write-batch": "Create and update batch resources",
              "read-product": "Read product resources",
              "read-productgroup": "Read product group resources",
              "read-productminimumstock": "Read product minimum stock resources",
              "read-productpricing": "Read product pricing resources",
              "write-productpricing": "Create and update product pricing resources",
              "read-productsupplier": "Read product supplier resources",
              "read-purchaseorder": "Read purchase order resources",
              "read-purchaseorderitem": "Read purchase order item resources",
              "read-receiveinvoice": "Read receive invoice resources",
              "write-receiveinvoice": "Create, update and delete receive invoice resources",
              "read-receiveinvoiceitem": "Read receive invoice item resources",
              "write-receiveinvoiceitem": "Create, update and delete receive invoice item resources",
              "read-stockadjustment": "Read stock adjustment resources",
              "write-stockadjustment": "Create and update stock adjustment resources",
              "read-stockadjustmentitem": "Read stock adjustment item resources",
              "write-stockadjustmentitem": "Create and update stock adjustment item resources",
              "read-stocktransaction": "Read stock transaction resources"
            }
          }
        }
      }
    },
    "parameters": {
      "locationUID": {
        "name": "locationUID",
        "in": "query",
        "required": true,
        "description": "The UID of the location or separation (e.g. business unit, entity, department)",
        "schema": {
          "type": "string",
          "format": "uid"
        }
      },
      "next_token": {
        "name": "next_token",
        "in": "query",
        "description": "Token for fetching the next page of results, obtained from `meta.next_token` in the previous response. Malformed or tampered values return 400 Bad Request, as does a token issued under a different sort order than the supplied filters imply — restart pagination without `next_token` when the filters change. The legacy `offset` parameter is not supported and will return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "AB3e7Z2i9FJu0j7hLExLp"
      },
      "page_size": {
        "name": "page_size",
        "in": "query",
        "description": "Number of items per page. Default is 2000, maximum is 2000. The legacy `limit` parameter is not supported and will return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "integer",
          "default": 2000,
          "minimum": 1,
          "maximum": 2000
        },
        "example": 200
      },
      "stx21_active": {
        "name": "active",
        "in": "query",
        "description": "JSON comparator object filtering on active status, e.g. `{\"eq\":true}`. Supported comparators: `eq`, `neq`. When omitted, only active records are returned. Bare values (`active=1`) return a 400 error.",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":true}"
      },
      "stx21_created_at": {
        "name": "created_at",
        "in": "query",
        "description": "JSON comparator object over the epoch time when the record was created, e.g. `{\"gte\":1695766710,\"lt\":1695853110}`. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`. When supplied without `modified_at`, results are ordered by created time then id. Bare values (`created_at=1695766710`) return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":1695766710,\"lt\":1695853110}"
      },
      "stx21_id": {
        "name": "id",
        "in": "query",
        "description": "JSON comparator object filtering on the Stock Transaction id, e.g. `{\"in\":[42,43]}`. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`. Bare values (`id=42`) return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"in\":[42,43]}"
      },
      "stx21_inventory_location_id": {
        "name": "inventory_location_id",
        "in": "query",
        "description": "JSON comparator object filtering on the inventory location a Stock Transaction belongs to, e.g. `{\"eq\":3}`. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`. The value is the location's numeric id, returned as `inventory_location_id` and listed by `GET /v2/separation`. Use `in` to cover several locations in one request. A Stock Transaction whose owner is not an inventory location reports null for that field: `neq` keeps those records, every other comparator excludes them. Does not affect result order.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":3}"
      },
      "stx21_inventory_location_uid": {
        "name": "inventory_location_uid",
        "in": "query",
        "description": "JSON comparator object filtering on the UID of the inventory location a Stock Transaction belongs to, e.g. `{\"eq\":\"ownershipSeparation_zatHyPOMfXQsuVfEYXbHP\"}`. Supported comparators: `eq`, `neq`, `in` — a UID is opaque, so it is matched whole rather than by pattern: any non-empty value of up to 50 characters is accepted, and a value no location carries selects nothing. The value is the one returned as `inventory_location_uid`. Prefer it over `inventory_location_id` when the same integration covers more than one site, because a UID is stable across sites and the numeric id is not. Transactions whose owner is not an inventory location report a null uid: `eq` and `in` cannot select them, while `neq` keeps them. A location whose uid has never been populated cannot be selected by this filter either — use `inventory_location_id`. Does not affect result order.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"ownershipSeparation_zatHyPOMfXQsuVfEYXbHP\"}"
      },
      "stx21_modified_at": {
        "name": "modified_at",
        "in": "query",
        "description": "JSON comparator object over the epoch time when the record was last modified, e.g. `{\"gte\":1695766710,\"lt\":1695853110}`. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`. When supplied, results are ordered by modified time then id. Bare values (`modified_at=1695766710`) return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":1695766710,\"lt\":1695853110}"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BadRequest"
            }
          }
        }
      },
      "ContentTooLarge": {
        "description": "Content Too Large — request array exceeds the 100-item batch limit. No\npurchase orders are created.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden — token does not include the `practice-management` scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "500"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "An internal server error occurred"
                },
                "detail": {
                  "type": "string",
                  "example": "An error occured, please contact API support with the id, status and code provided with the response."
                }
              }
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "internal_error": {
                "summary": "Internal server error",
                "value": {
                  "errors": [
                    {
                      "status": "500",
                      "code": "InternalError",
                      "detail": "An internal server error occurred."
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "text/html": {
            "schema": {
              "type": "string",
              "example": "No input file specified."
            }
          }
        }
      },
      "stx21_BadRequest": {
        "description": "Bad Request — returned when unsupported parameters (e.g. `limit`, `offset`) are used.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/StockTransactionErrorResponse"
            }
          }
        }
      },
      "stx21_InternalError": {
        "description": "Internal error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "500"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "An internal server error occurred"
                },
                "detail": {
                  "type": "string",
                  "example": "An error occurred, please contact API support with the id, status and code provided with the response."
                }
              }
            }
          }
        }
      },
      "stx21_Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "messages": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "level": {
                        "type": "string",
                        "example": "error"
                      },
                      "type": {
                        "type": "string",
                        "example": "InvalidRequestException"
                      },
                      "text": {
                        "type": "string",
                        "example": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \"access token\" parameter."
                      },
                      "fields": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "example": []
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "429"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Too Many Requests"
                },
                "detail": {
                  "type": "string",
                  "example": "Too Many Requests"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "messages": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "level": {
                        "type": "string",
                        "example": "error"
                      },
                      "type": {
                        "type": "string",
                        "example": "InvalidRequestException"
                      },
                      "text": {
                        "type": "string",
                        "example": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \\\"access token\\\" parameter."
                      },
                      "fields": {
                        "type": "array",
                        "example": [],
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "422"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                },
                "detail": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "BadRequest": {
        "description": "Bad Request",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_3YLvb0V7eXcHqgGauTjDy"
                },
                "status": {
                  "type": "string",
                  "example": "400"
                },
                "code": {
                  "type": "string",
                  "example": "100001"
                },
                "title": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                },
                "detail": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                }
              }
            }
          }
        }
      },
      "BalanceItem": {
        "type": "object",
        "properties": {
          "productUid": {
            "type": "string",
            "description": "UID of the product."
          },
          "product": {
            "type": "string",
            "description": "Product name."
          },
          "code": {
            "type": "string",
            "description": "Product code."
          },
          "available": {
            "type": "number",
            "format": "float",
            "description": "Quantity available (QOH)."
          }
        },
        "required": [
          "productUid",
          "product",
          "code",
          "available"
        ]
      },
      "BalancesResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BalanceItem"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "Batchv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "parent": {
            "type": "number"
          },
          "expiry": {
            "type": "number"
          }
        }
      },
      "BulkUpsertServiceFeeData": {
        "type": "array",
        "description": "Array of processed service fee rows",
        "items": {
          "$ref": "#/components/schemas/ProductOwnershipServiceFee"
        }
      },
      "BulkUpsertServiceFeeMeta": {
        "type": "object",
        "description": "Response metadata for bulk upsert endpoint",
        "properties": {
          "totalItems": {
            "type": "integer",
            "description": "Number of service fee rows processed in this request",
            "example": 3
          }
        },
        "required": [
          "totalItems"
        ]
      },
      "BulkUpsertServiceFeeRequest": {
        "type": "array",
        "description": "Service fee rows to add or remove",
        "minItems": 1,
        "maxItems": 1000,
        "items": {
          "$ref": "#/components/schemas/ProductOwnershipServiceFee"
        }
      },
      "BulkUpsertServiceFeeResponse": {
        "type": "object",
        "description": "Response for bulk upsert service fee endpoint",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/BulkUpsertServiceFeeData"
          },
          "meta": {
            "$ref": "#/components/schemas/BulkUpsertServiceFeeMeta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "CreateStockAdjustmentItemResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "number"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockAdjustmentItemv1"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "meta",
          "items",
          "messages"
        ]
      },
      "DeleteProductPricingResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "items_processed": {
                "type": "number"
              },
              "transaction_id": {
                "type": "string"
              },
              "timestamp": {
                "type": "number"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "productpricing": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "number"
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "cost_price": {
                      "type": "number"
                    },
                    "based_on": {
                      "type": "string",
                      "enum": [
                        "Price",
                        "Markup"
                      ]
                    },
                    "markup": {
                      "type": "number"
                    },
                    "sell_price": {
                      "type": "number"
                    },
                    "sell_price_tax": {
                      "type": "number"
                    },
                    "tax_rate": {
                      "$ref": "#/components/schemas/TaxRatev1"
                    },
                    "dispense_fee": {
                      "type": "number"
                    },
                    "product_id": {
                      "type": "number"
                    },
                    "ownership_id": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "An error object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Trace ID for error tracking",
            "example": "5280507925319776078"
          },
          "status": {
            "type": "string",
            "description": "HTTP status code as a string",
            "example": "400"
          },
          "code": {
            "type": "string",
            "description": "A unique error code",
            "example": "InvalidParameter"
          },
          "detail": {
            "type": "string",
            "description": "Detailed description of the error",
            "example": "Product ID is required."
          },
          "target": {
            "type": "string",
            "description": "JSON pointer to the invalid field in request payload",
            "example": "/1/serviceFeeProductId"
          }
        },
        "required": [
          "status",
          "code"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Error response that may include multiple errors when multiple service fee lines fail validation.\nFor bulk operations, any error causes the entire request to roll back (no partial updates).\n",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Error"
            },
            "minItems": 1
          }
        },
        "required": [
          "errors"
        ]
      },
      "InventoryMetaObject": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "integer",
            "example": 1731883188
          },
          "currentPage": {
            "type": "integer",
            "example": 1
          },
          "links": {
            "type": "array",
            "items": {
              "properties": {
                "url": {
                  "type": "string",
                  "description": "The urls of different pages",
                  "example": ".../api/v1/inventory/...?page=1"
                },
                "label": {
                  "type": "string",
                  "description": "The label of the page url",
                  "example": "first"
                }
              }
            }
          },
          "path": {
            "type": "string",
            "example": ".../api/v1/inventory/..."
          },
          "perPage": {
            "type": "integer",
            "example": 10000
          }
        }
      },
      "InventoryProducts": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "product_CnDsVPsM4Aq81Px7AHPzn",
            "description": "The UID of the product"
          },
          "name": {
            "type": "string",
            "example": "Diazepam",
            "description": "The name of the product"
          },
          "code": {
            "type": "string",
            "example": "DZP456",
            "description": "The code of the product"
          },
          "unitType": {
            "type": "string",
            "example": "mg",
            "description": "The measured unit of the product"
          },
          "unitCount": {
            "type": "integer",
            "example": 10,
            "description": "The lowest measurable unit amount for the product"
          },
          "batchTracked": {
            "type": "boolean",
            "example": true,
            "description": "Indicates whether the product is batch tracked"
          }
        }
      },
      "InventoryRequirements": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string",
            "example": "product_CnDsVPsM4Aq81Px7AHPzn",
            "description": "The UID of the product"
          },
          "product": {
            "type": "string",
            "example": "Diazepam",
            "description": "The name of the product"
          },
          "code": {
            "type": "string",
            "example": "DZP456",
            "description": "The code of the product"
          },
          "available": {
            "type": "integer",
            "example": 2,
            "description": "The available amount of a product at a location"
          },
          "minimum": {
            "type": "integer",
            "example": 3,
            "description": "The minimum amount of product set by client to reorder"
          },
          "required": {
            "type": "integer",
            "example": 5,
            "description": "The required amount of product set by client"
          }
        }
      },
      "InventorySuppliedProduct": {
        "type": "object",
        "required": [
          "productId",
          "supplied"
        ],
        "properties": {
          "productId": {
            "type": "string",
            "example": "product_MZcxwWMf9lprsWC8MH2OF",
            "description": "Unique identifier for the product."
          },
          "supplied": {
            "type": "number",
            "example": 5,
            "description": "Quantity of the product. Must be positive."
          },
          "batch": {
            "type": "object",
            "required": [
              "code",
              "expireAt"
            ],
            "properties": {
              "code": {
                "type": "string",
                "example": "777-3321",
                "description": "The code of the batch for the product"
              },
              "expireAt": {
                "type": "string",
                "format": "date",
                "example": "2024-01-23",
                "description": "The expiry date of the batch"
              }
            }
          }
        }
      },
      "Messages": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "example": []
      },
      "Meta": {
        "type": "object",
        "description": "Pagination metadata. When more pages exist, `next_token` contains the token for the next page.",
        "properties": {
          "next_token": {
            "type": "string",
            "nullable": true,
            "description": "Token for fetching the next page. Null or absent when there are no more pages.",
            "example": "AB3e7Z2i9FJu0j7hLExLp"
          }
        }
      },
      "Metav1": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string"
          },
          "items_page": {
            "type": "string"
          },
          "items_page_total": {
            "type": "string"
          },
          "items_page_size": {
            "type": "string"
          },
          "items_total": {
            "type": "string"
          }
        }
      },
      "PaginationLink": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "example": "next"
          },
          "url": {
            "type": "string",
            "example": "/v2/balances?nextToken=eyJsYXN0Q29kZSI6Ik..."
          }
        },
        "required": [
          "label",
          "url"
        ]
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp of the response."
          },
          "path": {
            "type": "string",
            "description": "API path for the request."
          },
          "perPage": {
            "type": "integer",
            "description": "Number of items returned per page."
          },
          "nextToken": {
            "type": "string",
            "description": "Pagination token for retrieving the next page."
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaginationLink"
            }
          }
        }
      },
      "ProductOwnershipServiceFee": {
        "type": "object",
        "description": "Patch instruction for one product ownership service fee row",
        "properties": {
          "productId": {
            "type": "integer",
            "description": "Product ID",
            "example": 132
          },
          "ownershipId": {
            "type": "integer",
            "description": "Ownership Separation ID",
            "example": 465
          },
          "serviceFeeProductId": {
            "type": "integer",
            "nullable": true,
            "description": "Service fee product ID to associate with this product at this ownership level.\n- Provide an integer ID to add the service fee association.\n- Provide `null` to remove the existing service fee association.\n",
            "example": 88
          }
        },
        "required": [
          "productId",
          "ownershipId",
          "serviceFeeProductId"
        ]
      },
      "PurchaseOrder": {
        "type": "object",
        "description": "A purchase order as returned by the API.",
        "required": [
          "id",
          "supplierId",
          "ownershipId",
          "date",
          "shipping",
          "status",
          "subtotalExcludingTax",
          "tax",
          "rounding",
          "total",
          "lines"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "UID of the PurchaseOrder.",
            "readOnly": true,
            "example": "purchaseorder_AB3e7Z2i9FJu0j7hLExLp"
          },
          "supplierId": {
            "type": "string",
            "description": "UID of the Contact that is the supplier.",
            "example": "contact_AB3e7Z2i9FJu0j7hLExLp"
          },
          "ownershipId": {
            "type": "string",
            "nullable": true,
            "description": "UID of the Ownership the PO belongs to. May be `null` on POs\ncreated before the field was enforced as non-nullable; always\npresent on POs created via this endpoint.\n",
            "example": "ownership_5Lh7q9XBxT4dfNYwVo2zP"
          },
          "date": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 document date.",
            "example": "2026-05-15T09:30:00Z"
          },
          "clientId": {
            "type": "string",
            "nullable": true,
            "description": "UID of the client (if applicable).",
            "example": "contact_2Lk8m4FRtY1eqMSwVo2zP"
          },
          "shipping": {
            "$ref": "#/components/schemas/Shipping"
          },
          "purchaseOrderNumber": {
            "type": "string",
            "nullable": true,
            "description": "External/supplier-supplied PO number (as accepted on create).",
            "example": "EXT-PO-77882"
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "description": "Free-text notes.",
            "example": "Auto-generated by inventory replenishment system"
          },
          "freight": {
            "type": "number",
            "format": "double",
            "description": "Freight cost excluding tax.",
            "example": 5
          },
          "freightTax": {
            "type": "number",
            "format": "double",
            "description": "Absolute tax component of the freight cost.",
            "example": 0.5
          },
          "freightTaxRate": {
            "type": "number",
            "format": "double",
            "description": "Tax rate applied to `freight`, as a decimal fraction (e.g. `0.10` for 10%).\nWhen the client supplied `freightTax` instead of `freightTaxRate`, the\nserver derives the rate from `freightTax / freight`. Returned as `null`\nwhen `freight == 0` (the rate is undefined in that case) or when neither\n`freightTax` nor `freightTaxRate` was supplied.\n",
            "nullable": true,
            "example": 0.1
          },
          "status": {
            "$ref": "#/components/schemas/PurchaseOrderStatus"
          },
          "subtotalExcludingTax": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "Sum of `lines[*].lineTotalExcludingTax` + `freight`.",
            "example": 205
          },
          "tax": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "Sum of `lines[*].lineTotalTax` + `freightTax`.",
            "example": 20.5
          },
          "rounding": {
            "type": "number",
            "format": "double",
            "description": "Currency rounding adjustment applied to the total.",
            "example": 0.02
          },
          "total": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "`subtotalExcludingTax` + `tax` + `rounding`.",
            "example": 225.52
          },
          "lines": {
            "type": "array",
            "description": "PO line items.",
            "items": {
              "$ref": "#/components/schemas/PurchaseOrderLine"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "ISO 8601 timestamp when the PO was created.",
            "example": "2026-05-15T09:30:05Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "ISO 8601 timestamp when the PO was last modified.",
            "example": "2026-05-15T09:30:05Z"
          }
        }
      },
      "PurchaseOrderCreate": {
        "type": "object",
        "description": "Request body for creating a purchase order. Derived fields (totals,\ntax, status, timestamps, line totals) are rejected if supplied.\n",
        "required": [
          "supplierId",
          "ownershipId",
          "date",
          "shipping"
        ],
        "additionalProperties": false,
        "properties": {
          "supplierId": {
            "type": "string",
            "description": "UID of the Contact that is acting as the supplier. Must be an\nactive contact and flagged as a supplier.\n",
            "example": "contact_AB3e7Z2i9FJu0j7hLExLp"
          },
          "ownershipId": {
            "type": "string",
            "description": "UID of the Ownership (location separation root) the PO belongs to.",
            "example": "ownership_5Lh7q9XBxT4dfNYwVo2zP"
          },
          "date": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp the PO is dated. Used as the document date that\nappears on the PO and in supplier integrations.\n",
            "example": "2026-05-15T09:30:00Z"
          },
          "clientId": {
            "type": "string",
            "description": "Optional UID of the Contact that is receiving the goods (e.g. a\nclient for drop-ship orders). Required when `shipping.shipType`\nis `client`.\n",
            "nullable": true,
            "example": "contact_2Lk8m4FRtY1eqMSwVo2zP"
          },
          "shipping": {
            "$ref": "#/components/schemas/Shipping"
          },
          "purchaseOrderNumber": {
            "type": "string",
            "description": "External/supplier-supplied PO number that appears on the document.\nDistinct from the system-generated UID returned in `id` and from\nthe system-assigned numeric purchase order number displayed in the UI.\n",
            "nullable": true,
            "maxLength": 50,
            "example": "EXT-PO-77882"
          },
          "notes": {
            "type": "string",
            "description": "Free-text notes for the supplier or internal commentary.",
            "nullable": true,
            "example": "Auto-generated by inventory replenishment system"
          },
          "freight": {
            "type": "number",
            "format": "double",
            "description": "Freight cost excluding tax. Defaults to 0 if omitted.",
            "default": 0,
            "minimum": 0,
            "example": 5
          },
          "freightTax": {
            "type": "number",
            "format": "double",
            "description": "Absolute tax component of the freight cost. Optional — omit\nentirely to let the server derive it from `freightTaxRate`, or\nto indicate \"no freight tax\".\nMutually exclusive with `freightTaxRate` — supply one or the other,\nnot both. If both are supplied the request is rejected with 400\n`InvalidRequestBody`.\n",
            "nullable": true,
            "minimum": 0,
            "example": 0.5
          },
          "freightTaxRate": {
            "type": "number",
            "format": "double",
            "description": "Tax rate applied to `freight`, expressed as a decimal fraction\n(e.g. `0.10` for 10%). Server computes `freightTax = freight * freightTaxRate`\nand persists both. Mutually exclusive with `freightTax`. Ignored\n(and rejected) when `freight == 0`. If neither `freightTax` nor\n`freightTaxRate` is supplied, the server defaults the rate to\nthe system default GST rate.\n",
            "nullable": true,
            "minimum": 0,
            "example": 0.1
          },
          "rounding": {
            "type": "number",
            "format": "double",
            "description": "Currency rounding adjustment applied to the total. Positive or negative.\nDefaults to 0. Server computes `total = subtotalExcludingTax + tax + rounding`.\n",
            "default": 0,
            "example": 0.02
          },
          "lines": {
            "type": "array",
            "description": "Optional list of PO line items. May be omitted or empty — a draft PO\nwith no lines is permitted (matches existing UI behaviour).\n",
            "items": {
              "$ref": "#/components/schemas/PurchaseOrderLineCreate"
            }
          }
        }
      },
      "PurchaseOrderLine": {
        "type": "object",
        "description": "A purchase order line item as returned by the API.",
        "required": [
          "id",
          "productId",
          "quantity",
          "unitPriceExcludingTax",
          "taxPerUnit",
          "discount",
          "outers",
          "unitsPerOuter",
          "lineTotalExcludingTax",
          "lineTotalTax",
          "order"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "description": "UID of the line item (purchaseorderexpense).",
            "example": "purchaseorderexpense_AB3e7Z2i9FJu0j7hLExLp"
          },
          "productId": {
            "type": "string",
            "description": "UID of the product.",
            "example": "product_ljBNFkNYUWi06cHcB9kOy"
          },
          "supplierCode": {
            "type": "string",
            "nullable": true,
            "description": "Supplier's code for this product on this line.",
            "example": "BND-2M"
          },
          "quantity": {
            "type": "number",
            "format": "double",
            "description": "Units ordered. Up to ~7 significant digits are stored.",
            "example": 2
          },
          "unitPriceExcludingTax": {
            "type": "string",
            "format": "decimal",
            "description": "Pre-discount per-unit price excluding tax, as a decimal string.\nUp to 10 digits before the decimal point and up to 4 after are stored.\n",
            "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
            "example": "100.0000"
          },
          "taxPerUnit": {
            "type": "string",
            "format": "decimal",
            "readOnly": true,
            "description": "Server-derived pre-discount per-unit tax component (absolute,\nnot a percentage), computed from the request's `taxRate` as\n`unitPriceExcludingTax * (taxRate / 100)`. Up to 10 digits before\nthe decimal point and up to 4 after are stored.\n",
            "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
            "example": "10.0000"
          },
          "discount": {
            "type": "string",
            "format": "decimal",
            "description": "Per-line discount percentage applied to derive the line totals,\nas a decimal string. Up to 2 digits after the decimal point are stored.\n",
            "pattern": "^(100(\\.0{1,2})?|\\d{1,2}(\\.\\d{1,2})?)$",
            "example": "10.00"
          },
          "outers": {
            "type": "number",
            "format": "double",
            "description": "Number of outers ordered. Fractional values are returned as-is.\n`0` means no packaging info recorded.\n",
            "example": 1
          },
          "unitsPerOuter": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "Units contained in each outer, copied from the productsupplier record\nat the time the line was created. May differ from the current product\nmaster if the supplier later ships a non-standard pack. `0` means no\npackaging info recorded.\n",
            "example": 2
          },
          "lineTotalExcludingTax": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "`quantity * unitPriceExcludingTax * (1 - discount/100)`.\n",
            "example": 180
          },
          "lineTotalTax": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "description": "`quantity * taxPerUnit * (1 - discount/100)`.\n",
            "example": 18
          },
          "order": {
            "type": "integer",
            "description": "Display order of this line within the PO (0-based).",
            "minimum": 0,
            "example": 0
          }
        }
      },
      "PurchaseOrderLineCreate": {
        "type": "object",
        "description": "A purchase order line item supplied at creation time.",
        "required": [
          "productId",
          "quantity",
          "supplierCode"
        ],
        "additionalProperties": false,
        "properties": {
          "productId": {
            "type": "string",
            "description": "UID of the product being ordered.",
            "example": "product_ljBNFkNYUWi06cHcB9kOy"
          },
          "supplierCode": {
            "type": "string",
            "description": "Supplier's code for this product. Required — callers that don't\nalready hold a code should look it up from the supplier's\nproduct record before posting.\n",
            "maxLength": 100,
            "minLength": 1,
            "example": "BND-2M"
          },
          "quantity": {
            "type": "number",
            "format": "double",
            "description": "Number of units ordered. Up to ~7 significant digits are stored;\nfractional inputs beyond that precision are silently truncated.\n",
            "minimum": 0,
            "example": 2
          },
          "unitPriceExcludingTax": {
            "type": "string",
            "format": "decimal",
            "description": "Pre-discount per-unit price excluding tax, as a decimal string\nto preserve precision. Up to 10 digits before the decimal point\nand up to 4 after are stored. Must be >= 0. The server applies\n`discount` to derive the post-discount per-unit price and the\nline total (`lineTotalExcludingTax`).\n",
            "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
            "default": "0",
            "example": "100.0000"
          },
          "taxRate": {
            "type": "string",
            "format": "decimal",
            "description": "Tax rate applied to this line as a decimal percentage (not a\nfraction) — e.g. `\"10.00\"` for 10%. Carried as a decimal string\nto preserve precision. Must satisfy 0 <= taxRate <= 100. If\nomitted the server uses the supplier-configured rate for the\nproduct. The server derives the absolute per-unit tax by\ncomputing `unitPriceExcludingTax * (taxRate / 100)`; the\nabsolute value appears on the response as `taxPerUnit`.\n",
            "pattern": "^(100(\\.0{1,4})?|\\d{1,2}(\\.\\d{1,4})?)$",
            "nullable": true,
            "example": "10.00"
          },
          "discount": {
            "type": "string",
            "format": "decimal",
            "description": "Per-line discount percentage as a decimal string. `0` means no\ndiscount, `100` means free. Up to 2 digits after the decimal\npoint are stored. Must satisfy 0 <= discount <= 100. Server\ncomputes the post-discount price and totals.\n",
            "pattern": "^(100(\\.0{1,2})?|\\d{1,2}(\\.\\d{1,2})?)$",
            "default": "0",
            "example": "10.00"
          },
          "outers": {
            "type": "number",
            "format": "double",
            "description": "Number of outers (cartons / cases) ordered — packaging metadata\nat the time of order, in a different unit basis from `quantity`\n(`quantity` is in base units). Defaults to 0 when omitted, to\nindicate \"no packaging info supplied\". Fractional outers are\naccepted (e.g. half-cartons in bulk-pharmacy workflows).\n",
            "default": 0,
            "minimum": 0,
            "example": 1
          },
          "order": {
            "type": "integer",
            "description": "Display order of this line within the PO (0-based). When omitted, the\nserver preserves the order of `lines[]` in the request.\n",
            "nullable": true,
            "minimum": 0,
            "example": 0
          }
        }
      },
      "PurchaseOrderStatus": {
        "type": "string",
        "description": "Lifecycle status of a purchase order. New POs created via this endpoint\nalways start in `Created`. Subsequent transitions happen through the\napproval / send / receive workflow (separate endpoints).\n",
        "enum": [
          "Created",
          "Approved",
          "Sent",
          "Confirmed",
          "PartiallyReceived",
          "Received",
          "Completed",
          "Canceled"
        ],
        "example": "Created"
      },
      "ReceiveInvoiceItemResponsev1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean",
            "default": true
          },
          "quantity": {
            "type": "number"
          },
          "price": {
            "type": "number"
          },
          "tax": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "total_tax": {
            "type": "number"
          },
          "tax_rate": {
            "type": "number"
          },
          "tax_code": {
            "type": "string"
          },
          "product_id": {
            "type": "number"
          },
          "product_supplier_id": {
            "type": "number"
          },
          "supplier_code": {
            "type": "string"
          },
          "location_id": {
            "type": "number"
          },
          "batch": {
            "type": "array",
            "items": {}
          },
          "purchase_order_item_id": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "created_at",
          "modified_at",
          "active",
          "quantity",
          "price",
          "tax",
          "total",
          "total_tax",
          "tax_rate",
          "tax_code",
          "product_id",
          "product_supplier_id",
          "supplier_code",
          "location_id",
          "batch",
          "purchase_order_item_id"
        ]
      },
      "ReceiveInvoiceItemv1": {
        "type": "object",
        "properties": {
          "quantity": {
            "type": "number"
          },
          "price": {
            "type": "number"
          },
          "tax": {
            "type": "number"
          },
          "supplier_code": {
            "type": "string"
          },
          "location_id": {
            "type": "number"
          },
          "purchase_order_item_id": {
            "type": "number"
          }
        },
        "required": [
          "quantity",
          "price",
          "tax",
          "supplier_code",
          "location_id"
        ]
      },
      "ReceiveInvoiceResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "string"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "receiveinvoice": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "active": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "string"
                        }
                      ],
                      "default": true
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "modified_at": {
                      "type": "string"
                    },
                    "invoice_number": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "due_date": {
                      "type": "string"
                    },
                    "supplier_id": {
                      "type": "string"
                    },
                    "freight": {
                      "type": "string"
                    },
                    "freight_tax": {
                      "type": "string"
                    },
                    "comments": {
                      "type": "string"
                    },
                    "tax": {
                      "type": "string"
                    },
                    "total": {
                      "type": "string"
                    },
                    "purchase_order_list": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string"
                          }
                        ]
                      }
                    },
                    "receive_invoice_item_list": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "ownership_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "messages": {
            "type": "array",
            "items": {}
          }
        }
      },
      "Responsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/Metav1"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockAdjustmentItemv1"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Shipping": {
        "type": "object",
        "description": "Where and how the supplier should ship. For `customAddress`, supply the\naddress fields inline; for the other types the destination is derived\nat render time from the linked supplier/business/client.\n",
        "required": [
          "shipType"
        ],
        "additionalProperties": false,
        "properties": {
          "shipType": {
            "type": "string",
            "description": "- `pickup` — collected from the supplier; no destination address.\n- `business` — shipped to the business address of the PO's ownership.\n- `client` — shipped to the client contact's address (requires top-level `clientId`).\n- `customAddress` — shipped to the inline `address` object (required).\n",
            "enum": [
              "pickup",
              "business",
              "client",
              "customAddress"
            ],
            "example": "business"
          },
          "address": {
            "$ref": "#/components/schemas/ShippingAddress"
          }
        }
      },
      "ShippingAddress": {
        "type": "object",
        "description": "Inline shipping address. Required only when `shipType=customAddress`.",
        "required": [
          "street1",
          "city",
          "postcode",
          "countryCode"
        ],
        "additionalProperties": false,
        "properties": {
          "street1": {
            "type": "string",
            "maxLength": 100,
            "example": "123 Industrial Park Rd"
          },
          "street2": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": "Warehouse 4"
          },
          "suburb": {
            "type": "string",
            "nullable": true,
            "maxLength": 50,
            "example": "Penrose"
          },
          "city": {
            "type": "string",
            "maxLength": 50,
            "example": "Auckland"
          },
          "region": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": "Auckland"
          },
          "state": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": ""
          },
          "postcode": {
            "type": "string",
            "maxLength": 45,
            "example": "1061"
          },
          "countryCode": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code (e.g. `NZ`, `AU`, `US`).\n",
            "minLength": 2,
            "maxLength": 2,
            "example": "NZ"
          }
        }
      },
      "StockAdjustmentItemv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "stockadjustment_id": {
            "type": "number"
          },
          "product_id": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "price": {
            "type": "number",
            "description": "The unit price recorded against the adjustment. Equivalent to `cost_price`; if both are supplied, `price` wins."
          },
          "cost_price": {
            "type": "number",
            "minimum": 0,
            "description": "The unit cost (purchase) price of the stock being adjusted, recorded against the adjustment in the same way as a cost price entered on a manual inventory adjustment in ezyVet. `cost_price` is a synonym of `price` - both write to the same value on the StockAdjustmentItem, so send one or the other. If both are supplied, `price` takes precedence and `cost_price` is ignored. Must be a non-negative number. When neither `price` nor `cost_price` is supplied, the adjustment defaults to the product's cost price for the line's ownership/location."
          },
          "ledger_account": {
            "type": "number"
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Allocated",
              "Finalised"
            ]
          },
          "batch": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Batchv1"
            }
          },
          "location_id": {
            "type": "number"
          }
        }
      },
      "StockAdjustmentItemWrapperv1": {
        "type": "object",
        "properties": {
          "stockadjustment": {
            "$ref": "#/components/schemas/StockAdjustmentv1"
          }
        }
      },
      "StockAdjustmentsResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/Metav1"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockAdjustmentItemWrapperv1"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "StockAdjustmentv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "date": {
            "type": "number"
          },
          "amount": {
            "type": "number",
            "default": 0
          },
          "comments": {
            "type": "string",
            "default": ""
          },
          "line_item": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockAdjustmentItemv1"
            }
          },
          "ownership_id": {
            "type": "number"
          }
        }
      },
      "StockTransaction": {
        "type": "object",
        "description": "Stock Transaction record in v2.1 format: the v2 field set plus `inventory_location_id` and `inventory_location_uid`.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Legacy integer identifier for the Stock Transaction.",
            "example": 42
          },
          "created_at": {
            "type": "integer",
            "description": "Unix epoch timestamp when the Stock Transaction was created.",
            "example": 1705312200
          },
          "modified_at": {
            "type": "integer",
            "description": "Unix epoch timestamp when the Stock Transaction was last modified.",
            "example": 1734705720
          },
          "active": {
            "type": "boolean",
            "description": "If true, the Stock Transaction is active and usable in ezyVet.",
            "example": true
          },
          "quantity": {
            "type": "string",
            "description": "The quantity of the Stock Transaction (v2 returns a decimal string).",
            "example": "-3.0000"
          },
          "alter_stock": {
            "type": "boolean",
            "description": "If true, the Stock Transaction alters stock.",
            "example": true
          },
          "inventory_location_id": {
            "type": "integer",
            "nullable": true,
            "description": "The inventory location this Stock Transaction belongs to. Null, along with the uid, when the transaction's owner is not an inventory location.",
            "example": 3
          },
          "inventory_location_uid": {
            "type": "string",
            "nullable": true,
            "description": "The globally unique identifier of the same inventory location, stable across sites where `inventory_location_id` is not. Null when the owner is not an inventory location, and on the rare location record whose uid has never been populated.",
            "example": "ownershipSeparation_zatHyPOMfXQsuVfEYXbHP"
          },
          "separation_id": {
            "type": "integer",
            "deprecated": true,
            "description": "The Stock Transaction's raw ownership-separation id, under the name and semantics v2 uses. Retained so an integration moving from v2 keeps working; `inventory_location_id` and `inventory_location_uid` are the supported fields. Unlike those it is populated on every record, including one whose owner is not an inventory location, and it is coerced to an integer as v2 coerces it, so an absent ownership reads as 0 rather than null.",
            "example": 3
          },
          "for_id": {
            "type": "integer",
            "description": "The for ID of the Stock Transaction.",
            "example": 4
          },
          "for_class": {
            "type": "string",
            "description": "The for class of the Stock Transaction.",
            "example": "InvoiceExpense"
          },
          "product_id": {
            "type": "integer",
            "nullable": true,
            "description": "Related product ID when resolvable (same as v2).",
            "example": 5012
          },
          "status": {
            "type": "string",
            "description": "Status, lowercase (pending, allocated, finalised). Note: the v2 endpoint returns this capitalized (Finalised/Allocated); v2.1 normalizes to lowercase.",
            "example": "allocated"
          },
          "date": {
            "type": "integer",
            "description": "Unix epoch timestamp for the transaction date (v2).",
            "example": 1492043940
          }
        }
      },
      "StockTransactionErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "example": "bad request"
                },
                "details": {
                  "type": "string",
                  "example": "The \"limit\" parameter is not supported. Use \"page_size\" instead."
                }
              }
            }
          }
        }
      },
      "StockTransactionItem": {
        "type": "object",
        "description": "v2-style list item wrapper (resource key matches v2 `stocktransaction`).",
        "properties": {
          "stocktransaction": {
            "$ref": "#/components/schemas/StockTransaction"
          }
        }
      },
      "StockTransactionListResponse": {
        "type": "object",
        "description": "Standard v2-style response envelope with token-based pagination.",
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockTransactionItem"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TaxRatev1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "rate": {
            "type": "number"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "PurchaseOrder",
      "description": "A purchase order is an instruction sent to a supplier to deliver products\nto a hospital. Once created via this endpoint the PO enters the `Created`\nstatus and can be progressed through the approval workflow in the UI.\n\nEach line references a product. Client-supplied fields:\n\n- `supplierCode`\n- `quantity`\n- `outers` (cartons)\n- `unitPriceExcludingTax`\n- `taxRate` (as a percentage)\n- `discount` (as a percentage)\n\nServer-computed fields (do not include in the request):\n\n- per-line totals (`lineTotalExcludingTax`, `lineTotalTax`)\n- header totals (`subtotalExcludingTax`, `tax`, `total`)\n- `unitsPerOuter` — copied from the supplier's product record\n- `taxPerUnit` — derived from `unitPriceExcludingTax` and `taxRate`\n"
    }
  ],
  "paths": {
    "/v1/barcode": {
      "get": {
        "summary": "Fetch a list of Barcodes",
        "description": "Fetches a list containing Barcodes (up to 10).",
        "operationId": "get-barcodes",
        "tags": [
          "Barcode"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The ID number used by the system to uniquely identify a Barcode."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the Barcode was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the Barcode was last modified."
          },
          {
            "name": "for_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The type of record that the Barcode is for. EG: 'product'."
          },
          {
            "name": "for_id",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The ID of the record that the Barcode is for."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "If true, the Barcode is active and usable in ezyVet."
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The format or standard of the system used Barcode. EG: 'EAN-13', or 'CODE128'."
          },
          {
            "name": "barcode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The text content for the Barcode."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "barcode": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "for_type": {
                                "type": "string"
                              },
                              "for_id": {
                                "type": "string"
                              },
                              "format": {
                                "type": "string"
                              },
                              "barcode": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-barcode"
            ]
          }
        ]
      }
    },
    "/v1/product": {
      "get": {
        "summary": "Fetch a Product list",
        "operationId": "get-product",
        "tags": [
          "Product"
        ],
        "description": "Fetches a list containing [`Product`](#product)(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a [`Product`](#product).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If **true**, the [`Product`](#product) is active and usable in ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the [`Product`](#product) was created.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the [`Product`](#product) was last modified.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "description": "String generally used by clinic staff members to identify `Products`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "questions",
            "in": "query",
            "description": "Complex inquiries about the [`Product`](#product). Refer to the `Questions` table.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Name of the [`Product`](#product) as it is visible on ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_group_id",
            "in": "query",
            "description": "The ID of the `ProductGroup` where the [`Product`](#product) is assigned. Every [`Product`](#product) requires a `ProductGroup`. This shows up as the \"Primary Product Group\" on the [`Product`](#product) screen.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "description",
            "in": "query",
            "description": "The description of the [`Product`](#product).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "warning",
            "in": "query",
            "description": "This is where clinic staff can write warning messages regarding the [`Product`](#product), such as \"For external use only\".",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Specifies the [`Product`](#product) type, and where it can be used: `Standard`, `Medication`, `Vaccination`, `Diagnostic`, `Integrated Diagnostic`, `Procedure`",
            "schema": {
              "type": "string",
              "enum": [
                "Standard",
                "Medication",
                "Vaccination",
                "Diagnostic",
                "Integrated Diagnostic",
                "Procedure"
              ],
              "default": "Standard"
            }
          },
          {
            "name": "is_sold",
            "in": "query",
            "description": "If **true**, the [`Product`](#product) can be sold.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_purchased",
            "in": "query",
            "description": "If **true**, the [`Product`](#product) can be bought.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_container",
            "in": "query",
            "description": "If **true**, the [`Product`](#product) acts as a container for other [`Product`](#product)(s).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_derived_price",
            "in": "query",
            "description": "If **true**, the price is derived from all the [`Product`](#product)(s) contained.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "has_direct_cost",
            "in": "query",
            "description": "If **true**, the [`Product`](#product) has the \"has direct cost\" checkmark set and can use markup.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_identifier",
            "in": "query",
            "description": "For the US, this is the 11 digit NDC or product ID for compounds.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_schedule_or_class",
            "in": "query",
            "description": "This is the controlled substances for controlled drugs. For the US, this value is in roman numerals, Eg. II, III, IV,V.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Limits the number of results returned.",
            "schema": {
              "type": "string",
              "default": 10
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Specifies the page number of the result.",
            "schema": {
              "type": "string",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of products with stock levels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "code": {
                                "type": "string"
                              },
                              "product_group_id": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              },
                              "warning": {
                                "type": "string"
                              },
                              "is_sold": {
                                "type": "string"
                              },
                              "is_purchased": {
                                "type": "string"
                              },
                              "is_container": {
                                "type": "string"
                              },
                              "product_identifier": {
                                "type": "string"
                              },
                              "product_schedule_or_class": {
                                "type": "string"
                              },
                              "is_derived_price": {
                                "type": "string"
                              },
                              "has_direct_cost": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "_answers": {
                                "type": "object",
                                "properties": {
                                  "stocklevel": {
                                    "type": "object",
                                    "properties": {
                                      "in_stock": {
                                        "type": "string"
                                      },
                                      "allocated": {
                                        "type": "string"
                                      },
                                      "available": {
                                        "type": "string"
                                      },
                                      "on_order_for_inventory": {
                                        "type": "string"
                                      },
                                      "on_order_total": {
                                        "type": "string"
                                      },
                                      "being_receipted": {
                                        "type": "string"
                                      },
                                      "inventory_turn": {
                                        "type": "string"
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-product"
            ]
          }
        ]
      }
    },
    "/v1/productgroup": {
      "get": {
        "summary": "Fetch a ProductGroup list",
        "operationId": "get-productgroup",
        "tags": [
          "Product Group"
        ],
        "description": "Fetches a list containing ProductGroup(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a ProductGroup."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "If true, the ProductGroup is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the ProductGroup was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the ProductGroup was last modified."
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the ProductGroup."
          },
          {
            "name": "description",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The description of the ProductGroup."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 10
            },
            "description": "Limits the number of items returned."
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 1
            },
            "description": "Specifies the page number of the result."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of ProductGroups",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productgroup": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-productgroup"
            ]
          }
        ]
      }
    },
    "/v1/purchaseorder": {
      "get": {
        "summary": "Fetch a PurchaseOrder list",
        "operationId": "get-purchaseorder",
        "tags": [
          "Purchase Order"
        ],
        "description": "Fetches a list containing `PurchaseOrder`(s). (up to 10)",
        "parameters": [
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the client linked to the `PurchaseOrder`."
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The ID number used by the system to uniquely identify a `PurchaseOrder`."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "If `true`, the `PurchaseOrder` is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The epoch time when the `PurchaseOrder` was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The epoch time when the `PurchaseOrder` was last modified."
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The epoch time of the `PurchaseOrder` transaction date."
          },
          {
            "name": "shipping_address_id",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The ID of the shipping `Address` for the order."
          },
          {
            "name": "comments",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Any comments left by the `User` placing the order."
          },
          {
            "name": "freight",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The total monetary cost of the freight (inc tax)."
          },
          {
            "name": "freight_tax",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The total tax content in the freight amount."
          },
          {
            "name": "tax",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The total tax content of the `PurchaseOrder`."
          },
          {
            "name": "total",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The total monetary amount of the `PurchaseOrder`. This value can be negative, indicating its a return of items. This value is tax inclusive."
          },
          {
            "name": "supplier_id",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The ID of the `supplier` to whom the order is sent."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The status of the `PurchaseOrder`. Can only be one of the following: `Created`, `Approved`, `Sent`, `Confirmed`, `Partial`, `Received`, `Completed` or `Cancelled`."
          },
          {
            "name": "supplier_order_number",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "A number assigned by the `supplier` once an order is placed."
          },
          {
            "name": "supplier_account_number",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "A string assigned on the `supplier` to identify the account the order is made from."
          },
          {
            "name": "ownership_id",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "description": "The ID of the `Ownership Separation` to which this `PurchaseOrder` belongs."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of PurchaseOrders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "purchaseorder": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "date": {
                                "type": "string"
                              },
                              "shipping_address_id": {
                                "type": "string"
                              },
                              "comments": {
                                "type": "string"
                              },
                              "freight": {
                                "type": "string"
                              },
                              "freight_tax": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "client_id": {
                                "type": "string"
                              },
                              "supplier_id": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              },
                              "supplier_order_number": {
                                "type": "string"
                              },
                              "supplier_account_number": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "string"
                              },
                              "purchase_order_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-purchaseorder"
            ]
          }
        ]
      }
    },
    "/v1/purchaseorderitem": {
      "get": {
        "summary": "Fetches a list containing PurchaseOrderItem(s)",
        "operationId": "get-purchaseorderitem",
        "tags": [
          "Purchase Order Item"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a PurchaseOrderItem."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "If true, the PurchaseOrderItem is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the PurchaseOrderItem was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the PurchaseOrderItem was last modified."
          },
          {
            "name": "purchase_order_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID of the PurchaseOrder to which this PurchaseOrderItem is linked."
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID of the product on the PurchaseOrderItem."
          },
          {
            "name": "supplier_code",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The code of the product in the supplier's records."
          },
          {
            "name": "outers",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The number of outers being ordered for the given product."
          },
          {
            "name": "units_per_outer",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The number of units of the product included in one outer."
          },
          {
            "name": "price_per_unit",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The price of one unit in an outer."
          },
          {
            "name": "tax_per_unit",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The tax content per unit."
          },
          {
            "name": "quantity",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The number of units being ordered for the given product."
          },
          {
            "name": "total",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The total monetary amount of the PurchaseOrderItem excluding tax."
          },
          {
            "name": "total_tax",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The total tax content of the PurchaseOrderItem."
          },
          {
            "name": "ownership_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID of the Ownership Separation to which this PurchaseOrderItem belongs."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of PurchaseOrderItems",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "purchaseorderitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "purchase_order_id": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "outers": {
                                "type": "string"
                              },
                              "units_per_outer": {
                                "type": "string"
                              },
                              "price_per_unit": {
                                "type": "string"
                              },
                              "tax_per_unit": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "total_tax": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-purchaseorderitem"
            ]
          }
        ]
      }
    },
    "/v1/receiveinvoice": {
      "get": {
        "summary": "Fetch a list of Receive Invoices",
        "operationId": "get-receiveinvoice",
        "description": "Gets a `ReceiveInvoice` and any included `ReceiveInvoiceItems`\nIt's recommended to use the [`v2/receiveinvoice`](/$get-receiveinvoicev2) endpoint",
        "tags": [
          "Receive Invoice"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a ReceiveInvoice.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ReceiveInvoice is active and usable in ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoice was created.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoice was last modified.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoice_number",
            "in": "query",
            "description": "The value given by a Supplier to track the invoice on their end.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "The epoch time of the ReceiveInvoice transaction date.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "due_date",
            "in": "query",
            "description": "The due date of the ReceiveInvoice in epoch time.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "The ID of the Supplier who sent the ReceiveInvoice.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "freight",
            "in": "query",
            "description": "The total monetary cost of the freight (inc tax).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "freight_tax",
            "in": "query",
            "description": "The total tax content in the freight amount.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "comments",
            "in": "query",
            "description": "Any comments.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tax",
            "in": "query",
            "description": "The total tax content of the ReceiveInvoice.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "total",
            "in": "query",
            "description": "The total monetary amount of the ReceiveInvoice. This value is tax inclusive.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "description": "The ID of the Ownership Separation to which this ReceiveInvoice belongs.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Receive Invoices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoice": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "invoice_number": {
                                "type": "string"
                              },
                              "date": {
                                "type": "string"
                              },
                              "due_date": {
                                "type": "string"
                              },
                              "supplier_id": {
                                "type": "string"
                              },
                              "freight": {
                                "type": "string"
                              },
                              "freight_tax": {
                                "type": "string"
                              },
                              "comments": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "purchase_order_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "receive_invoice_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "ownership_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-receiveinvoice"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a Receive Invoice",
        "operationId": "create-receiveinvoice",
        "tags": [
          "Receive Invoice"
        ],
        "description": "Gets a `ReceiveInvoice` and any included `ReceiveInvoiceItems`\nIt's recommended to use the [`v2/receiveinvoice`](/#get-receiveinvoicev2) endpoint",
        "parameters": [
          {
            "name": "confirm_invoice_number",
            "in": "query",
            "description": "If this contains the value **1**, then the validation for duplicate **invoice_number** will be ignored, allowing the **invoice_number** used on a previous `ReceiveInvoice` to be used on a new `ReceiveInvoice`.",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "description": "Mandatory fields are marked with a `*`.",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "invoice_number",
                  "date",
                  "due_date"
                ],
                "properties": {
                  "invoice_number": {
                    "type": "string",
                    "description": "The value given by a [`Supplier`](#contact) to track the invoice on their end."
                  },
                  "date": {
                    "type": "string",
                    "description": "The epoch time of the [`ReceiveInvoice`](#receiveinvoice) transaction date."
                  },
                  "due_date": {
                    "type": "string",
                    "description": "The due date of the [`ReceiveInvoice`](#receiveinvoice) in epoch time."
                  },
                  "freight": {
                    "type": "string",
                    "description": "The total monetary cost of the freight (inc tax)."
                  },
                  "freight_tax": {
                    "type": "string",
                    "description": "The total tax content in the freight amount."
                  },
                  "comments": {
                    "type": "string",
                    "description": "Any comments."
                  },
                  "ownership_id": {
                    "type": "string",
                    "description": "The ID of the [`Ownership Separation`](#separation) to which this [`ReceiveInvoice`](#receiveinvoice) belongs. *This value defaults to the separation ID of the `Database` if not given.*"
                  },
                  "receive_invoice_item_list": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ReceiveInvoiceItemv1"
                    },
                    "description": "Contains a list of [`ReceiveInvoiceItem`](#receiveinvoiceitem) objects. *Please refer to the `POST` fields for [`ReceiveInvoiceItem`](#receiveinvoiceitem) to understand the values required in each object.*"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiveInvoiceResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoice"
            ]
          }
        ]
      }
    },
    "/v1/receiveinvoice/{id}": {
      "delete": {
        "summary": "Delete a Receive Invoice",
        "operationId": "delete-receiveinvoice",
        "tags": [
          "Receive Invoice"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the ReceiveInvoice to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "description": "Authorization token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful deletion of ReceiveInvoice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoice"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update a Receive Invoice",
        "operationId": "update-receiveinvoice",
        "tags": [
          "Receive Invoice"
        ],
        "description": "Updates a ReceiveInvoice. You may PATCH the associated ReceiveInvoiceItems through the ReceiveInvoiceItem endpoint or this endpoint.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            },
            "description": "The ID number used by the system to uniquely identify a ReceiveInvoice."
          },
          {
            "name": "confirm_invoice_number",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "If this contains the value 1, then the validation for duplicate invoice_number will be ignored."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "number"
                  },
                  "invoice_number": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "freight": {
                    "type": "string"
                  },
                  "freight_tax": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "ownership_id": {
                    "type": "string"
                  },
                  "receive_invoice_item_list": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "number"
                            },
                            "quantity": {
                              "type": "string"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoice": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "invoice_number": {
                                "type": "string"
                              },
                              "date": {
                                "type": "string"
                              },
                              "due_date": {
                                "type": "string"
                              },
                              "supplier_id": {
                                "type": "string"
                              },
                              "freight": {
                                "type": "string"
                              },
                              "freight_tax": {
                                "type": "string"
                              },
                              "comments": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "purchase_order_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "receive_invoice_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "ownership_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoice"
            ]
          }
        ]
      }
    },
    "/v1/receiveinvoiceitem": {
      "get": {
        "summary": "Fetch a list of Receive Invoice Items",
        "operationId": "get-receiveinvoiceitem",
        "tags": [
          "Receive Invoice Item"
        ],
        "description": "Fetches a list containing `ReceiveInvoiceItem(s)`. (up to 10)",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The product ID used by the system to uniquely identify a `ReceiveInvoiceItem`."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Receive Invoice Items",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Responsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-receiveinvoiceitem"
            ]
          }
        ]
      },
      "post": {
        "summary": "Creates a Receive Invoice Item",
        "operationId": "create-receiveinvoiceitem",
        "tags": [
          "Receive Invoice Item"
        ],
        "description": "Creates a ReceiveInvoiceItem. All ReceiveInvoiceItems must be linked to a ReceiveInvoice.\n\nYou cannot add ReceiveInvoiceItems to ReceiveInvoices that are Approved in ezyVet.\n\nA ReceiveInvoiceItem can be linked to a PurchaseOrderItem.",
        "parameters": [
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ReceiveInvoiceItem is active and usable in ezyVet.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "receive_invoice_id",
            "in": "query",
            "description": "The ID of the ReceiveInvoice the ReceiveInvoiceItem is to be linked to.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "description": "The quantity of product invoiced. Depending on the configuration set by the Supplier, this value may represent the quantity of Outers or the quantity of Units.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "price",
            "in": "query",
            "description": "The price of one selling unit. Depending on the configuration set by the Supplier, this value may represent the price of one Outer or the price of one Unit.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tax",
            "in": "query",
            "description": "The tax content per selling unit. Depending on the configuration set by the Supplier, this value may represent the tax amount from one Outer or one Unit.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "supplier_code",
            "in": "query",
            "description": "The code of the product in the supplier's records. (i.e. the code given to the product by the supplier)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "description": "The ID of the Ownership Separation to which this ReceiveInvoiceItem belongs.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "comments",
            "in": "query",
            "description": "Any comments related to the ReceiveInvoiceItem.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "purchase_order_item_id",
            "in": "query",
            "description": "The ID of the PurchaseOrderItem linked to this ReceiveInvoiceItem.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "receive_invoice_id": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "string"
                  },
                  "price": {
                    "type": "string"
                  },
                  "tax": {
                    "type": "string"
                  },
                  "supplier_code": {
                    "type": "string"
                  },
                  "ownership_id": {
                    "type": "string"
                  },
                  "purchase_order_item_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "receive_invoice_id",
                  "quantity",
                  "price",
                  "tax",
                  "supplier_code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receive Invoice Item created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoiceitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "receive_invoice_id": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "string"
                              },
                              "price": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "total_tax": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "string"
                              },
                              "comments": {
                                "type": "string"
                              },
                              "purchase_order_item_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoiceitem"
            ]
          }
        ]
      }
    },
    "/v1/receiveinvoiceitem/{id}": {
      "patch": {
        "summary": "Updates a Receive Invoice Item",
        "operationId": "update-receiveinvoiceitem",
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoiceitem"
            ]
          }
        ],
        "tags": [
          "Receive Invoice Item"
        ],
        "description": "Updates a ReceiveInvoiceItem. You cannot update ReceiveInvoiceItems where the ReceiveInvoice is Approved in ezyVet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a ReceiveInvoiceItem."
          }
        ],
        "requestBody": {
          "description": "Data to update the ReceiveInvoiceItem",
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "string",
                    "description": "If true, the ReceiveInvoiceItem is active and usable in ezyVet."
                  },
                  "receive_invoice_id": {
                    "type": "string",
                    "description": "The ID of the ReceiveInvoice the ReceiveInvoiceItem is linked to."
                  },
                  "quantity": {
                    "type": "string",
                    "description": "The quantity of product invoiced. Depending on the configuration set by the Supplier, this value may represent the quantity of Outers or the quantity of Units."
                  },
                  "price": {
                    "type": "string",
                    "description": "The price of one selling unit. Depending on the configuration set by the Supplier, this value may represent the price of one Outer or the price of one Unit."
                  },
                  "tax": {
                    "type": "string",
                    "description": "The tax content per selling unit. Depending on the configuration set by the Supplier, this value may represent the tax amount from one Outer or one Unit."
                  },
                  "product_id": {
                    "type": "string",
                    "description": "The ID of the product on the ReceiveInvoiceItem."
                  },
                  "comments": {
                    "type": "string",
                    "description": "Any comments related to the ReceiveInvoiceItem."
                  },
                  "ownership_id": {
                    "type": "string",
                    "description": "The ID of the Ownership Separation to which this ReceiveInvoiceItem belongs."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ReceiveInvoiceItem updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoiceitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "receive_invoice_id": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "string"
                              },
                              "price": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "string"
                              },
                              "total": {
                                "type": "string"
                              },
                              "total_tax": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "string"
                              },
                              "comments": {
                                "type": "string"
                              },
                              "purchase_order_item_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "summary": "Delete a Receive Invoice Item",
        "operationId": "delete-receiveinvoiceitem",
        "tags": [
          "Receive Invoice Item"
        ],
        "description": "Deletes a ReceiveInvoiceItem. ReceiveInvoiceItems linked to an Approved ReceiveInvoice cannot be deleted.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the ReceiveInvoiceItem to delete."
          }
        ],
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoiceitem"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully deleted the ReceiveInvoiceItem",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - The item cannot be deleted because it is linked to an Approved ReceiveInvoice."
          },
          "404": {
            "description": "Not Found - The specified ReceiveInvoiceItem ID does not exist."
          }
        }
      }
    },
    "/v2/batch": {
      "get": {
        "summary": "Fetch a list of Batches",
        "operationId": "get-batch",
        "tags": [
          "Batch"
        ],
        "description": "Fetches a list containing Batches (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "required": false,
            "description": "The ID number used by the system to uniquely identify a Batch."
          },
          {
            "name": "uid",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "The ID number used by the system to uniquely identify an Batch across all ezyVet sites."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "required": false,
            "description": "The epoch time when the Batch was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "required": false,
            "description": "The epoch time when the Batch was last modified."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "required": false,
            "description": "If true, the Batch is active and usable in ezyVet."
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "The name given for a Batch."
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "The type of Batch."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Batches",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "batch": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "uid": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "parent": {
                                "type": "number"
                              },
                              "expiry": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-batch"
            ]
          }
        ]
      },
      "post": {
        "summary": "Creates a Batch",
        "operationId": "create-batch",
        "security": [
          {
            "bearerAuth": [
              "write-batch"
            ]
          }
        ],
        "tags": [
          "Batch"
        ],
        "description": "Creates a Batch used to track a batch of products.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "default": "Batch"
                  },
                  "product_id": {
                    "type": "number"
                  }
                },
                "required": [
                  "name",
                  "product_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "batch": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "uid": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean",
                                "default": true
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "parent": {
                                "type": "number"
                              },
                              "expiry": {
                                "type": "number",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/product/{product_id}": {
      "get": {
        "summary": "Fetch a Specific Product",
        "operationId": "get-productv2",
        "tags": [
          "Product V2"
        ],
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "description": "The ID number used by the system to uniquely identify a Product.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": true,
            "description": "Bearer token for authentication",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A specific product by its id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number",
                                "description": "The unique ID of the product.",
                                "example": 1234
                              },
                              "created_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product was created.",
                                "example": 1706745600
                              },
                              "modified_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product was last modified.",
                                "example": 1706832000
                              },
                              "active": {
                                "type": "boolean",
                                "description": "Whether the product is active and usable in ezyVet.",
                                "example": true
                              },
                              "name": {
                                "type": "string",
                                "description": "The display name of the product.",
                                "example": "Amoxicillin 250mg"
                              },
                              "code": {
                                "type": "string",
                                "description": "A short alphanumeric code used to identify the product.",
                                "example": "AMOX250"
                              },
                              "description": {
                                "type": "string",
                                "description": "An optional text description of the product.",
                                "example": "Broad-spectrum antibiotic for dogs and cats."
                              },
                              "type": {
                                "type": "string",
                                "description": "The category type of the product.",
                                "enum": [
                                  "Standard",
                                  "Medication",
                                  "Vaccination",
                                  "Diagnostic",
                                  "Integrated Diagnostic",
                                  "Procedure"
                                ],
                                "example": "Medication"
                              },
                              "tracking_level": {
                                "type": "string",
                                "description": "Controls how inventory is tracked for this product. 'No' means no tracking, 'Product' tracks by product, 'Batch' tracks individual batches/lots.",
                                "enum": [
                                  "No",
                                  "Product",
                                  "Batch"
                                ],
                                "example": "Batch"
                              },
                              "product_group_id": {
                                "type": "number",
                                "description": "The ID of the product group this product belongs to.",
                                "example": 12
                              },
                              "warning": {
                                "type": "string",
                                "description": "An optional warning message displayed when this product is used.",
                                "example": "For veterinary use only."
                              },
                              "is_sold": {
                                "type": "boolean",
                                "description": "Whether this product can be sold to clients.",
                                "example": true
                              },
                              "is_purchased": {
                                "type": "boolean",
                                "description": "Whether this product can be purchased from suppliers.",
                                "example": true
                              },
                              "is_container": {
                                "type": "boolean",
                                "description": "Whether this product acts as a container for dispensing other products.",
                                "example": false
                              },
                              "is_derived_price": {
                                "type": "boolean",
                                "description": "Whether the sell price is derived from another product's pricing.",
                                "example": false
                              },
                              "has_cost_price": {
                                "type": "boolean",
                                "description": "Whether a cost price has been recorded for this product.",
                                "example": true
                              },
                              "lowest_dispensable_quantity": {
                                "type": "number",
                                "description": "The minimum quantity that can be dispensed for this product.",
                                "example": 1
                              },
                              "lowest_dispensable_unit": {
                                "type": "string",
                                "description": "The unit corresponding to the lowest dispensable quantity (e.g., tablet, mL).",
                                "example": "tablet"
                              },
                              "concentration": {
                                "type": "number",
                                "description": "The concentration strength of the product (used for medications).",
                                "example": 250
                              },
                              "concentration_unit": {
                                "type": "string",
                                "description": "The unit of measurement for the concentration.",
                                "example": "mg"
                              },
                              "concentration_volume": {
                                "type": "string",
                                "description": "The volume unit associated with the concentration denominator.",
                                "example": "tablet"
                              },
                              "concentration_diluted": {
                                "type": "number",
                                "description": "The diluted concentration value for reconstituted medications.",
                                "example": 5
                              },
                              "concentration_diluted_unit": {
                                "type": "string",
                                "description": "The unit of measurement for the diluted concentration.",
                                "example": "mg"
                              },
                              "concentration_diluted_volume": {
                                "type": "string",
                                "description": "The volume unit for the diluted concentration denominator.",
                                "example": "mL"
                              },
                              "default_dosage_calculation_method": {
                                "type": "string",
                                "description": "The default method used to calculate dosage for this product (e.g., mg/kg, mL/kg).",
                                "example": "mg/kg"
                              },
                              "is_constant_rate_infusion": {
                                "type": "boolean",
                                "description": "Whether this product is administered as a constant rate infusion (CRI).",
                                "example": false
                              },
                              "default_infusion_rate_per": {
                                "type": "string",
                                "description": "The time unit for the default infusion rate when is_constant_rate_infusion is true.",
                                "example": "hour"
                              },
                              "default_route_of_administration": {
                                "type": "string",
                                "description": "The default route by which this product is administered.",
                                "example": "Oral"
                              },
                              "sheet_group": {
                                "type": "number",
                                "description": "The ID of the treatment sheet group this product belongs to.",
                                "example": 3
                              },
                              "sheet_group_name": {
                                "type": "string",
                                "description": "The name of the treatment sheet group this product belongs to.",
                                "example": "Antibiotics"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "examples": {
                  "product_response": {
                    "summary": "A medication product",
                    "value": {
                      "meta": {
                        "items_page": 1,
                        "items_page_total": 1,
                        "items_page_size": 10,
                        "items_total": 1,
                        "transaction_id": "abc123xyz",
                        "timestamp": 1706745600
                      },
                      "items": [
                        {
                          "product": {
                            "id": 1234,
                            "created_at": 1706745600,
                            "modified_at": 1706832000,
                            "active": true,
                            "name": "Amoxicillin 250mg",
                            "code": "AMOX250",
                            "description": "Broad-spectrum antibiotic for dogs and cats.",
                            "type": "Medication",
                            "tracking_level": "Batch",
                            "product_group_id": 12,
                            "warning": "For veterinary use only.",
                            "is_sold": true,
                            "is_purchased": true,
                            "is_container": false,
                            "is_derived_price": false,
                            "has_cost_price": true,
                            "lowest_dispensable_quantity": 1,
                            "lowest_dispensable_unit": "tablet",
                            "concentration": 250,
                            "concentration_unit": "mg",
                            "concentration_volume": "tablet",
                            "concentration_diluted": null,
                            "concentration_diluted_unit": null,
                            "concentration_diluted_volume": null,
                            "default_dosage_calculation_method": "mg/kg",
                            "is_constant_rate_infusion": false,
                            "default_infusion_rate_per": null,
                            "default_route_of_administration": "Oral",
                            "sheet_group": 3,
                            "sheet_group_name": "Antibiotics"
                          }
                        }
                      ],
                      "messages": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-product"
            ]
          }
        ]
      }
    },
    "/v2.1/product/servicefee/bulk": {
      "patch": {
        "summary": "Bulk patch service fee associations for multiple products",
        "description": "Add or remove service fees to products for given ownerships\n\n**Request Semantics**\n- Submit only changed rows.\n- Each row requires `productId` and `ownershipId`.\n- Duplicate `(productId, ownershipId)` rows in one request are rejected.\n\n**Row Operation**\n- `serviceFeeProductId = null`: remove the service fee association for this product at this ownership level.\n- `serviceFeeProductId = <id>`: add the service fee association for this product at this ownership level.\n  - If a service fee association already exists with a different product, the existing one is removed and the new one is added.\n  - If a service fee association already exists with the same product, no change is made.\n\n**Error and Transaction Behavior**\n- Error responses return multiple errors if multiple service fee lines fail validation.\n- Requests are atomic: if any row fails validation or processing, the entire bulk operation is rolled back and no service fee rows are changed.\n- Hard limit: maximum 1000 rows per request.\n",
        "operationId": "bulk-upload-service-fee",
        "tags": [
          "Service Fee"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpsertServiceFeeRequest"
              },
              "examples": {
                "multiple_products": {
                  "summary": "Add and remove service fee rows",
                  "value": [
                    {
                      "productId": 132,
                      "ownershipId": 465,
                      "serviceFeeProductId": 88
                    },
                    {
                      "productId": 132,
                      "ownershipId": 466,
                      "serviceFeeProductId": null
                    },
                    {
                      "productId": 133,
                      "ownershipId": 465,
                      "serviceFeeProductId": 91
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service fees added or removed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpsertServiceFeeResponse"
                },
                "examples": {
                  "updated_rows": {
                    "summary": "Processed rows as a flat list",
                    "value": {
                      "data": [
                        {
                          "productId": 132,
                          "ownershipId": 465,
                          "serviceFeeProductId": 88
                        },
                        {
                          "productId": 132,
                          "ownershipId": 466,
                          "serviceFeeProductId": null
                        },
                        {
                          "productId": 133,
                          "ownershipId": 465,
                          "serviceFeeProductId": 91
                        }
                      ],
                      "meta": {
                        "totalItems": 3
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-productpricing"
            ]
          }
        ]
      }
    },
    "/v2/productminimumstock": {
      "get": {
        "summary": "Fetches Product Minimum Stock",
        "operationId": "get-productminimumstock",
        "tags": [
          "Product Minimum Stock"
        ],
        "description": "Fetches a list containing [`ProductMinimumStock`](#ProductMinimumStock)(s).",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the [`Product`](#Product) this [`ProductMinimumStock`](#ProductMinimumStock) this relates to."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productminimumstock": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number",
                                "nullable": true
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "product_id": {
                                "type": "number"
                              },
                              "minimumstock": {
                                "type": "number",
                                "description": "The minimim level of stock the location is allowed before a PO is required"
                              },
                              "re_order_to_max_level": {
                                "type": "boolean",
                                "description": "if true, an order should be placed so that the QOH will equal the value in 're_order_qty'. If false, an order should be placed where the ordered amount is greater than or equal to the value in 're_order_qty'."
                              },
                              "re_order_qty": {
                                "type": "string",
                                "description": "assists in the calculation for reordering products. To be used in conjunction with 're_order_to_max_level' and the QOH."
                              },
                              "start_day": {
                                "type": "number"
                              },
                              "start_month": {
                                "type": "number"
                              },
                              "end_day": {
                                "type": "number"
                              },
                              "end_month": {
                                "type": "number"
                              },
                              "ownership_id": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-productminimumstock"
            ]
          }
        ]
      }
    },
    "/v2/productpricing": {
      "get": {
        "summary": "Fetch a Product Pricing by ID",
        "operationId": "get-productpricing",
        "security": [
          {
            "bearerAuth": [
              "read-productpricing"
            ]
          }
        ],
        "tags": [
          "Product Pricing"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a Product Pricing.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the Product Pricing was created.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the Product Pricing was last modified.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the Product Pricing is active and usable in ezyVet.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "description": "The ID of the Product this Product Pricing relates to.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "description": "The ID of the ownership separation (site/practice) this Product Pricing applies to.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A JSON object containing product pricing details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productpricing": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number",
                                "description": "The unique ID of the product pricing record.",
                                "example": 567
                              },
                              "created_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was created.",
                                "example": 1706745600
                              },
                              "modified_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was last modified.",
                                "example": 1706832000
                              },
                              "active": {
                                "type": "boolean",
                                "description": "Whether this pricing record is active.",
                                "example": true
                              },
                              "cost_price": {
                                "type": "number",
                                "description": "The cost price of the product for this pricing record.",
                                "example": 1.5
                              },
                              "based_on": {
                                "type": "string",
                                "description": "Whether the sell price is set as a fixed price or calculated as a markup over cost.",
                                "enum": [
                                  "Price",
                                  "Markup"
                                ],
                                "example": "Price"
                              },
                              "markup": {
                                "type": "number",
                                "description": "The percentage markup applied to the cost price when based_on is 'Markup'.",
                                "example": 150
                              },
                              "sell_price": {
                                "type": "number",
                                "description": "The selling price of the product excluding tax.",
                                "example": 5
                              },
                              "sell_price_tax": {
                                "type": "number",
                                "description": "The selling price of the product including tax.",
                                "example": 5.5
                              },
                              "tax_rate": {
                                "$ref": "#/components/schemas/TaxRatev1"
                              },
                              "dispense_fee": {
                                "type": "number",
                                "description": "An additional dispensing fee applied when this product is sold.",
                                "example": 0.5
                              },
                              "product_id": {
                                "type": "number",
                                "description": "The ID of the product this pricing record applies to.",
                                "example": 1234
                              },
                              "ownership_id": {
                                "type": "number",
                                "description": "The ID of the ownership separation (site/practice) this pricing applies to.",
                                "example": 1
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "examples": {
                  "productpricing_response": {
                    "summary": "A product pricing record",
                    "value": {
                      "meta": {
                        "items_page": 1,
                        "items_page_total": 1,
                        "items_page_size": 10,
                        "items_total": 1,
                        "transaction_id": "abc123xyz",
                        "timestamp": 1706745600
                      },
                      "items": [
                        {
                          "productpricing": {
                            "id": 567,
                            "created_at": 1706745600,
                            "modified_at": 1706832000,
                            "active": true,
                            "cost_price": 1.5,
                            "based_on": "Price",
                            "markup": null,
                            "sell_price": 5,
                            "sell_price_tax": 5.5,
                            "tax_rate": {
                              "id": 3,
                              "created_at": 1706745600,
                              "modified_at": 1706745600,
                              "active": true,
                              "code": "GST",
                              "rate": 10
                            },
                            "dispense_fee": 0.5,
                            "product_id": 1234,
                            "ownership_id": 1
                          }
                        }
                      ],
                      "messages": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "summary": "Create a Product Pricing",
        "operationId": "create-productpricing",
        "tags": [
          "Product Pricing"
        ],
        "description": "Creates a new Product Pricing for the provided Product and Ownership Separation.\n",
        "security": [
          {
            "bearerAuth": [
              "write-productpricing"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": "number"
                  },
                  "ownership_id": {
                    "type": "number"
                  },
                  "based_on": {
                    "type": "string",
                    "enum": [
                      "Price",
                      "Markup"
                    ]
                  },
                  "tax_rate": {
                    "type": "number"
                  },
                  "cost_price": {
                    "type": "number",
                    "description": "Mandatory if based_on = 'Markup'."
                  },
                  "sell_price": {
                    "type": "number"
                  }
                },
                "required": [
                  "product_id",
                  "ownership_id",
                  "based_on",
                  "tax_rate",
                  "sell_price"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON object containing the created Product Pricing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productpricing": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number",
                                "description": "The unique ID of the product pricing record.",
                                "example": 567
                              },
                              "created_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was created.",
                                "example": 1706745600
                              },
                              "modified_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was last modified.",
                                "example": 1706832000
                              },
                              "active": {
                                "type": "boolean",
                                "description": "Whether this pricing record is active.",
                                "example": true
                              },
                              "cost_price": {
                                "type": "number",
                                "description": "The cost price of the product for this pricing record.",
                                "example": 1.5
                              },
                              "based_on": {
                                "type": "string",
                                "description": "Whether the sell price is set as a fixed price or calculated as a markup over cost.",
                                "enum": [
                                  "Price",
                                  "Markup"
                                ],
                                "example": "Price"
                              },
                              "markup": {
                                "type": "number",
                                "description": "The percentage markup applied to the cost price when based_on is 'Markup'.",
                                "example": 150
                              },
                              "sell_price": {
                                "type": "number",
                                "description": "The selling price of the product excluding tax.",
                                "example": 5
                              },
                              "sell_price_tax": {
                                "type": "number",
                                "description": "The selling price of the product including tax.",
                                "example": 5.5
                              },
                              "tax_rate": {
                                "type": "object",
                                "description": "The tax rate applied to this product pricing.",
                                "properties": {
                                  "id": {
                                    "type": "number",
                                    "description": "The unique ID of the tax rate.",
                                    "example": 3
                                  },
                                  "created_at": {
                                    "type": "number",
                                    "description": "Epoch timestamp when the tax rate was created.",
                                    "example": 1706745600
                                  },
                                  "modified_at": {
                                    "type": "number",
                                    "description": "Epoch timestamp when the tax rate was last modified.",
                                    "example": 1706745600
                                  },
                                  "active": {
                                    "type": "boolean",
                                    "description": "Whether this tax rate is active.",
                                    "example": true
                                  },
                                  "code": {
                                    "type": "string",
                                    "description": "The short code identifying the tax rate.",
                                    "example": "GST"
                                  },
                                  "rate": {
                                    "type": "number",
                                    "description": "The tax rate as a percentage.",
                                    "example": 10
                                  }
                                }
                              },
                              "dispense_fee": {
                                "type": "number",
                                "description": "An additional dispensing fee applied when this product is sold.",
                                "example": 0.5
                              },
                              "product_id": {
                                "type": "number",
                                "description": "The ID of the product this pricing record applies to.",
                                "example": 1234
                              },
                              "ownership_id": {
                                "type": "number",
                                "description": "The ID of the ownership separation (site/practice) this pricing applies to.",
                                "example": 1
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "examples": {
                  "productpricing_created": {
                    "summary": "A newly created product pricing record",
                    "value": {
                      "meta": {
                        "transaction_id": "abc123xyz",
                        "timestamp": 1706745600
                      },
                      "items": [
                        {
                          "productpricing": {
                            "id": 567,
                            "created_at": 1706745600,
                            "modified_at": 1706745600,
                            "active": true,
                            "cost_price": 1.5,
                            "based_on": "Price",
                            "markup": null,
                            "sell_price": 5,
                            "sell_price_tax": 5.5,
                            "tax_rate": {
                              "id": 3,
                              "created_at": 1706745600,
                              "modified_at": 1706745600,
                              "active": true,
                              "code": "GST",
                              "rate": 10
                            },
                            "dispense_fee": 0.5,
                            "product_id": 1234,
                            "ownership_id": 1
                          }
                        }
                      ],
                      "messages": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/productpricing/{id}": {
      "patch": {
        "summary": "Update a Product Pricing",
        "operationId": "update-productpricing",
        "tags": [
          "Product Pricing"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "cost_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "based_on",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Markup",
                "Price"
              ]
            }
          },
          {
            "name": "markup",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sell_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "tax_rate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sell_price": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful update of Product Pricing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_processed": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productpricing": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number",
                                "description": "The unique ID of the product pricing record.",
                                "example": 567
                              },
                              "created_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was created.",
                                "example": 1706745600
                              },
                              "modified_at": {
                                "type": "number",
                                "description": "Epoch timestamp (Unix seconds) when the product pricing was last modified.",
                                "example": 1706832000
                              },
                              "active": {
                                "type": "boolean",
                                "description": "Whether this pricing record is active.",
                                "example": true
                              },
                              "cost_price": {
                                "type": "number",
                                "description": "The cost price of the product for this pricing record.",
                                "example": 1.5
                              },
                              "based_on": {
                                "type": "string",
                                "description": "Whether the sell price is set as a fixed price or calculated as a markup over cost.",
                                "enum": [
                                  "Markup",
                                  "Price"
                                ],
                                "example": "Price"
                              },
                              "markup": {
                                "type": "number",
                                "description": "The percentage markup applied to the cost price when based_on is 'Markup'.",
                                "example": 150
                              },
                              "sell_price": {
                                "type": "number",
                                "description": "The selling price of the product excluding tax.",
                                "example": 5
                              },
                              "sell_price_tax": {
                                "type": "number",
                                "description": "The selling price of the product including tax.",
                                "example": 5.5
                              },
                              "tax_rate": {
                                "type": "object",
                                "description": "The tax rate applied to this product pricing.",
                                "properties": {
                                  "id": {
                                    "type": "number",
                                    "description": "The unique ID of the tax rate.",
                                    "example": 3
                                  },
                                  "created_at": {
                                    "type": "number",
                                    "description": "Epoch timestamp when the tax rate was created.",
                                    "example": 1706745600
                                  },
                                  "modified_at": {
                                    "type": "number",
                                    "description": "Epoch timestamp when the tax rate was last modified.",
                                    "example": 1706745600
                                  },
                                  "active": {
                                    "type": "boolean",
                                    "description": "Whether this tax rate is active.",
                                    "example": true
                                  },
                                  "code": {
                                    "type": "string",
                                    "description": "The short code identifying the tax rate.",
                                    "example": "GST"
                                  },
                                  "rate": {
                                    "type": "number",
                                    "description": "The tax rate as a percentage.",
                                    "example": 10
                                  }
                                }
                              },
                              "dispense_fee": {
                                "type": "number",
                                "description": "An additional dispensing fee applied when this product is sold.",
                                "example": 0.5
                              },
                              "product_id": {
                                "type": "number",
                                "description": "The ID of the product this pricing record applies to.",
                                "example": 1234
                              },
                              "ownership_id": {
                                "type": "number",
                                "description": "The ID of the ownership separation (site/practice) this pricing applies to.",
                                "example": 1
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "examples": {
                  "productpricing_updated": {
                    "summary": "An updated product pricing record",
                    "value": {
                      "meta": {
                        "items_processed": 1,
                        "transaction_id": "abc123xyz",
                        "timestamp": 1706832000
                      },
                      "items": [
                        {
                          "productpricing": {
                            "id": 567,
                            "created_at": 1706745600,
                            "modified_at": 1706832000,
                            "active": true,
                            "cost_price": 1.5,
                            "based_on": "Price",
                            "markup": null,
                            "sell_price": 6,
                            "sell_price_tax": 6.6,
                            "tax_rate": {
                              "id": 3,
                              "created_at": 1706745600,
                              "modified_at": 1706745600,
                              "active": true,
                              "code": "GST",
                              "rate": 10
                            },
                            "dispense_fee": 0.5,
                            "product_id": 1234,
                            "ownership_id": 1
                          }
                        }
                      ],
                      "messages": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-productpricing"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Deletes a Product Pricing",
        "operationId": "delete-productpricing",
        "tags": [
          "Product Pricing"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID number used by the system to uniquely identify a Product Pricing.",
            "required": true,
            "schema": {
              "type": "number"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": [
              "write-productpricing"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteProductPricingResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/productsupplier": {
      "get": {
        "summary": "Fetch Product Suppliers",
        "operationId": "get-productsupplier",
        "tags": [
          "Product Supplier"
        ],
        "description": "This will fetch a list of product suppliers based on the query parameters supplied.",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the product to filter by."
          },
          {
            "name": "supplier_contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the supplier contact to filter by."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of product suppliers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "productsupplier": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "product_id": {
                                "type": "number"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "expected_price": {
                                "type": "number"
                              },
                              "units_per_outer": {
                                "type": "number"
                              },
                              "supplier_contact_id": {
                                "type": "number"
                              },
                              "tax_rate_id": {
                                "type": "number"
                              },
                              "list_price": {
                                "type": "number",
                                "nullable": true
                              },
                              "is_default": {
                                "type": "boolean"
                              },
                              "unit_of_measure": {
                                "type": "string",
                                "nullable": true
                              },
                              "last_update": {
                                "type": "number",
                                "nullable": true
                              },
                              "contract_price": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-productsupplier"
            ]
          }
        ]
      }
    },
    "/v2/receiveinvoice": {
      "post": {
        "summary": "Create a Receive Invoice (V2)",
        "operationId": "create-receiveinvoicev2",
        "tags": [
          "Receive Invoice V2"
        ],
        "description": "Creates a `ReceiveInvoice` and any included `ReceiveInvoiceItems`](/#create-receiveinvoiceitemv2).\nIt's recommended to encapsulate a receive invoice via the [`v2/jobqueue`](/#create-jobqueue) endpoint as it allows for invoices to require approval from a staff member.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_number": {
                    "type": "string"
                  },
                  "date": {
                    "type": "number"
                  },
                  "due_date": {
                    "type": "number"
                  },
                  "comments": {
                    "type": "string",
                    "default": ""
                  },
                  "freight": {
                    "type": "number",
                    "default": 0
                  },
                  "freight_tax": {
                    "type": "number",
                    "default": 0
                  },
                  "ownership_id": {
                    "type": "number"
                  },
                  "line_item": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ReceiveInvoiceItemv1"
                    }
                  }
                },
                "required": [
                  "invoice_number",
                  "date",
                  "due_date",
                  "ownership_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoice": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean",
                                "default": true
                              },
                              "invoice_number": {
                                "type": "string"
                              },
                              "date": {
                                "type": "number"
                              },
                              "due_date": {
                                "type": "number"
                              },
                              "supplier_id": {
                                "type": "number"
                              },
                              "freight": {
                                "type": "number",
                                "default": 0
                              },
                              "freight_tax": {
                                "type": "number",
                                "default": 4
                              },
                              "rounding": {
                                "type": "number",
                                "default": 0
                              },
                              "comments": {
                                "type": "string"
                              },
                              "tax": {
                                "type": "number",
                                "default": 24
                              },
                              "total": {
                                "type": "number",
                                "default": 234
                              },
                              "ownership_id": {
                                "type": "number"
                              },
                              "line_item": {
                                "type": "array",
                                "items": {
                                  "$ref": "#/components/schemas/ReceiveInvoiceItemResponsev1"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoice"
            ]
          }
        ]
      },
      "get": {
        "operationId": "get-receiveinvoicev2",
        "tags": [
          "Receive Invoice V2"
        ],
        "summary": "Fetches a list containing Receive Invoices (up to 10), and their associated Receive Invoice Items.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a ReceiveInvoice.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ReceiveInvoice is active and usable in ezyVet.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoice was created.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoice was last modified.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "invoice_number",
            "in": "query",
            "description": "The value given by a Supplier to track the invoice on their end.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "The epoch time of the ReceiveInvoice transaction date.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "due_date",
            "in": "query",
            "description": "The due date of the ReceiveInvoice in epoch time.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "The ID of the Supplier who sent the ReceiveInvoice.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "description": "The ID of the OwnershipSeparation to which this ReceiveInvoice belongs.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Receive Invoices and their associated Receive Invoice Items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "number"
                        },
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoice": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "invoice_number": {
                                "type": "string"
                              },
                              "date": {
                                "type": "number"
                              },
                              "due_date": {
                                "type": "number"
                              },
                              "supplier_id": {
                                "type": "number"
                              },
                              "freight": {
                                "type": "number",
                                "default": 0
                              },
                              "freight_tax": {
                                "type": "number",
                                "default": 0
                              },
                              "rounding": {
                                "type": "number",
                                "default": 0
                              },
                              "comments": {
                                "type": "string",
                                "default": ""
                              },
                              "tax": {
                                "type": "number",
                                "default": 0
                              },
                              "total": {
                                "type": "number",
                                "default": 0
                              },
                              "ownership_id": {
                                "type": "number"
                              },
                              "line_item": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "number"
                                    },
                                    "created_at": {
                                      "type": "number"
                                    },
                                    "modified_at": {
                                      "type": "number"
                                    },
                                    "active": {
                                      "type": "boolean"
                                    },
                                    "quantity": {
                                      "type": "number"
                                    },
                                    "price": {
                                      "type": "number"
                                    },
                                    "tax": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    },
                                    "total_tax": {
                                      "type": "number"
                                    },
                                    "tax_rate": {
                                      "type": "number"
                                    },
                                    "tax_code": {
                                      "type": "string"
                                    },
                                    "product_id": {
                                      "type": "number"
                                    },
                                    "product_supplier_id": {
                                      "type": "number"
                                    },
                                    "supplier_code": {
                                      "type": "string"
                                    },
                                    "ownership_id": {
                                      "type": "number"
                                    },
                                    "batch": {
                                      "type": "array",
                                      "items": {}
                                    },
                                    "purchase_order_item_id": {
                                      "type": "number"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-receiveinvoice"
            ]
          }
        ]
      }
    },
    "/v2/receiveinvoiceitem": {
      "post": {
        "security": [
          {
            "bearerAuth": [
              "write-receiveinvoiceitem"
            ]
          }
        ],
        "summary": "Creates a ReceiveInvoiceItem",
        "operationId": "create-receiveinvoiceitemv2",
        "tags": [
          "Receive Invoice Item V2"
        ],
        "description": "Creates a ReceiveInvoiceItem and optionally creates multiple batches.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "quantity": {
                    "type": "string",
                    "description": "Please provide the number of outers/containers, not the number of units/inners. (This is a known issue)"
                  },
                  "price": {
                    "type": "number"
                  },
                  "tax": {
                    "type": "number"
                  },
                  "supplier_code": {
                    "type": "string"
                  },
                  "location_id": {
                    "type": "number"
                  },
                  "receive_invoice_id": {
                    "type": "number"
                  },
                  "batch": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "expiry": {
                          "type": "number"
                        },
                        "quantity": {
                          "type": "number"
                        }
                      }
                    }
                  }
                },
                "required": [
                  "quantity",
                  "price",
                  "tax",
                  "supplier_code",
                  "location_id",
                  "receive_invoice_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoiceitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean",
                                "default": true
                              },
                              "receive_invoice_id": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "number"
                              },
                              "price": {
                                "type": "number"
                              },
                              "tax": {
                                "type": "number"
                              },
                              "total": {
                                "type": "number"
                              },
                              "total_tax": {
                                "type": "number"
                              },
                              "tax_rate": {
                                "type": "number"
                              },
                              "tax_code": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "number"
                              },
                              "product_supplier_id": {
                                "type": "number"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "location_id": {
                                "type": "number"
                              },
                              "batch": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "number"
                                    },
                                    "uid": {
                                      "type": "string"
                                    },
                                    "created_at": {
                                      "type": "number"
                                    },
                                    "modified_at": {
                                      "type": "number"
                                    },
                                    "active": {
                                      "type": "boolean",
                                      "default": true
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "type": {
                                      "type": "string"
                                    },
                                    "expiry": {
                                      "type": "number",
                                      "nullable": true
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "summary": "Fetches a list containing ReceiveInvoiceItems",
        "operationId": "get-receiveinvoiceitemv2",
        "tags": [
          "Receive Invoice Item V2"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a ReceiveInvoiceItem.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoiceItem was created.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the ReceiveInvoiceItem was last modified.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ReceiveInvoiceItem is active and usable in ezyVet.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "receive_invoice_id",
            "in": "query",
            "description": "The ID of the ReceiveInvoice the ReceiveInvoiceItem is linked to.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "description": "The quantity of Product invoiced. Depending on the configuration set by the Supplier, this value may represent the quantity of Outers or the quantity of Units.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "price",
            "in": "query",
            "description": "The price of one selling unit. Depending on the configuration set by the Supplier, this value may represent the price of one Outer or the price of one Unit.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "tax",
            "in": "query",
            "description": "The tax content per selling unit. Depending on the configuration set by the Supplier, this value may represent the tax amount from one Outer or one Unit.",
            "schema": {
              "type": "number",
              "default": 0
            }
          },
          {
            "name": "total",
            "in": "query",
            "description": "The total monetary amount of the ReceiveInvoiceItem excluding tax.",
            "schema": {
              "type": "number",
              "default": 0
            }
          },
          {
            "name": "total_tax",
            "in": "query",
            "description": "The total tax content of the ReceiveInvoiceItem.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "tax_rate",
            "in": "query",
            "description": "The tax rate applied to the ReceiveInvoiceItem.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "tax_code",
            "in": "query",
            "description": "The tax code relating to the tax rate on the ReceiveInvoiceItem.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "description": "The ID of the Product on the ReceiveInvoiceItem.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "product_supplier_id",
            "in": "query",
            "description": "The ID of the ProductSupplier on the ReceiveInvoiceItem.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "supplier_code",
            "in": "query",
            "description": "The code of the Product in the Supplier's records. (i.e. the code given to the product by the supplier)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "description": "The ID of the LocationSeparation to which this ReceiveInvoiceItem belongs.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of ReceiveInvoiceItems",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "number"
                        },
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "receiveinvoiceitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "receive_invoice_id": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "number"
                              },
                              "price": {
                                "type": "number"
                              },
                              "tax": {
                                "type": "number"
                              },
                              "total": {
                                "type": "number"
                              },
                              "total_tax": {
                                "type": "number"
                              },
                              "tax_rate": {
                                "type": "number"
                              },
                              "tax_code": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "number"
                              },
                              "product_supplier_id": {
                                "type": "number"
                              },
                              "supplier_code": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "number"
                              },
                              "batch": {
                                "type": "array",
                                "items": {}
                              },
                              "purchase_order_item_id": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-receiveinvoiceitem"
            ]
          }
        ]
      }
    },
    "/v2/stockadjustment": {
      "post": {
        "summary": "Create a StockAdjustment",
        "operationId": "create-stockadjustment",
        "security": [
          {
            "bearerAuth": [
              "write-stockadjustment"
            ]
          }
        ],
        "description": "Adjust stock levels for a product\nIt's recommended to use the [`inventory/v1/supplied`](/#create-product-balance-update) endpoint.",
        "tags": [
          "Stock Adjustment"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "date": {
                    "type": "number",
                    "description": "The epoch time specified on create of the StockAdjustment."
                  },
                  "comments": {
                    "type": "string",
                    "default": "",
                    "description": "Any comments to add to the StockAdjustment."
                  },
                  "line_item": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/StockAdjustmentItemv1"
                    },
                    "description": "The StockAdjustmentItems associated with this StockAdjustment."
                  },
                  "ownership_id": {
                    "type": "number",
                    "description": "The ID of the ownership Separation to which this StockAdjustment belongs."
                  }
                },
                "required": [
                  "date",
                  "line_item",
                  "ownership_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "stockadjustment": {
                            "$ref": "#/components/schemas/StockAdjustmentv1"
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/stockadjustment/{id}": {
      "get": {
        "summary": "Fetch stock adjustments",
        "operationId": "get-stockadjustment",
        "security": [
          {
            "bearerAuth": [
              "read-stockadjustment"
            ]
          }
        ],
        "tags": [
          "Stock Adjustment"
        ],
        "description": "Fetches a list of StockAdjustment records (up to 10).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "If true, the StockAdjustment is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the StockAdjustment was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the StockAdjustment was last modified."
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time specified on create of the StockAdjustment."
          },
          {
            "name": "ownership_id",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The ID of the ownership Separation to which this StockAdjustment belongs."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StockAdjustmentsResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/stockadjustmentitem": {
      "post": {
        "summary": "Creates a single StockAdjustmentItem",
        "operationId": "create-stockadjustmentitem",
        "tags": [
          "Stock Adjustment Item"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-stockadjustmentitem"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stockadjustment_id": {
                    "type": "number"
                  },
                  "product_id": {
                    "type": "number"
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "price": {
                    "type": "number",
                    "description": "The unit price recorded against the adjustment. Equivalent to `cost_price`; if both are supplied, `price` wins."
                  },
                  "cost_price": {
                    "type": "number",
                    "minimum": 0,
                    "description": "The unit cost (purchase) price of the stock being adjusted, recorded against the adjustment in the same way as a cost price entered on a manual inventory adjustment in ezyVet. `cost_price` is a synonym of `price` - both write to the same value on the StockAdjustmentItem, so send one or the other. If both are supplied, `price` takes precedence and `cost_price` is ignored. Must be a non-negative number. When neither `price` nor `cost_price` is supplied, the adjustment defaults to the product's cost price for the line's ownership/location."
                  },
                  "ledger_account": {
                    "type": "number"
                  },
                  "batch": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Batchv1"
                    }
                  },
                  "location_id": {
                    "type": "number"
                  }
                },
                "required": [
                  "stockadjustment_id",
                  "product_id",
                  "quantity"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateStockAdjustmentItemResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/stockadjustmentitem/{id}": {
      "get": {
        "summary": "Fetch a Stock Adjustment Item",
        "operationId": "get-stockadjustmentitem",
        "tags": [
          "Stock Adjustment Item"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "stockadjustment_id",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "ledger_account",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "Pending",
                "Allocated",
                "Finalised"
              ]
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Responsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-stockadjustmentitem"
            ]
          }
        ]
      }
    },
    "/v2/stocktransaction": {
      "get": {
        "deprecated": true,
        "summary": "Fetch stock transactions",
        "operationId": "get-stocktransaction",
        "tags": [
          "Stock Transaction"
        ],
        "description": "Fetches a list of StockTransaction records.\n\nIt's recommended to use the [`v2.1/stocktransaction`](#get-stocktransactionv21) endpoint, which uses token-based (keyset) pagination via `page_size`/`next_token` and performs reliably on large sites. This endpoint is scheduled for sunset on 31 January 2027.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a StockTransaction."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "If true, the StockTransaction is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the StockTransaction was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the StockTransaction was last modified."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 10
            },
            "description": "Limits the number of items returned."
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 1
            },
            "description": "Specifies the page number of the result."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of StockTransaction records.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "stocktransaction": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "quantity": {
                                "type": "string"
                              },
                              "alter_stock": {
                                "type": "boolean"
                              },
                              "separation_id": {
                                "type": "string"
                              },
                              "for_id": {
                                "type": "string"
                              },
                              "for_class": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              },
                              "date": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-stocktransaction"
            ]
          }
        ]
      }
    },
    "/inventory/v1/products": {
      "get": {
        "summary": "Get inventory tracked products",
        "tags": [
          "Inventory Tracked Products"
        ],
        "operationId": "get-tracked-products",
        "description": "Returns all inventory tracked products as well as details pertaining to the measurement systems of the product",
        "security": [
          {
            "bearerAuth": [
              "inventory-management"
            ]
          }
        ],
        "servers": [
          {
            "url": "https://apiv2.ezyvet.com",
            "description": "ezyVet production environment"
          },
          {
            "url": "https://apiv2.trial.ezyvet.com",
            "description": "ezyVet trial environment"
          }
        ],
        "responses": {
          "200": {
            "description": "Gets inventory tracked products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InventoryProducts"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Messages"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/inventory/v1/requirements": {
      "get": {
        "summary": "Get inventory balance and requirements",
        "operationId": "get-inventory-requirements",
        "tags": [
          "Inventory Requirements"
        ],
        "description": "Returns the current state of products at an inventory location",
        "security": [
          {
            "bearerAuth": [
              "inventory-management"
            ]
          }
        ],
        "servers": [
          {
            "url": "https://apiv2.ezyvet.com",
            "description": "ezyVet production environment"
          },
          {
            "url": "https://apiv2.trial.ezyvet.com",
            "description": "ezyVet trial environment"
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/locationUID"
          }
        ],
        "responses": {
          "200": {
            "description": "Gets products with their inventory balance and requirements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InventoryRequirements"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Messages"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/inventory/v1/supplied": {
      "post": {
        "summary": "Supply products to a location",
        "operationId": "create-product-balance-update",
        "security": [
          {
            "bearerAuth": [
              "inventory-management"
            ]
          }
        ],
        "servers": [
          {
            "url": "https://apiv2.ezyvet.com",
            "description": "ezyVet production environment"
          },
          {
            "url": "https://apiv2.trial.ezyvet.com",
            "description": "ezyVet trial environment"
          }
        ],
        "tags": [
          "Supplied Inventory"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/InventorySuppliedProduct"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "locationUID",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "ownershipSeparation_9K8oZgeaLT0AEctz3KtwC",
            "description": "The UID of the location that the products are supplied to",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InventorySuppliedProduct"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/InventoryMetaObject"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/inventory/v2/balances": {
      "get": {
        "summary": "Get inventory balances",
        "description": "Returns quantity-on-hand (QOH) for all active tracked products at a given location or organisational unit.\nUnlike /v1/requirements, this endpoint does not require minimum stock configuration.\nResults are ordered by product code ascending and use token-based pagination.",
        "operationId": "getbalances",
        "security": [
          {
            "bearerAuth": [
              "inventory-management"
            ]
          }
        ],
        "tags": [
          "Balances"
        ],
        "servers": [
          {
            "url": "https://apiv2.ezyvet.com",
            "description": "ezyVet production environment"
          },
          {
            "url": "https://apiv2.trial.ezyvet.com",
            "description": "ezyVet trial environment"
          }
        ],
        "parameters": [
          {
            "name": "locationUID",
            "in": "query",
            "required": true,
            "description": "The UID of the location or organisational unit to query balances for.",
            "example": "ownershipSeparation_9K8oZgeaLT0AEctz3KtwC",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "productUID",
            "in": "query",
            "required": false,
            "description": "Optional comma-separated list of product UIDs. Up to 100 values are accepted and each value must be 50 characters or fewer; longer values are rejected with `400 invalidParameter`. Whitespace is trimmed and duplicates ignored. When both `productUID` and `productCode` are supplied, a product is included only if its UID matches a value in `productUID` **and** its code matches a value in `productCode` (the two filters are intersected, not unioned).",
            "example": "product_aBc123,product_dEf456",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "productCode",
            "in": "query",
            "required": false,
            "description": "Optional comma-separated list of product codes. Up to 100 values are accepted and each value must be 40 characters or fewer; longer values are rejected with `400 invalidParameter`. Whitespace is trimmed and duplicates ignored. Matching is case- and accent-insensitive (e.g. `Café`, `cafe`, and `CAFE` all match the same products). See `productUID` for combined-filter behaviour.",
            "example": "PROD-001,PROD-002",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Number of items returned per page. Maximum value is 2000.",
            "schema": {
              "type": "integer",
              "default": 2000,
              "maximum": 2000,
              "minimum": 1
            }
          },
          {
            "name": "nextToken",
            "in": "query",
            "required": false,
            "description": "Opaque pagination token returned from a previous response. If provided, `locationUID`, `pageSize`, `productUID` and `productCode` query parameters must match the values encoded in the token, otherwise a 400 error is returned.",
            "example": "eyJsYXN0Q29kZSI6IlBST0QtMDAzIiwibG9jYXRpb25VSUQiOiJsb2MtMTIzIiwicGFnZVNpemUiOjIwMDB9",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response containing inventory balances.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalancesResponse"
                },
                "examples": {
                  "example": {
                    "value": {
                      "data": [
                        {
                          "productUid": "product_abc123",
                          "product": "Amoxicillin 250mg",
                          "code": "AMOX-250",
                          "available": 42.5
                        }
                      ],
                      "meta": {
                        "timestamp": "2026-03-10T12:00:00Z",
                        "path": "/v2/balances",
                        "perPage": 2000,
                        "nextToken": "eyJsYXN0Q29kZSI6Ik...",
                        "links": [
                          {
                            "label": "next",
                            "url": "/v2/balances?nextToken=eyJsYXN0Q29kZSI6Ik..."
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Returned when `nextToken` conflicts with provided query parameters."
          },
          "401": {
            "description": "Unauthorized. Missing or invalid Bearer token."
          },
          "403": {
            "description": "Forbidden. The required feature flag `ezyvet.inventory.ds-api-use-cdc` is not enabled or the token lacks the `inventory-management` scope."
          }
        }
      }
    },
    "/v4/purchaseorder": {
      "post": {
        "summary": "Creates one or more PurchaseOrders.",
        "description": "Accepts an array of 1 to 100 purchase orders and creates them in a single atomic request. Each item is owned by the supplied `ownershipId`, addressed to the supplier identified by `supplierId`. Lines are optional - a draft PO with no lines is permitted and matches the existing UI behaviour.\n\nEach PO is created with status `Created`.\n\nIf any item fails validation the whole batch is rejected - no purchase orders are persisted and the response lists every failing item by array index in the `target` JSON Pointer (e.g. `/0/supplierId`, `/2/lines/0/productId`).\n\nRequests exceeding 100 items are rejected with `413 Content Too Large`.\n",
        "operationId": "create-purchaseorder-v4",
        "tags": [
          "Purchase Order V4"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "description": "Array of purchase orders to create. 1 to 100 items per request.",
                "minItems": 1,
                "maxItems": 100,
                "items": {
                  "$ref": "#/components/schemas/PurchaseOrderCreate"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The PurchaseOrders were created. Returns the created objects as an\narray, in the same order as the request. No envelope.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "$ref": "#/components/schemas/PurchaseOrder"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/ContentTooLarge"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "practice-management"
            ]
          }
        ]
      }
    },
    "/v2.1/stocktransaction": {
      "get": {
        "summary": "Fetches a list containing Stock Transaction(s) — v2 format with token pagination.",
        "description": "Filters take a URL-encoded JSON comparator object, e.g. `modified_at={\"gte\":1712000000,\"lt\":1712086400}` — see [API filtering](https://developers.ezyvet.com/guides/api-filtering.html#supported-comparators). Comparators within a filter and across filters are combined with AND. `like` is not supported on this endpoint: its one string-typed filter, `inventory_location_uid`, holds an opaque identifier and is matched whole, so it takes only `eq`, `neq` and `in`. Bare scalar values return a 400 error — use `{\"eq\":<value>}`. An `in` list accepts at most 1000 values.\n\nResult order follows the filters supplied: `modified_at` leads when it is filtered, otherwise `created_at` when it is filtered, otherwise `id`; `id` is always the final tie-breaker. `next_token` encodes the sort order it was issued under, so changing filters mid-pagination returns a 400 — restart without `next_token`.",
        "operationId": "get-stocktransaction-v2-1",
        "tags": [
          "Stock Transaction"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/stx21_id"
          },
          {
            "$ref": "#/components/parameters/stx21_active"
          },
          {
            "$ref": "#/components/parameters/stx21_created_at"
          },
          {
            "$ref": "#/components/parameters/stx21_modified_at"
          },
          {
            "$ref": "#/components/parameters/stx21_inventory_location_id"
          },
          {
            "$ref": "#/components/parameters/stx21_inventory_location_uid"
          },
          {
            "$ref": "#/components/parameters/page_size"
          },
          {
            "$ref": "#/components/parameters/next_token"
          }
        ],
        "responses": {
          "200": {
            "description": "List response using the standard v2-style envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StockTransactionListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/stx21_BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/stx21_Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/stx21_InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-stocktransaction"
            ]
          }
        ]
      }
    }
  }
}
