{
  "openapi": "3.1.0",
  "info": {
    "title": "Invoice Website Agent API",
    "version": "1.0.0",
    "description": "Create, update, share, and send invoices and estimates on behalf of an Invoice Website user.\n\nAuthenticate with a user API key: \"Authorization: Bearer iw_live_...\". Users create keys at https://invoicewebsite.com/account#api-keys.\n\nThe API requires a Basic or Premium plan (https://invoicewebsite.com/pricing). Keys owned by Free accounts get 402 payment_required on every endpoint.\n\nEach key allows 60 requests per minute. Plan limits (documents per month, emails per day) apply as in the app and return 402 when reached.\n\nOptionally send an \"X-Agent-Source\" header naming your agent or integration.",
    "contact": {
      "url": "https://invoicewebsite.com/contact"
    }
  },
  "externalDocs": {
    "description": "Agent API guide",
    "url": "https://invoicewebsite.com/help/agent-api"
  },
  "servers": [
    {
      "url": "https://invoicewebsite.com/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Current user, plan, key scopes, and remaining usage",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/invoices": {
      "get": {
        "operationId": "listInvoices",
        "summary": "List invoices, newest first",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Document"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createInvoice",
        "summary": "Create a draft invoice",
        "description": "Counts toward the monthly document limit. Totals are computed for you.",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocument"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/invoices/{id}": {
      "get": {
        "operationId": "getInvoice",
        "summary": "Get an invoice",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "updateInvoice",
        "summary": "Update an invoice",
        "description": "Only the fields you send change. Sending items replaces all line items.",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateInvoice"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/invoices/{id}/send": {
      "post": {
        "operationId": "sendInvoice",
        "summary": "Email the client a link to the invoice",
        "description": "Sends an email with a share link (no PDF attachment) and marks a draft invoice as sent. Counts toward the daily email limit.",
        "x-required-scope": "send",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendInvoice"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/invoices/{id}/share-link": {
      "post": {
        "operationId": "createInvoiceShareLink",
        "summary": "Create a public share link for an invoice",
        "x-required-scope": "send",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/estimates": {
      "get": {
        "operationId": "listEstimates",
        "summary": "List estimates, newest first",
        "x-required-scope": "estimates:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Document"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createEstimate",
        "summary": "Create a draft estimate",
        "x-required-scope": "estimates:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocument"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/estimates/{id}": {
      "get": {
        "operationId": "getEstimate",
        "summary": "Get an estimate",
        "x-required-scope": "estimates:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Estimate id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "updateEstimate",
        "summary": "Update an estimate",
        "x-required-scope": "estimates:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Estimate id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEstimate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/estimates/{id}/share-link": {
      "post": {
        "operationId": "createEstimateShareLink",
        "summary": "Create a public share link for an estimate",
        "x-required-scope": "send",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Estimate id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/estimates/{id}/convert": {
      "post": {
        "operationId": "convertEstimate",
        "summary": "Convert an estimate into a new invoice",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Estimate id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/clients": {
      "get": {
        "operationId": "listClients",
        "summary": "List saved clients",
        "x-required-scope": "clients:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Client"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createClient",
        "summary": "Save a client",
        "x-required-scope": "clients:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClient"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/businesses": {
      "get": {
        "operationId": "listBusinesses",
        "summary": "List the businesses that can issue documents",
        "x-required-scope": "clients:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Business"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/editor-link": {
      "post": {
        "operationId": "createEditorLink",
        "summary": "Build a prefilled editor link for the user to review and save",
        "description": "Does not save anything or count toward limits. Use it when the user should check the document before it is created.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSource"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditorLink"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "iw_live_...",
        "description": "Scopes: invoices:read, invoices:write, estimates:read, estimates:write, clients:read, clients:write, send. Each operation lists its scope in x-required-scope."
      }
    },
    "parameters": {
      "AgentSource": {
        "name": "X-Agent-Source",
        "in": "header",
        "required": false,
        "description": "Name of the calling agent or integration, used for usage stats.",
        "schema": {
          "type": "string",
          "maxLength": 100
        }
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "The request was malformed or failed validation.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, invalid, or revoked API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "The account is on the Free plan, or a plan limit was reached.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The API key lacks the required scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist or belongs to another user.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests for this key. Retry after the Retry-After header.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "CreateDocument": {
        "type": "object",
        "properties": {
          "businessId": {
            "description": "Business that issues the document. Defaults to your most recently created business.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "clientId": {
            "description": "Saved client to bill. Use either clientId or client.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "client": {
            "description": "Client details to put on the document. Use either clientId or client.",
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "maxLength": 320,
                "format": "email",
                "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
              },
              "address": {
                "type": "string",
                "maxLength": 1000
              }
            },
            "required": [
              "name"
            ]
          },
          "items": {
            "minItems": 1,
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1000000
                },
                "rate": {
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000,
                  "description": "Unit price in the document currency."
                }
              },
              "required": [
                "description",
                "quantity",
                "rate"
              ]
            }
          },
          "currency": {
            "description": "ISO 4217 code such as USD or EUR. Defaults to USD.",
            "type": "string",
            "minLength": 1,
            "maxLength": 10
          },
          "date": {
            "description": "Issue date. Defaults to today (UTC).",
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "dueDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Calendar date in YYYY-MM-DD format."
          },
          "terms": {
            "description": "Payment terms. net7, net15, and net30 also set dueDate when it is not given.",
            "type": "string",
            "enum": [
              "none",
              "due_upon_receipt",
              "net7",
              "net15",
              "net30",
              "custom",
              "proforma"
            ]
          },
          "customTerms": {
            "description": "Terms text when terms is custom.",
            "type": "string",
            "maxLength": 2000
          },
          "notes": {
            "type": "string",
            "maxLength": 5000
          },
          "poNumber": {
            "type": "string",
            "maxLength": 100
          },
          "number": {
            "description": "Document number. Leave out to use the next number for the business.",
            "type": "string",
            "maxLength": 100
          },
          "templateId": {
            "description": "Template id from https://invoicewebsite.com/templates. Defaults to default.",
            "type": "string",
            "maxLength": 100
          },
          "discount": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "percentage",
                  "flat"
                ]
              },
              "value": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000000000
              }
            },
            "required": [
              "type",
              "value"
            ]
          },
          "taxLines": {
            "description": "Taxes, applied after the discount.",
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "percentage": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": [
                "name",
                "percentage"
              ]
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "UpdateInvoice": {
        "type": "object",
        "properties": {
          "businessId": {
            "description": "Business that issues the document. Defaults to your most recently created business.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "clientId": {
            "description": "Saved client to bill. Use either clientId or client.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "client": {
            "description": "Client details to put on the document. Use either clientId or client.",
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "maxLength": 320,
                "format": "email",
                "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
              },
              "address": {
                "type": "string",
                "maxLength": 1000
              }
            },
            "required": [
              "name"
            ]
          },
          "items": {
            "minItems": 1,
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1000000
                },
                "rate": {
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000,
                  "description": "Unit price in the document currency."
                }
              },
              "required": [
                "description",
                "quantity",
                "rate"
              ]
            }
          },
          "currency": {
            "description": "ISO 4217 code such as USD or EUR. Defaults to USD.",
            "type": "string",
            "minLength": 1,
            "maxLength": 10
          },
          "date": {
            "description": "Issue date. Defaults to today (UTC).",
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "dueDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Calendar date in YYYY-MM-DD format."
          },
          "terms": {
            "description": "Payment terms. net7, net15, and net30 also set dueDate when it is not given.",
            "type": "string",
            "enum": [
              "none",
              "due_upon_receipt",
              "net7",
              "net15",
              "net30",
              "custom",
              "proforma"
            ]
          },
          "customTerms": {
            "description": "Terms text when terms is custom.",
            "type": "string",
            "maxLength": 2000
          },
          "notes": {
            "type": "string",
            "maxLength": 5000
          },
          "poNumber": {
            "type": "string",
            "maxLength": 100
          },
          "number": {
            "description": "Document number. Leave out to use the next number for the business.",
            "type": "string",
            "maxLength": 100
          },
          "templateId": {
            "description": "Template id from https://invoicewebsite.com/templates. Defaults to default.",
            "type": "string",
            "maxLength": 100
          },
          "discount": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "percentage",
                  "flat"
                ]
              },
              "value": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000000000
              }
            },
            "required": [
              "type",
              "value"
            ]
          },
          "taxLines": {
            "description": "Taxes, applied after the discount.",
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "percentage": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": [
                "name",
                "percentage"
              ]
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "not_sent",
              "sent",
              "paid",
              "partially_paid",
              "deposit_received",
              "overdue",
              "cancelled"
            ]
          }
        }
      },
      "UpdateEstimate": {
        "type": "object",
        "properties": {
          "businessId": {
            "description": "Business that issues the document. Defaults to your most recently created business.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "clientId": {
            "description": "Saved client to bill. Use either clientId or client.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "client": {
            "description": "Client details to put on the document. Use either clientId or client.",
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "maxLength": 320,
                "format": "email",
                "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
              },
              "address": {
                "type": "string",
                "maxLength": 1000
              }
            },
            "required": [
              "name"
            ]
          },
          "items": {
            "minItems": 1,
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1000000
                },
                "rate": {
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000,
                  "description": "Unit price in the document currency."
                }
              },
              "required": [
                "description",
                "quantity",
                "rate"
              ]
            }
          },
          "currency": {
            "description": "ISO 4217 code such as USD or EUR. Defaults to USD.",
            "type": "string",
            "minLength": 1,
            "maxLength": 10
          },
          "date": {
            "description": "Issue date. Defaults to today (UTC).",
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "dueDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Calendar date in YYYY-MM-DD format."
          },
          "terms": {
            "description": "Payment terms. net7, net15, and net30 also set dueDate when it is not given.",
            "type": "string",
            "enum": [
              "none",
              "due_upon_receipt",
              "net7",
              "net15",
              "net30",
              "custom",
              "proforma"
            ]
          },
          "customTerms": {
            "description": "Terms text when terms is custom.",
            "type": "string",
            "maxLength": 2000
          },
          "notes": {
            "type": "string",
            "maxLength": 5000
          },
          "poNumber": {
            "type": "string",
            "maxLength": 100
          },
          "number": {
            "description": "Document number. Leave out to use the next number for the business.",
            "type": "string",
            "maxLength": 100
          },
          "templateId": {
            "description": "Template id from https://invoicewebsite.com/templates. Defaults to default.",
            "type": "string",
            "maxLength": 100
          },
          "discount": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "percentage",
                  "flat"
                ]
              },
              "value": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000000000
              }
            },
            "required": [
              "type",
              "value"
            ]
          },
          "taxLines": {
            "description": "Taxes, applied after the discount.",
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "percentage": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": [
                "name",
                "percentage"
              ]
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "accepted",
              "declined"
            ]
          }
        }
      },
      "SendInvoice": {
        "type": "object",
        "properties": {
          "to": {
            "description": "Recipients. Defaults to the client email on the invoice.",
            "minItems": 1,
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 320,
              "format": "email",
              "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
            }
          },
          "cc": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 320,
              "format": "email",
              "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
            }
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          }
        }
      },
      "CreateClient": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "email": {
            "type": "string",
            "maxLength": 320,
            "format": "email",
            "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
          },
          "address": {
            "type": "string",
            "maxLength": 1000
          },
          "phone": {
            "type": "string",
            "maxLength": 50
          }
        },
        "required": [
          "name"
        ]
      },
      "EditorLink": {
        "type": "object",
        "properties": {
          "documentType": {
            "default": "invoice",
            "type": "string",
            "enum": [
              "invoice",
              "estimate"
            ]
          },
          "items": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1000000
                },
                "rate": {
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000,
                  "description": "Unit price in the document currency."
                }
              },
              "required": [
                "description",
                "quantity",
                "rate"
              ]
            }
          },
          "client": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "maxLength": 320,
                "format": "email",
                "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
              },
              "address": {
                "type": "string",
                "maxLength": 1000
              }
            },
            "required": [
              "name"
            ]
          },
          "currency": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10
          },
          "date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Calendar date in YYYY-MM-DD format."
          },
          "dueDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Calendar date in YYYY-MM-DD format."
          },
          "terms": {
            "type": "string",
            "enum": [
              "none",
              "due_upon_receipt",
              "net7",
              "net15",
              "net30",
              "custom",
              "proforma"
            ]
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "poNumber": {
            "type": "string",
            "maxLength": 100
          },
          "tax": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "percentage": {
                "type": "number",
                "minimum": 0,
                "maximum": 100
              }
            },
            "required": [
              "name",
              "percentage"
            ]
          },
          "templateId": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice",
              "estimate"
            ]
          },
          "number": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          },
          "businessId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "client": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "email": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "address": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "email",
              "address"
            ],
            "additionalProperties": false
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "rate": {
                  "type": "number"
                },
                "amount": {
                  "type": "number"
                }
              },
              "required": [
                "description",
                "quantity",
                "rate",
                "amount"
              ],
              "additionalProperties": false
            }
          },
          "discount": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "value": {
                "type": "number"
              },
              "amount": {
                "type": "number"
              }
            },
            "required": [
              "type",
              "value",
              "amount"
            ],
            "additionalProperties": false
          },
          "taxLines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "percentage": {
                  "type": "number"
                },
                "amount": {
                  "type": "number"
                }
              },
              "required": [
                "name",
                "percentage",
                "amount"
              ],
              "additionalProperties": false
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "subtotal": {
                "type": "number"
              },
              "discount": {
                "type": "number"
              },
              "tax": {
                "type": "number"
              },
              "total": {
                "type": "number"
              }
            },
            "required": [
              "subtotal",
              "discount",
              "tax",
              "total"
            ],
            "additionalProperties": false
          },
          "terms": {
            "type": "string"
          },
          "customTerms": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "poNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "templateId": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "viewUrl": {
            "type": "string",
            "format": "uri",
            "description": "Opens the document in the signed-in dashboard."
          },
          "editUrl": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "id",
          "type",
          "number",
          "status",
          "date",
          "dueDate",
          "currency",
          "businessId",
          "client",
          "items",
          "discount",
          "taxLines",
          "totals",
          "terms",
          "customTerms",
          "notes",
          "poNumber",
          "templateId",
          "createdAt",
          "updatedAt",
          "viewUrl",
          "editUrl"
        ],
        "additionalProperties": false
      },
      "Client": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": "string"
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "address",
          "phone",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "Business": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "address",
          "phone",
          "website"
        ],
        "additionalProperties": false
      },
      "Me": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "basic",
              "premium"
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "documentsRemainingThisMonth": {
                "description": "null means unlimited.",
                "type": [
                  "number",
                  "null"
                ]
              },
              "emailsRemainingToday": {
                "description": "null means unlimited.",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "documentsRemainingThisMonth",
              "emailsRemainingToday"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "userId",
          "email",
          "plan",
          "scopes",
          "usage"
        ],
        "additionalProperties": false
      },
      "ShareLink": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "url"
        ],
        "additionalProperties": false
      },
      "SendResult": {
        "type": "object",
        "properties": {
          "sent": {
            "type": "boolean",
            "const": true
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "shareUrl": {
            "type": "string",
            "format": "uri"
          },
          "status": {
            "type": "string"
          },
          "warning": {
            "type": "string"
          }
        },
        "required": [
          "sent",
          "recipients",
          "shareUrl",
          "status"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      }
    }
  }
}