{
  "openapi": "3.0.1",
  "info": {
    "title": "Standard Product Supplier Integration (SPSI)",
    "description": "The SPSI is a combination of a subset of ezyVet's API and the product supplier's API that provides customers a consistent workflow experience. \n\nFind more info on the SPSI framework [`here`](./guides/product-suppliers) inlcuding UI examples.",
    "license": {
      "name": "ezyVet API license",
      "url": "https://www.ezyvet.com/private-api-terms-and-conditions"
    },
    "contact": {
      "email": "apisupport-ezyvet@idexx.com"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.ezyvet.com",
      "description": "ezyVet Production Environment"
    },
    {
      "url": "https://api.trial.ezyvet.com",
      "description": "ezyVet Trial Environment"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api.ezyvet.com/v1/oauth/access_token",
            "scopes": {
              "read-receiveinvoice": "Read receive invoice resources",
              "read-separation": "Read separation resources",
              "write-jobqueue": "Create and update job queue resources",
              "write-receiveinvoice": "Create, update and delete receive invoice resources"
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BadRequest"
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal Server Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/InternalError"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "text/html": {
            "schema": {
              "$ref": "#/components/schemas/NotFound"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TooManyRequests"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Unauthorized"
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/UnprocessableEntity"
            }
          }
        }
      }
    },
    "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."
                }
              }
            }
          }
        }
      },
      "InternalError": {
        "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."
          }
        }
      },
      "NotFound": {
        "type": "string",
        "example": "No input file specified."
      },
      "PartnerAuthentication": {
        "properties": {
          "access_token": {
            "type": "string",
            "example": "CnKAVqSqp6UBq3Ei17e1UIj2U39UuOQI1i9Db3QT"
          },
          "token_type": {
            "type": "string",
            "example": "Bearer"
          }
        }
      },
      "PurchaseOrder": {
        "type": "object",
        "properties": {
          "purchaseorder": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier of the purchase order",
                "example": "12"
              },
              "active": {
                "type": "string",
                "description": "The active status of the purchase order",
                "example": "1"
              },
              "created_at": {
                "type": "string",
                "description": "The timestamp when the purchase order was created",
                "example": "1514493886"
              },
              "modified_at": {
                "type": "string",
                "description": "The timestamp when the purchase order was last modified",
                "example": "1514493886"
              },
              "date": {
                "type": "string",
                "description": "The date of the purchase order",
                "example": "1514466000"
              },
              "shipping_address_id": {
                "type": "string",
                "description": "The ID of the shipping address associated with the purchase order",
                "example": "2"
              },
              "comments": {
                "type": "string",
                "description": "Additional comments related to the purchase order",
                "example": "Some comments."
              },
              "freight": {
                "type": "string",
                "description": "The freight cost associated with the purchase order",
                "example": "0"
              },
              "freight_tax": {
                "type": "string",
                "description": "The tax on the freight cost",
                "example": "0"
              },
              "tax": {
                "type": "string",
                "description": "The total tax amount for the purchase order",
                "example": "0.4"
              },
              "total": {
                "type": "string",
                "description": "The total amount of the purchase order",
                "example": "4.4"
              },
              "client_id": {
                "type": "string",
                "description": "The ID of the client who placed the purchase order",
                "example": "2"
              },
              "supplier_id": {
                "type": "string",
                "description": "The ID of the supplier fulfilling the purchase order",
                "example": "10006"
              },
              "status": {
                "type": "string",
                "description": "The current status of the purchase order",
                "example": "Approved"
              },
              "supplier_order_number": {
                "type": "string",
                "description": "The order number assigned by the supplier",
                "example": ""
              },
              "supplier_account_number": {
                "type": "string",
                "description": "The account number assigned by the supplier",
                "example": ""
              },
              "purchase_order_number": {
                "type": "string",
                "description": "The unique purchase order number",
                "example": "15000032"
              },
              "ownership_id": {
                "type": "string",
                "description": "The ID indicating ownership of the purchase order",
                "example": "1"
              },
              "purchase_order_item_list": {
                "type": "array",
                "description": "A list of items included in the purchase order",
                "items": {
                  "$ref": "#/components/schemas/PurchaseOrderItem"
                }
              }
            }
          }
        }
      },
      "PurchaseOrderItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The unique identifier of the purchase order item",
            "example": "9"
          },
          "product_id": {
            "type": "string",
            "description": "The ID of the product being ordered",
            "example": "50002"
          },
          "supplier_code": {
            "type": "string",
            "description": "The supplier code for the product",
            "example": "TP1"
          },
          "outers": {
            "type": "string",
            "description": "The number of outer packages ordered",
            "example": "1"
          },
          "units_per_outer": {
            "type": "string",
            "description": "The number of units per outer package",
            "example": "1"
          },
          "price_per_unit": {
            "type": "string",
            "description": "The price per unit of the product",
            "example": "4"
          },
          "tax_per_unit": {
            "type": "string",
            "description": "The tax amount per unit of the product",
            "example": "0.4"
          },
          "quantity": {
            "type": "string",
            "description": "The quantity of the product ordered",
            "example": "1"
          },
          "total": {
            "type": "string",
            "description": "The total price for the item",
            "example": "4"
          },
          "total_tax": {
            "type": "string",
            "description": "The total tax amount for the item",
            "example": "0.4"
          },
          "ownership_id": {
            "type": "string",
            "description": "The ID indicating ownership of the purchase order item",
            "example": "3"
          }
        }
      },
      "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"
        ]
      },
      "SupplierProductCategories": {
        "type": "object",
        "properties": {
          "categories": {
            "description": "An array containing a list of product categories.",
            "type": "array",
            "items": {
              "type": "string",
              "description": "a category",
              "example": "consumable"
            }
          }
        },
        "required": [
          "categories"
        ]
      },
      "SupplierProducts": {
        "type": "object",
        "properties": {
          "products": {
            "type": "array",
            "items": {
              "properties": {
                "active": {
                  "type": "integer",
                  "description": "Indicates if the product is active (1 for active, 0 for inactive)",
                  "example": 1
                },
                "code": {
                  "type": "string",
                  "description": "The code of the product",
                  "example": "BND"
                },
                "name": {
                  "type": "string",
                  "description": "The name of the product",
                  "example": "2m-bandage"
                },
                "type": {
                  "type": "string",
                  "description": "The type of the product",
                  "example": "standard",
                  "enum": [
                    "standard",
                    "medication",
                    "vaccination",
                    "diagnostic",
                    "procedure",
                    "service fee"
                  ]
                },
                "category": {
                  "type": "string",
                  "description": "The category of the product",
                  "example": "consumable"
                },
                "units_per_outer": {
                  "type": "string",
                  "description": "The number of units per outer package",
                  "example": "1"
                },
                "unit_of_measure": {
                  "type": "string",
                  "description": "The unit of measure for the product",
                  "example": "box"
                },
                "price_per_unit": {
                  "type": "string",
                  "description": "The price per unit of the product",
                  "example": "2"
                },
                "list_price": {
                  "type": "number",
                  "description": "The list price of the product",
                  "example": 2
                },
                "contract_price": {
                  "type": "number",
                  "description": "The contract price of the product",
                  "example": 1.5
                },
                "barcode": {
                  "type": "integer",
                  "description": "The barcode of the product",
                  "example": 6587
                },
                "stock_available": {
                  "type": "integer",
                  "description": "The number of units available in stock",
                  "example": 20
                },
                "related_urls": {
                  "type": "array",
                  "description": "A list of related URLs for the product",
                  "items": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://example.com"
                  }
                }
              },
              "required": [
                "active",
                "code",
                "name",
                "type",
                "category",
                "units_per_outer",
                "unit_of_measure",
                "list_price"
              ]
            }
          }
        },
        "required": [
          "products"
        ]
      },
      "TooManyRequests": {
        "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": {
        "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": {
        "title": "Unprocessable Entity",
        "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"
          }
        }
      }
    }
  },
  "paths": {
    "/accesstoken": {
      "servers": [
        {
          "url": "https://partnerurl.com"
        }
      ],
      "post": {
        "security": [],
        "operationId": "get-partner-token",
        "tags": [
          "Partner Authentication"
        ],
        "summary": "Get an access token from the partner",
        "description": "This endpoint must be implemented by the Partner. \n\nThis endpoint will allow ezyVet to authenticate and use the Partner's web services\n",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_id": {
                    "type": "string",
                    "example": "partner-clinic"
                  },
                  "client_secret": {
                    "type": "string",
                    "example": "partner-secret"
                  },
                  "grant_type": {
                    "type": "string",
                    "example": "client_credentials"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns an access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerAuthentication"
                }
              }
            }
          },
          "400": {
            "description": "Error Message From Partner",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Cannot process this request."
                }
              }
            }
          }
        }
      }
    },
    "/v1/oauth/access_token": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Fetch a JWT bearer token",
        "operationId": "get-token",
        "servers": [
          {
            "url": "https://api.ezyvet.com",
            "description": "ezyVet production environment"
          },
          {
            "url": "https://api.trial.ezyvet.com",
            "description": "ezyVet trial environment"
          }
        ],
        "description": "Generates a valid access token, given client credentials. Access tokens have an 12-hour TTL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partner_id": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "client_secret": {
                    "type": "string"
                  },
                  "grant_type": {
                    "type": "string",
                    "default": "client_credentials"
                  },
                  "scope": {
                    "type": "string"
                  },
                  "site_uid": {
                    "type": "string"
                  }
                },
                "required": [
                  "partner_id",
                  "client_id",
                  "client_secret",
                  "grant_type",
                  "scope",
                  "site_uid"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON object containing the access token details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string"
                    },
                    "expires_in": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "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": []
      }
    },
    "/v2/separation": {
      "get": {
        "summary": "Fetch a Separation list",
        "description": "Fetches a list containing Separations.\nSeparations are a complex part of the ezyVet API and is important to understand. \nPlease read [this document](./guides/understanding-separations) to ensure you have an adequate understanding.",
        "operationId": "get-separationv2",
        "tags": [
          "Separations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The ID number used by the system to uniquely identify a [`Separation`](#get-separationv2)."
          },
          {
            "name": "uid",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a [`Separation`](#get-separationv2) across all ezyVet sites."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "If **true**, the [`Separation`](#get-separationv2) is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the [`Separation`](#get-separationv2) was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "The epoch time when the [`Separation`](#get-separationv2) was last modified."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of separations",
            "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": {
                          "separation": {
                            "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"
                              },
                              "child": {
                                "type": "number"
                              },
                              "separation_type": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "number"
                              },
                              "contact_uid": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "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-separation"
            ]
          }
        ]
      }
    },
    "/v2/jobqueue": {
      "post": {
        "summary": "Creates a JobQueue job",
        "operationId": "create-jobqueue",
        "tags": [
          "Job Queue"
        ],
        "description": "Creates a JobQueue job. A job will need to contain the parameters needed for a normal [`ReceiveInvoice`](/) API request to be processed.",
        "security": [
          {
            "bearerAuth": [
              "write-jobqueue"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "The endpoint type to hit.",
                    "example": "ReceiveInvoice"
                  },
                  "type_id": {
                    "type": "number",
                    "default": 0,
                    "description": "The id of the record the JobQueue job is for.",
                    "example": 3
                  },
                  "action": {
                    "type": "string",
                    "default": "ApiRequest",
                    "description": "The type of action to perform for the JobQueue job."
                  },
                  "data": {
                    "type": "object",
                    "properties": {
                      "method": {
                        "type": "string",
                        "description": "The HTTP method to be used.",
                        "example": "POST"
                      },
                      "endpoint": {
                        "type": "string",
                        "description": "The endpoint to be queued to hit.",
                        "example": "api/v2/receiveinvoice"
                      },
                      "body": {
                        "type": "object",
                        "description": "The JSON body to be sent to the endpoint.",
                        "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": {
                              "type": "object",
                              "properties": {
                                "purchase_order_item_id": {
                                  "type": "integer",
                                  "example": 26,
                                  "description": "The ID of the purchase order item. Links the invoice to the PO."
                                },
                                "supplier_code": {
                                  "type": "string",
                                  "example": "Droid"
                                },
                                "quantity": {
                                  "type": "string",
                                  "example": "1"
                                },
                                "price": {
                                  "type": "string",
                                  "example": "50"
                                },
                                "tax": {
                                  "type": "string",
                                  "example": "0.10"
                                },
                                "total": {
                                  "type": "string",
                                  "example": "50"
                                },
                                "total_tax": {
                                  "type": "string",
                                  "example": "0.10"
                                },
                                "location_id": {
                                  "type": "integer",
                                  "example": 3
                                }
                              },
                              "required": [
                                "supplier_code",
                                "quantity",
                                "price",
                                "tax",
                                "total",
                                "total_tax",
                                "location_id"
                              ]
                            }
                          }
                        },
                        "required": [
                          "invoice_number",
                          "date",
                          "due_date",
                          "ownership_id",
                          "line_item"
                        ]
                      }
                    },
                    "required": [
                      "method",
                      "endpoint",
                      "body"
                    ]
                  }
                },
                "required": [
                  "type",
                  "type_id",
                  "data"
                ]
              }
            }
          }
        },
        "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": {
                          "jobqueue": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean",
                                "default": true
                              },
                              "type": {
                                "type": "string"
                              },
                              "type_id": {
                                "type": "number"
                              },
                              "action": {
                                "type": "string",
                                "default": "ApiRequest"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "Pending",
                                  "Queued",
                                  "Processing",
                                  "Error",
                                  "Completed"
                                ]
                              },
                              "data": {
                                "type": "object",
                                "properties": {
                                  "method": {
                                    "type": "string"
                                  },
                                  "endpoint": {
                                    "type": "string"
                                  },
                                  "body": {
                                    "type": "object"
                                  }
                                }
                              },
                              "error": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "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/receiveinvoice": {
      "post": {
        "summary": "Create a Receive Invoice",
        "operationId": "create-receiveinvoicev2",
        "tags": [
          "Receive Invoice"
        ],
        "description": "Creates a `ReceiveInvoice` and any included `ReceiveInvoiceItems`.\n\nIt's mandatory to encapsulate a receive invoice via the [`v2/jobqueue`](/spsi#create-jobqueue) endpoint as it allows for invoices to require approval from a staff member.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "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": {
                      "type": "object",
                      "properties": {
                        "purchase_order_item_id": {
                          "type": "integer",
                          "example": 26,
                          "description": "The ID of the purchase order item. Links the invoice to the PO."
                        },
                        "supplier_code": {
                          "type": "string",
                          "example": "Droid"
                        },
                        "quantity": {
                          "type": "string",
                          "example": "1"
                        },
                        "price": {
                          "type": "string",
                          "example": "50"
                        },
                        "tax": {
                          "type": "string",
                          "example": "0.10"
                        },
                        "total": {
                          "type": "string",
                          "example": "50"
                        },
                        "total_tax": {
                          "type": "string",
                          "example": "0.10"
                        },
                        "location_id": {
                          "type": "integer",
                          "example": 3
                        }
                      },
                      "required": [
                        "supplier_code",
                        "quantity",
                        "price",
                        "tax",
                        "total",
                        "total_tax",
                        "location_id"
                      ]
                    }
                  }
                },
                "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": [
              "read-receiveinvoice",
              "write-receiveinvoice"
            ]
          }
        ]
      }
    },
    "/categories": {
      "servers": [
        {
          "url": "https://partnerurl.com"
        }
      ],
      "get": {
        "operationId": "get-partner-catalog-categories",
        "tags": [
          "Product Catagories"
        ],
        "summary": "Get product categories from the partner",
        "description": "This endpoint must be implemented by the partner. \n\nThis endpoint will allow ezyVet to gather a list of product categories from the partner and also perform product lookups.\n",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplierProductCategories"
                }
              }
            }
          },
          "400": {
            "description": "Error Message From Partner",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Cannot process this request."
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/purchaseorder": {
      "servers": [
        {
          "url": "https://partnerurl.com"
        }
      ],
      "post": {
        "operationId": "send-partner-purchase-order",
        "summary": "Send a purchase order to the partner",
        "tags": [
          "Purchase Orders"
        ],
        "description": "This endpoint must be implemented by the partner. \n\nThis endpoint will allow ezyVet to send purchase orders to the partner.\n",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchaseOrder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error Message From Partner",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Cannot process this request."
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/products": {
      "servers": [
        {
          "url": "https://partnerurl.com"
        }
      ],
      "get": {
        "operationId": "get-partner-catalog",
        "summary": "Get products from the partner",
        "tags": [
          "Product Catalog"
        ],
        "description": "This endpoint must be implemented by the partner.\n\nThis endpoint will allow ezyVet to get products from the partner and also perform product lookups.\n",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "An array containing none, one or many product names. If values are provided, results should only include products with names that contain or match one or more of the values provided. An empty array means no filtering.",
            "example": "[2m-bandage,1m-bandage]",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "code",
            "in": "query",
            "description": "An array containing none, one or many product codes. If values are provided, results should only include products with codes that contain or match one or more of the values provided. An empty array means no filtering.",
            "example": "[BND]",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "An array containing none, one or many product categories. If values are provided, results should only include products with categories that contain or match one or more of the values provided. An empty array means no filtering.",
            "example": "[consumable]",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "An array containing ONLY one integer. The integer provided will be the maximum number of results to return. If an empty value, empty array is provided, or if the parameter is non-existent, then return with no limit.",
            "example": "[3]",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "An array containing ONLY one integer. The integer provided will be the page number to return. E.g. If the limit was 5 and the total number of results was 40, then a page value of 3 would give us results between 15-19 inclusive. \n\nNOTE: Page number starts at 0. So the first page of results will be for page 0.\n",
            "example": "[0]",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplierProducts"
                }
              }
            }
          },
          "400": {
            "description": "Error Message From Partner - Commonly used for mentioning if products are no longer offered or if business logic failed.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Cannot process this request."
                }
              }
            }
          }
        },
        "security": []
      }
    }
  }
}
