{
  "openapi": "3.0.0",
  "info": {
    "title": "LedgerBeaver AI API",
    "version": "1.0.0",
    "description": "REST API wrapper for LedgerBeaver MCP tools for external agentic AI connection."
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api/v1/fiscal-periods-list": {
      "post": {
        "summary": "List all fiscal periods for a company with their close status.",
        "operationId": "fiscal_periods_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  },
                  "statusFilter": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "limit",
                  "statusFilter"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fiscal-period-close": {
      "post": {
        "summary": "Close a fiscal period (Soft or Hard). Hard close is IRREVERSIBLE and prevents all journal entries in that period. HIGH RISK.",
        "operationId": "fiscal_period_close",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodKey": {
                    "type": "string"
                  },
                  "closeType": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "periodKey",
                  "closeType",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fiscal-period-reopen": {
      "post": {
        "summary": "Reopen a soft-closed period. Cannot reopen hard-closed periods. HIGH RISK.",
        "operationId": "fiscal_period_reopen",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodKey": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "periodKey",
                  "reason",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fiscal-period-check": {
      "post": {
        "summary": "Check whether a specific date falls within a hard-closed period (to verify entries are allowed).",
        "operationId": "fiscal_period_check",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "date"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/integrity-check-ar": {
      "post": {
        "summary": "Run Accounts Receivable sub-ledger integrity check. Compares AR Invoices - Payments - Credits against GL AR Control Account. Discrepancies are logged to integrity_alerts.",
        "operationId": "integrity_check_ar",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodKey": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "periodKey"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/integrity-check-ap": {
      "post": {
        "summary": "Run Accounts Payable sub-ledger integrity check. Compares AP Invoices - Payments against GL AP Control Account. Discrepancies are logged to integrity_alerts.",
        "operationId": "integrity_check_ap",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodKey": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "periodKey"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/integrity-check-full": {
      "post": {
        "summary": "Run a complete integrity check on both AR and AP sub-ledgers against the GL. Creates alerts for any discrepancies found.",
        "operationId": "integrity_check_full",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodKey": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "periodKey"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/integrity-alerts-list": {
      "post": {
        "summary": "List all open (unresolved) integrity alerts for a company. Shows AR/AP drift details.",
        "operationId": "integrity_alerts_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/integrity-alert-resolve": {
      "post": {
        "summary": "Mark an integrity alert as resolved with an explanation.",
        "operationId": "integrity_alert_resolve",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "alertId": {
                    "type": "string"
                  },
                  "resolutionNote": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "alertId",
                  "resolutionNote"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-reconcile-entry": {
      "post": {
        "summary": "Link a journal entry to a bank statement transaction, marking both as reconciled. Records match confidence.",
        "operationId": "recon_reconcile_entry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "entryId": {
                    "type": "string"
                  },
                  "bankTransactionId": {
                    "type": "string"
                  },
                  "matchConfidence": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "entryId",
                  "bankTransactionId",
                  "matchConfidence"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-unreconciled-entries": {
      "post": {
        "summary": "List journal entries that haven't been matched to a bank statement yet. Helps identify outstanding items for reconciliation.",
        "operationId": "recon_unreconciled_entries",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  },
                  "fromDate": {
                    "type": "string"
                  },
                  "toDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "limit",
                  "fromDate",
                  "toDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-action-inbox": {
      "post": {
        "summary": "Show actionable items needing human attention, sorted by urgency. Each item includes a suggested next action. Ask: What needs my attention? What should I do today? What's in my inbox?",
        "operationId": "bi_action_inbox",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-list-invoices": {
      "post": {
        "summary": "List AP invoices with optional status filter.",
        "operationId": "ap_list_invoices",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-get-invoice": {
      "post": {
        "summary": "Get full details of a specific AP invoice.",
        "operationId": "ap_get_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-list-vendors": {
      "post": {
        "summary": "List vendors for the company.",
        "operationId": "ap_list_vendors",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-list-recurring-templates": {
      "post": {
        "summary": "List recurring AP invoice templates with next scheduled invoice date and status.",
        "operationId": "ap_list_recurring_templates",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-get-payment-batches": {
      "post": {
        "summary": "List payment batches and their status.",
        "operationId": "ap_get_payment_batches",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-aging-report": {
      "post": {
        "summary": "Get AP aging report - breakdown of outstanding payables by aging bucket (current, 1-30, 31-60, 61-90, 90+ days).",
        "operationId": "ap_aging_report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-vendor-statement": {
      "post": {
        "summary": "Get a full statement for a vendor showing all open invoices, total outstanding balance, and available credit.",
        "operationId": "ap_vendor_statement",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendor_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendor_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-check-duplicate-invoice": {
      "post": {
        "summary": "Check for potential duplicate AP invoices before creating a new one. Flags matching vendor+invoice_number, or similar amounts on same date from same vendor.",
        "operationId": "ap_check_duplicate_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendor_id": {
                    "type": "string"
                  },
                  "invoice_number": {
                    "type": "string"
                  },
                  "total_amount": {
                    "type": "number"
                  },
                  "invoice_date": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendor_id",
                  "invoice_number",
                  "total_amount",
                  "invoice_date"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-get-discounts-available": {
      "post": {
        "summary": "List invoices with early payment discounts available.",
        "operationId": "ap_get_discounts_available",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-create-invoice": {
      "post": {
        "summary": "Prepare a new AP invoice. Requires human approval.",
        "operationId": "ap_prepare_create_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendor_id": {
                    "type": "string"
                  },
                  "invoice_number": {
                    "type": "string"
                  },
                  "invoice_date": {
                    "type": "string"
                  },
                  "subtotal": {
                    "type": "number"
                  },
                  "tax": {
                    "type": "number"
                  },
                  "total": {
                    "type": "number"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "capture_method": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  },
                  "po_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendor_id",
                  "invoice_number",
                  "invoice_date",
                  "subtotal",
                  "tax",
                  "total",
                  "due_date",
                  "capture_method",
                  "source",
                  "po_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-approve-invoice": {
      "post": {
        "summary": "Prepare approval for an AP invoice. Amount > $5000 requires double confirmation.",
        "operationId": "ap_prepare_approve_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "comments"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-schedule-payment": {
      "post": {
        "summary": "Schedule a payment for an approved invoice. Low risk.",
        "operationId": "ap_prepare_schedule_payment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "payment_date": {
                    "type": "string"
                  },
                  "payment_method": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "payment_date",
                  "payment_method"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-void-invoice": {
      "post": {
        "summary": "Prepare to void/cancel an AP invoice. HIGH RISK - reverses the GL entry if auto-posted. Cannot void already-paid invoices.",
        "operationId": "ap_prepare_void_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-execute-payment": {
      "post": {
        "summary": "Execute a payment. HIGH RISK - money leaves the account. Double confirmation required.",
        "operationId": "ap_prepare_execute_payment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "method": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "amount",
                  "method"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-create-recurring-template": {
      "post": {
        "summary": "Prepare a recurring AP invoice template for automatic periodic invoice generation.",
        "operationId": "ap_prepare_create_recurring_template",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendor_id": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "frequency": {
                    "type": "string"
                  },
                  "next_due_date": {
                    "type": "string"
                  },
                  "end_date": {
                    "type": "string"
                  },
                  "auto_approve": {
                    "type": "boolean"
                  },
                  "expense_account": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendor_id",
                  "template_name",
                  "amount",
                  "frequency",
                  "next_due_date",
                  "end_date",
                  "auto_approve",
                  "expense_account",
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-generate-recurring": {
      "post": {
        "summary": "Generate the next invoice from a recurring AP template. LOW risk.",
        "operationId": "ap_prepare_generate_recurring",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "template_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "template_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-prepare-post-to-gl": {
      "post": {
        "summary": "Post an AP invoice to GL. HIGH RISK - permanent entry. Double confirmation required.",
        "operationId": "ap_prepare_post_to_gl",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "debit_account": {
                    "type": "string"
                  },
                  "credit_account": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "debit_account",
                  "credit_account"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ap-approaching-deadlines": {
      "post": {
        "summary": "Show AP bills approaching their due dates and any early-payment discount opportunities. Returns a ranked priority list for cash flow decisions.",
        "operationId": "ap_approaching_deadlines",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "daysAhead": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "daysAhead"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/list-pending-actions": {
      "post": {
        "summary": "List all pending actions awaiting human approval across all modules (AP, AR, GL, Finance).",
        "operationId": "list_pending_actions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action_id": {
                    "type": "string"
                  },
                  "approved_by": {
                    "type": "string"
                  }
                },
                "required": [
                  "action_id",
                  "approved_by"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/confirm-action": {
      "post": {
        "summary": "Confirm a high-risk action after initial approval. This is the final step — the action EXECUTES after this call.",
        "operationId": "confirm_action",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirmation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "confirmation_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/modify-action": {
      "post": {
        "summary": "Modify a pending action's parameters before approval. Resets the expiry timer.",
        "operationId": "modify_action",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action_id": {
                    "type": "string"
                  },
                  "new_params": {
                    "type": "string"
                  },
                  "new_description": {
                    "type": "string"
                  }
                },
                "required": [
                  "action_id",
                  "new_params",
                  "new_description"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/reject-action": {
      "post": {
        "summary": "Reject a pending action. Rejection is logged in the audit trail.",
        "operationId": "reject_action",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action_id": {
                    "type": "string"
                  },
                  "rejected_by": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "action_id",
                  "rejected_by",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-invoices": {
      "post": {
        "summary": "List AR invoices with optional status filter.",
        "operationId": "ar_list_invoices",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-get-invoice": {
      "post": {
        "summary": "Get full details of a specific AR invoice.",
        "operationId": "ar_get_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-customers": {
      "post": {
        "summary": "List customers for the company.",
        "operationId": "ar_list_customers",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-payments": {
      "post": {
        "summary": "List AR payments (cash receipts) with optional status filter.",
        "operationId": "ar_list_payments",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-prepayments": {
      "post": {
        "summary": "List customer prepayments/deposits and remaining unapplied deposit balances.",
        "operationId": "ar_list_prepayments",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "openOnly": {
                    "type": "boolean"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "openOnly",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-overpayments": {
      "post": {
        "summary": "List customer overpayments / unapplied cash receipts that can be refunded or applied to future invoices.",
        "operationId": "ar_list_overpayments",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-nsf-payments": {
      "post": {
        "summary": "List AR payments marked NSF / bounced, including reversed amounts and reason.",
        "operationId": "ar_list_nsf_payments",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-aging-report": {
      "post": {
        "summary": "Get AR aging report - breakdown of outstanding receivables by aging bucket.",
        "operationId": "ar_aging_report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-disputes": {
      "post": {
        "summary": "List disputed AR invoices, including collections hold and resolution status.",
        "operationId": "ar_list_disputes",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "customer_id",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-write-offs": {
      "post": {
        "summary": "List AR bad debt write-offs by customer/invoice.",
        "operationId": "ar_list_write_offs",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-list-payment-plans": {
      "post": {
        "summary": "List AR payment plans and installment status for invoices on payment arrangements.",
        "operationId": "ar_list_payment_plans",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "customer_id",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-get-payment-plan": {
      "post": {
        "summary": "Get one AR payment plan with all installments and progress summary.",
        "operationId": "ar_get_payment_plan",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "payment_plan_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "payment_plan_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-get-invoice-payment-history": {
      "post": {
        "summary": "Get the complete payment history for an AR invoice — all partial payments, dates, methods, and remaining balance.",
        "operationId": "ar_get_invoice_payment_history",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-create-invoice": {
      "post": {
        "summary": "Prepare a new AR invoice. Requires human approval before creating.",
        "operationId": "ar_prepare_create_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "invoice_number": {
                    "type": "string"
                  },
                  "invoice_date": {
                    "type": "string"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "subtotal": {
                    "type": "number"
                  },
                  "tax": {
                    "type": "number"
                  },
                  "total": {
                    "type": "number"
                  },
                  "payment_terms": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "invoice_number",
                  "invoice_date",
                  "due_date",
                  "subtotal",
                  "tax",
                  "total",
                  "payment_terms"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-open-invoice-dispute": {
      "post": {
        "summary": "Prepare to mark an AR invoice as disputed. This places collections on hold but does not remove AR or post GL.",
        "operationId": "ar_prepare_open_invoice_dispute",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "disputed_amount": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "disputed_amount",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-resolve-invoice-dispute": {
      "post": {
        "summary": "Prepare to resolve an invoice dispute. HIGH RISK if credit adjustment is applied because AR/GL changes.",
        "operationId": "ar_prepare_resolve_invoice_dispute",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "dispute_id": {
                    "type": "string"
                  },
                  "resolution": {
                    "type": "string"
                  },
                  "resolution_amount": {
                    "type": "number"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "dispute_id",
                  "resolution",
                  "resolution_amount",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-write-off-bad-debt": {
      "post": {
        "summary": "Prepare to write off an uncollectible AR invoice balance as bad debt. HIGH RISK - reduces AR and posts bad debt expense.",
        "operationId": "ar_prepare_write_off_bad_debt",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "write_off_date": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "amount",
                  "write_off_date",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-create-payment-plan": {
      "post": {
        "summary": "Prepare an AR payment plan for an invoice, splitting the remaining balance into scheduled installments.",
        "operationId": "ar_prepare_create_payment_plan",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "installment_count": {
                    "type": "number"
                  },
                  "start_date": {
                    "type": "string"
                  },
                  "frequency": {
                    "type": "string"
                  },
                  "plan_number": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoice_id",
                  "installment_count",
                  "start_date",
                  "frequency",
                  "plan_number",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-record-prepayment": {
      "post": {
        "summary": "Prepare to record a customer prepayment/deposit received before an invoice is issued or revenue is recognized.",
        "operationId": "ar_prepare_record_prepayment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "received_date": {
                    "type": "string"
                  },
                  "payment_method": {
                    "type": "string"
                  },
                  "reference_number": {
                    "type": "string"
                  },
                  "payment_type": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "amount",
                  "received_date",
                  "payment_method",
                  "reference_number",
                  "payment_type",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-apply-payment": {
      "post": {
        "summary": "Prepare to apply a payment to an invoice. AI suggests the match, human confirms.",
        "operationId": "ar_prepare_apply_payment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "payment_id": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "payment_plan_id": {
                    "type": "string"
                  },
                  "installment_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "payment_id",
                  "invoice_id",
                  "amount",
                  "payment_plan_id",
                  "installment_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-record-nsf": {
      "post": {
        "summary": "Prepare to record an NSF / bounced customer payment. HIGH RISK - reopens invoices and reverses cash/AR GL entries.",
        "operationId": "ar_prepare_record_nsf",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "payment_id": {
                    "type": "string"
                  },
                  "nsf_date": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "payment_id",
                  "nsf_date",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-prepare-issue-credit": {
      "post": {
        "summary": "Prepare a credit memo. HIGH RISK - affects GL and customer balance.",
        "operationId": "ar_prepare_issue_credit",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "invoice_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "customer_id",
                  "invoice_id",
                  "amount",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/ar-run-collections-cycle": {
      "post": {
        "summary": "Run an automated AR collections cycle. Checks all overdue invoices, groups by customer, drafts appropriate-toned emails, and optionally sends them. Use dryRun=true to preview without sending.",
        "operationId": "ar_run_collections_cycle",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "dryRun": {
                    "type": "boolean"
                  },
                  "maxDaysOverdue": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "dryRun",
                  "maxDaysOverdue"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/auth-list-keys": {
      "post": {
        "summary": "List all API keys for the current company (key values are never exposed).",
        "operationId": "auth_list_keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/auth-status": {
      "post": {
        "summary": "Check authentication context — company, mode.",
        "operationId": "auth_status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "permissions": {
                    "type": "string"
                  },
                  "expiresInDays": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "name",
                  "permissions",
                  "expiresInDays"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/auth-revoke-key": {
      "post": {
        "summary": "Revoke an API key immediately.",
        "operationId": "auth_revoke_key",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "keyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "keyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/auth-revoke-all-keys": {
      "post": {
        "summary": "Revoke ALL active keys. Requires confirm=true.",
        "operationId": "auth_revoke_all_keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-checklist": {
      "post": {
        "summary": "Show the month-end close checklist to see what needs to be done.",
        "operationId": "close_checklist",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-peek": {
      "post": {
        "summary": "Preview the closing journal entry without posting it.",
        "operationId": "close_peek",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-run": {
      "post": {
        "summary": "EXECUTE month-end close. Creates closing entry and locks the period. HIGH RISK.",
        "operationId": "close_run",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "period",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-reopen": {
      "post": {
        "summary": "Reopen a soft-closed period. Cannot reopen hard-closed periods. HIGH RISK.",
        "operationId": "close_reopen",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "period",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-hardLock": {
      "post": {
        "summary": "HARD CLOSE a period. IRREVERSIBLE — cannot be undone even by close_reopen. Requires prior soft close. Only for auditor/final sign-off. EXTREME RISK.",
        "operationId": "close_hardLock",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "period",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/close-status": {
      "post": {
        "summary": "Check the close status of periods.",
        "operationId": "close_status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-cash": {
      "post": {
        "summary": "Check cash position: total cash across all bank accounts. Ask: How much cash do we have?",
        "operationId": "bi_cash",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-who-owes-me": {
      "post": {
        "summary": "Show who owes the business money (AR aging). Ask: Who owes me money?",
        "operationId": "bi_who_owes_me",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-who-do-i-owe": {
      "post": {
        "summary": "Show who the business owes money to (AP aging). Ask: Who do I owe money?",
        "operationId": "bi_who_do_i_owe",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-top-expenses": {
      "post": {
        "summary": "Show the biggest expense categories. Ask: Where is my money going? What are my biggest expenses?",
        "operationId": "bi_top_expenses",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-revenue": {
      "post": {
        "summary": "Show revenue breakdown. Ask: How's revenue? How much did we make?",
        "operationId": "bi_revenue",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-overdue-now": {
      "post": {
        "summary": "Show all invoices that are past due RIGHT NOW. Ask: Which invoices are overdue?",
        "operationId": "bi_overdue_now",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-bills-due": {
      "post": {
        "summary": "Show bills due this week (next 7 days). Ask: What bills are due this week?",
        "operationId": "bi_bills_due",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-snapshot": {
      "post": {
        "summary": "Quick business health check: cash, net income, overdue AR, upcoming AP, top expense. Ask: How's the business doing?",
        "operationId": "bi_snapshot",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/bi-daily-briefing": {
      "post": {
        "summary": "Generate a morning business briefing: cash position, P&L summary, overdue alerts, upcoming bills, anomalies, and a recommended focus for the day. Ask: Give me today's briefing. How's the business looking today?",
        "operationId": "bi_daily_briefing",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/dashboard-summary": {
      "post": {
        "summary": "Get a complete financial dashboard: cash position, AR/AP aging, P&L snapshot, and upcoming deadlines.",
        "operationId": "dashboard_summary",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-cash-position": {
      "post": {
        "summary": "Get the current cash position - latest projected cash balance from cash flow forecasts.",
        "operationId": "finance_cash_position",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-budget-vs-actual": {
      "post": {
        "summary": "Get budget vs actual comparison for a given period.",
        "operationId": "finance_budget_vs_actual",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-get-kpis": {
      "post": {
        "summary": "Get key performance indicators for the company.",
        "operationId": "finance_get_kpis",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-cash-flow-forecast": {
      "post": {
        "summary": "Get cash flow forecast for upcoming weeks.",
        "operationId": "finance_cash_flow_forecast",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "weeks": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "weeks"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-list-decisions": {
      "post": {
        "summary": "List finance decisions (pending and resolved).",
        "operationId": "finance_list_decisions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-list-reports": {
      "post": {
        "summary": "List generated financial reports.",
        "operationId": "finance_list_reports",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "report_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "report_type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-prepare-set-budget": {
      "post": {
        "summary": "Prepare budget amounts for a period. Requires human approval.",
        "operationId": "finance_prepare_set_budget",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "subcategory": {
                    "type": "string"
                  },
                  "budget_amount": {
                    "type": "number"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period",
                  "category",
                  "subcategory",
                  "budget_amount",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-prepare-generate-report": {
      "post": {
        "summary": "Prepare to generate a financial report. HIGH RISK - report may be distributed externally.",
        "operationId": "finance_prepare_generate_report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "report_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "period",
                  "report_type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/finance-prepare-sync-sheets": {
      "post": {
        "summary": "Prepare to sync data to Google Sheets. HIGH RISK - writes to external system.",
        "operationId": "finance_prepare_sync_sheets",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "sheet_tab": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "sheet_tab"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fin-pnl": {
      "post": {
        "summary": "Generate Profit & Loss (Income Statement) for a period.",
        "operationId": "fin_pnl",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fin-balance-sheet": {
      "post": {
        "summary": "Generate a Balance Sheet — snapshot of assets, liabilities, and equity.",
        "operationId": "fin_balance_sheet",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fin-trial-balance": {
      "post": {
        "summary": "Generate a Trial Balance — all GL accounts with debit/credit columns.",
        "operationId": "fin_trial_balance",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fin-export-pnl": {
      "post": {
        "summary": "Generate P&L data as structured JSON (for PDF generation or export).",
        "operationId": "fin_export_pnl",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fin-cash-flow": {
      "post": {
        "summary": "Generate a Cash Flow Statement showing operating, investing, and financing cash flows.",
        "operationId": "fin_cash_flow",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fuzzy-match-vendor": {
      "post": {
        "summary": "Find the closest matching vendor for a given name string. Useful when an AI ingests an invoice from an email and the vendor name doesn't exactly match the database. Returns top matches with confidence scores.",
        "operationId": "fuzzy_match_vendor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorName": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "vendorName",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fuzzy-match-customer": {
      "post": {
        "summary": "Find the closest matching customer for a given name string. Use when an AI needs to match a customer name from a payment, invoice, or email to the database.",
        "operationId": "fuzzy_match_customer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customerName": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "customerName",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fuzzy-match-account": {
      "post": {
        "summary": "Find the closest matching GL account for a given account name or description. Useful when categorizing expenses or mapping imported transactions to the chart of accounts.",
        "operationId": "fuzzy_match_account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "accountName": {
                    "type": "string"
                  },
                  "accountType": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "accountName",
                  "accountType",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/fuzzy-check-duplicate": {
      "post": {
        "summary": "Check if an AP invoice might be a duplicate of an existing one. Compares vendor, amount, and invoice number. Use BEFORE creating a new AP invoice to avoid duplicates.",
        "operationId": "fuzzy_check_duplicate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "invoiceNumber": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "tolerance": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "invoiceNumber",
                  "amount",
                  "tolerance"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-createJournalEntry": {
      "post": {
        "summary": "Create a draft journal entry. Balance (DR=CR) is enforced; unbalanced entries are rejected. Does NOT post to ledger — call gl_postJournalEntry to post.",
        "operationId": "gl_createJournalEntry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "entryDate": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "lines": {
                    "type": "string"
                  },
                  "accountId": {
                    "type": "string"
                  },
                  "debit": {
                    "type": "number"
                  },
                  "credit": {
                    "type": "number"
                  },
                  "sourceModule": {
                    "type": "string"
                  },
                  "sourceId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "entryDate",
                  "description",
                  "lines",
                  "accountId",
                  "debit",
                  "credit",
                  "description",
                  "sourceModule",
                  "sourceId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-postJournalEntry": {
      "post": {
        "summary": "Post a draft journal entry to the ledger. Double-checks balance and updates account balances. Once posted, entries CANNOT be edited — use gl_reverseEntry to correct.",
        "operationId": "gl_postJournalEntry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "journalEntryId": {
                    "type": "string"
                  },
                  "postedBy": {
                    "type": "string"
                  }
                },
                "required": [
                  "journalEntryId",
                  "postedBy"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-listJournalEntries": {
      "post": {
        "summary": "List journal entries with optional filters. Defaults to most recent first.",
        "operationId": "gl_listJournalEntries",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  },
                  "postedOnly": {
                    "type": "boolean"
                  },
                  "draftOnly": {
                    "type": "boolean"
                  },
                  "entryType": {
                    "type": "string"
                  },
                  "sourceModule": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  },
                  "offset": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate",
                  "postedOnly",
                  "draftOnly",
                  "entryType",
                  "sourceModule",
                  "limit",
                  "offset"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-getJournalEntry": {
      "post": {
        "summary": "Get a single journal entry with all its ledger lines and account names.",
        "operationId": "gl_getJournalEntry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "journalEntryId": {
                    "type": "string"
                  }
                },
                "required": [
                  "journalEntryId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-reverseEntry": {
      "post": {
        "summary": "Create a reversing entry for a posted journal entry. Creates a new entry that mirrors the original (DR↔CR). Original is marked as reversed. HIGH RISK — creates new posted entry.",
        "operationId": "gl_reverseEntry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "journalEntryId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "reversedBy": {
                    "type": "string"
                  }
                },
                "required": [
                  "journalEntryId",
                  "reason",
                  "reversedBy"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-getAccountDetail": {
      "post": {
        "summary": "Get detailed ledger activity for a single GL account — all debit/credit movements with journal entry links.",
        "operationId": "gl_getAccountDetail",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "accountId",
                  "startDate",
                  "endDate",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-listAccounts": {
      "post": {
        "summary": "List chart of accounts with balances. Filterable by account type and active status.",
        "operationId": "gl_listAccounts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "accountType": {
                    "type": "string"
                  },
                  "activeOnly": {
                    "type": "boolean"
                  },
                  "includeZeroBalance": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "accountType",
                  "activeOnly",
                  "includeZeroBalance"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-getAccount": {
      "post": {
        "summary": "Get a single GL account with full details and current balance.",
        "operationId": "gl_getAccount",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "accountId": {
                    "type": "string"
                  }
                },
                "required": [
                  "accountId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-getTrialBalance": {
      "post": {
        "summary": "Get trial balance showing all account balances for a date range. Uses the DB get_trial_balance function.",
        "operationId": "gl_getTrialBalance",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-checkBalance": {
      "post": {
        "summary": "Quick GL health check — computes aggregate debits vs credits across ALL posted entries. Returns balanced/unbalanced status with totals.",
        "operationId": "gl_checkBalance",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-simpleEntry": {
      "post": {
        "summary": "Create and immediately post a simple two-line journal entry in one call. Good for quick adjustments.",
        "operationId": "gl_simpleEntry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "debitAccountId": {
                    "type": "string"
                  },
                  "creditAccountId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "date",
                  "description",
                  "debitAccountId",
                  "creditAccountId",
                  "amount"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/gl-auditTrail": {
      "post": {
        "summary": "Get the audit trail for a GL account or period — all posted entries with timestamps, descriptions, and balance impact.",
        "operationId": "gl_auditTrail",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "accountId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "accountId",
                  "startDate",
                  "endDate",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-requestReversal": {
      "post": {
        "summary": "Request to reverse (void) a posted transaction. Does NOT execute — goes to Authority Gate for human approval. Creates an offsetting journal entry upon execution. No data is ever deleted.",
        "operationId": "authority_requestReversal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "originalType": {
                    "type": "string"
                  },
                  "originalId": {
                    "type": "string"
                  },
                  "originalReference": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "requestedBy": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "originalType",
                  "originalId",
                  "originalReference",
                  "reason",
                  "requestedBy"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-approveReversal": {
      "post": {
        "summary": "Approve a pending reversal request. HUMAN SIGN-OFF REQUIRED. No reversal can be executed without a human user approving it first.",
        "operationId": "authority_approveReversal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reversalRequestId": {
                    "type": "string"
                  },
                  "approvedBy": {
                    "type": "string"
                  },
                  "approvedByName": {
                    "type": "string"
                  }
                },
                "required": [
                  "reversalRequestId",
                  "approvedBy",
                  "approvedByName"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-rejectReversal": {
      "post": {
        "summary": "Reject a pending reversal request. Rejection is logged permanently.",
        "operationId": "authority_rejectReversal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reversalRequestId": {
                    "type": "string"
                  },
                  "rejectedBy": {
                    "type": "string"
                  },
                  "rejectedByName": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reversalRequestId",
                  "rejectedBy",
                  "rejectedByName",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-listReversals": {
      "post": {
        "summary": "List reversal requests with status filter.",
        "operationId": "authority_listReversals",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "originalType": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "originalType",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-setThreshold": {
      "post": {
        "summary": "Set an approval threshold for a company. Transactions above this amount require human review.",
        "operationId": "authority_setThreshold",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "thresholdAmount": {
                    "type": "number"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "appliesTo": {
                    "type": "string"
                  },
                  "autoApproveBelow": {
                    "type": "boolean"
                  },
                  "requiredRole": {
                    "type": "string"
                  },
                  "dualApprovalAbove": {
                    "type": "number"
                  },
                  "active": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "name",
                  "thresholdAmount",
                  "currency",
                  "appliesTo",
                  "autoApproveBelow",
                  "requiredRole",
                  "dualApprovalAbove",
                  "active"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-checkThreshold": {
      "post": {
        "summary": "Check what threshold rules would apply to a hypothetical transaction. Useful for AI agents to preview before proposing.",
        "operationId": "authority_checkThreshold",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "module": {
                    "type": "string"
                  },
                  "currency": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "amount",
                  "module",
                  "currency"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-listThresholds": {
      "post": {
        "summary": "List all approval thresholds for a company.",
        "operationId": "authority_listThresholds",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "activeOnly": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "activeOnly"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-proposePayment": {
      "post": {
        "summary": "AI agent proposes a payment. The payment enters the Authority Gate as PROPOSED and awaits human review/approval. No money moves without human sign-off.",
        "operationId": "authority_proposePayment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "batchDate": {
                    "type": "string"
                  },
                  "paymentMethod": {
                    "type": "string"
                  },
                  "invoiceIds": {
                    "type": "string"
                  },
                  "proposedBy": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "batchDate",
                  "paymentMethod",
                  "invoiceIds",
                  "proposedBy",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-approvePayment": {
      "post": {
        "summary": "Human approves a proposed payment batch. HUMAN SIGN-OFF REQUIRED. No payment can be submitted without a human user explicitly approving it.",
        "operationId": "authority_approvePayment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batchId": {
                    "type": "string"
                  },
                  "approvedBy": {
                    "type": "string"
                  },
                  "approvedByName": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "batchId",
                  "approvedBy",
                  "approvedByName",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-rejectPayment": {
      "post": {
        "summary": "Human rejects a proposed payment batch. Rejection is logged permanently.",
        "operationId": "authority_rejectPayment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batchId": {
                    "type": "string"
                  },
                  "rejectedBy": {
                    "type": "string"
                  },
                  "rejectedByName": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "batchId",
                  "rejectedBy",
                  "rejectedByName",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/authority-getDecisionLog": {
      "post": {
        "summary": "Get the immutable decision log for a company — every approve, reject, propose, auto-approve, and reversal.",
        "operationId": "authority_getDecisionLog",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "recordType": {
                    "type": "string"
                  },
                  "recordId": {
                    "type": "string"
                  },
                  "decisionType": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "recordType",
                  "recordId",
                  "decisionType",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-list": {
      "post": {
        "summary": "List notes for a company with optional filters: entity type, entity ID, pinned, tags, date range, and text search.",
        "operationId": "notes_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "entityType": {
                    "type": "string"
                  },
                  "entityId": {
                    "type": "string"
                  },
                  "pinned": {
                    "type": "boolean"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "fromDate": {
                    "type": "string"
                  },
                  "toDate": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  },
                  "offset": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "entityType",
                  "entityId",
                  "pinned",
                  "tags",
                  "search",
                  "fromDate",
                  "toDate",
                  "limit",
                  "offset"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-get": {
      "post": {
        "summary": "Get full details of a specific note by its UUID.",
        "operationId": "notes_get",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "noteId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-search": {
      "post": {
        "summary": "Full-text search across all note titles and content.",
        "operationId": "notes_search",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "query": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "entityType": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "query",
                  "tags",
                  "entityType",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-journal": {
      "post": {
        "summary": "List or view daily journal entries. If no date specified, returns today's entries. Entity type is 'journal' with entity_id derived from the date.",
        "operationId": "notes_journal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "date",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-create": {
      "post": {
        "summary": "Create a new note attached to a business entity (vendor, customer, invoice, etc.) or as a standalone journal entry.",
        "operationId": "notes_create",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "entityType": {
                    "type": "string"
                  },
                  "entityId": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "pinned": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "entityType",
                  "entityId",
                  "title",
                  "content",
                  "tags",
                  "pinned"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-update": {
      "post": {
        "summary": "Update an existing note's title, content, tags, or pinned status.",
        "operationId": "notes_update",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "pinned": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "noteId",
                  "title",
                  "content",
                  "tags",
                  "pinned"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-archive": {
      "post": {
        "summary": "Archive a note (soft delete — it's hidden from normal views but recoverable).",
        "operationId": "notes_archive",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "noteId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-unarchive": {
      "post": {
        "summary": "Restore an archived note back to active.",
        "operationId": "notes_unarchive",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "noteId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-delete": {
      "post": {
        "summary": "Permanently delete a note.",
        "operationId": "notes_delete",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "noteId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-toggle-pin": {
      "post": {
        "summary": "Toggle the pinned status of a note.",
        "operationId": "notes_toggle_pin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "noteId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "noteId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notes-quick-journal": {
      "post": {
        "summary": "Quickly create a daily journal entry. Automatically sets entity_type='journal' and tags with the date.",
        "operationId": "notes_quick_journal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "content",
                  "date",
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notification-list": {
      "post": {
        "summary": "List sent/pending notifications with filters for recipient type, event type, and status.",
        "operationId": "notification_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "recipientType": {
                    "type": "string"
                  },
                  "triggerEvent": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "recipientType",
                  "triggerEvent",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notification-get": {
      "post": {
        "summary": "Get full details of a specific notification including the email body.",
        "operationId": "notification_get",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notification-send": {
      "post": {
        "summary": "Send a notification email to a vendor or customer. Uses predefined templates for common events or a custom message.",
        "operationId": "notification_send",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "recipientType": {
                    "type": "string"
                  },
                  "recipientId": {
                    "type": "string"
                  },
                  "triggerEvent": {
                    "type": "string"
                  },
                  "templateData": {
                    "type": "string"
                  },
                  "invoiceNumber": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "dueDate": {
                    "type": "string"
                  },
                  "paymentMethod": {
                    "type": "string"
                  },
                  "scheduledDate": {
                    "type": "string"
                  },
                  "referenceNumber": {
                    "type": "string"
                  },
                  "portalUrl": {
                    "type": "string"
                  },
                  "customSubject": {
                    "type": "string"
                  },
                  "customBody": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "recipientType",
                  "recipientId",
                  "triggerEvent",
                  "templateData",
                  "invoiceNumber",
                  "amount",
                  "dueDate",
                  "paymentMethod",
                  "scheduledDate",
                  "referenceNumber",
                  "portalUrl",
                  "customSubject",
                  "customBody"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notification-send-bulk": {
      "post": {
        "summary": "Send the same notification to multiple recipients at once. Useful for payment confirmations or overdue reminders.",
        "operationId": "notification_send_bulk",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "recipientType": {
                    "type": "string"
                  },
                  "recipientIds": {
                    "type": "string"
                  },
                  "triggerEvent": {
                    "type": "string"
                  },
                  "templateData": {
                    "type": "string"
                  },
                  "customSubject": {
                    "type": "string"
                  },
                  "customBody": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "recipientType",
                  "recipientIds",
                  "triggerEvent",
                  "templateData",
                  "customSubject",
                  "customBody"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/notification-stats": {
      "post": {
        "summary": "Get notification statistics: delivery rates, top events, bounce rates.",
        "operationId": "notification_stats",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "days": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "days"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-list-batches": {
      "post": {
        "summary": "List AP payment batches with optional status filter.",
        "operationId": "payment_list_batches",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-get-batch": {
      "post": {
        "summary": "Get full details of a payment batch including individual invoice payments.",
        "operationId": "payment_get_batch",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "batchId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "batchId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-ready-invoices": {
      "post": {
        "summary": "List AP invoices that are approved and ready to be scheduled for payment. Sorted by due date (oldest first).",
        "operationId": "payment_ready_invoices",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-ar-list": {
      "post": {
        "summary": "List AR payments received from customers with optional status filter.",
        "operationId": "payment_ar_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-schedule": {
      "post": {
        "summary": "Schedule approved AP invoices for payment. Creates a payment batch grouped by payment method. Use payment_ready_invoices first to see what's available.",
        "operationId": "payment_schedule",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoiceIds": {
                    "type": "string"
                  },
                  "paymentMethod": {
                    "type": "string"
                  },
                  "batchDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoiceIds",
                  "paymentMethod",
                  "batchDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-approve-batch": {
      "post": {
        "summary": "Approve a draft payment batch for execution. Moves batch from 'draft' to 'approved'.",
        "operationId": "payment_approve_batch",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "batchId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "batchId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-confirm-batch": {
      "post": {
        "summary": "Confirm that a payment batch was executed by the bank. Moves to 'confirmed' status and updates invoices to PAID. Sandbox: simulates successful payment.",
        "operationId": "payment_confirm_batch",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "batchId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "batchId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-ar-record": {
      "post": {
        "summary": "Record a payment received from a customer. Payment starts as 'unmatched' until applied to invoices.",
        "operationId": "payment_ar_record",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customerId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "paymentMethod": {
                    "type": "string"
                  },
                  "receivedDate": {
                    "type": "string"
                  },
                  "referenceNumber": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "customerId",
                  "amount",
                  "paymentMethod",
                  "receivedDate",
                  "referenceNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-ar-apply": {
      "post": {
        "summary": "Apply an AR payment to one or more open invoices. Creates payment application records and updates invoice/payment status.",
        "operationId": "payment_ar_apply",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "paymentId": {
                    "type": "string"
                  },
                  "applications": {
                    "type": "string"
                  },
                  "invoiceId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "paymentId",
                  "applications",
                  "invoiceId",
                  "amount"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/payment-dashboard": {
      "post": {
        "summary": "Payment orchestration dashboard: AP payable summary, AR receivable summary, cash flow impact, and upcoming deadlines.",
        "operationId": "payment_dashboard",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-list": {
      "post": {
        "summary": "List available AI providers and their models. Shows which providers are configured for the company.",
        "operationId": "provider_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "includeModels": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "includeModels"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-get-usage": {
      "post": {
        "summary": "Get AI provider usage statistics for the current billing period.",
        "operationId": "provider_get_usage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "periodStart": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "periodStart"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-configure": {
      "post": {
        "summary": "Configure an AI provider for the company. Set API key, enable/disable, set default model. API keys are stored encrypted and never returned in full.",
        "operationId": "provider_configure",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "providerSlug": {
                    "type": "string"
                  },
                  "apiKey": {
                    "type": "string"
                  },
                  "isEnabled": {
                    "type": "boolean"
                  },
                  "defaultModel": {
                    "type": "string"
                  },
                  "maxTokensPerMonth": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "providerSlug",
                  "apiKey",
                  "isEnabled",
                  "defaultModel",
                  "maxTokensPerMonth"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-test-connection": {
      "post": {
        "summary": "Test the connection to an AI provider. Verifies the API key is valid by making a simple models list or chat request.",
        "operationId": "provider_test_connection",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "providerSlug": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "providerSlug"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-set-routing": {
      "post": {
        "summary": "Configure AI provider routing rules. Set which providers to use for each task type, in priority order. Earlier providers are tried first; later ones are fallbacks.",
        "operationId": "provider_set_routing",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "taskType": {
                    "type": "string"
                  },
                  "providerChain": {
                    "type": "string"
                  },
                  "modelOverride": {
                    "type": "string"
                  },
                  "maxRetries": {
                    "type": "number"
                  },
                  "timeoutMs": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "taskType",
                  "providerChain",
                  "modelOverride",
                  "maxRetries",
                  "timeoutMs"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/provider-chat": {
      "post": {
        "summary": "Send a chat completion request through LedgerBeaver's unified AI gateway. Automatically routes to the best available provider based on company routing rules. Falls back through the provider chain if the primary is unavailable.",
        "operationId": "provider_chat",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "messages": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "model": {
                    "type": "string"
                  },
                  "taskType": {
                    "type": "string"
                  },
                  "maxTokens": {
                    "type": "number"
                  },
                  "temperature": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "messages",
                  "role",
                  "content",
                  "model",
                  "taskType",
                  "maxTokens",
                  "temperature"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-list-accounts": {
      "post": {
        "summary": "List bank accounts on file for the company.",
        "operationId": "recon_list_accounts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-list-transactions": {
      "post": {
        "summary": "List bank transactions with optional filters. Defaults to unreconciled, most recent first.",
        "operationId": "recon_list_transactions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "bankAccountId": {
                    "type": "string"
                  },
                  "unreconciledOnly": {
                    "type": "boolean"
                  },
                  "limit": {
                    "type": "number"
                  },
                  "fromDate": {
                    "type": "string"
                  },
                  "toDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "bankAccountId",
                  "unreconciledOnly",
                  "limit",
                  "fromDate",
                  "toDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-list-prior": {
      "post": {
        "summary": "List prior completed reconciliations for audit/reference.",
        "operationId": "recon_list_prior",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "bankAccountId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "bankAccountId",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-import-transactions": {
      "post": {
        "summary": "Import bank statement transactions (CSV data submitted as structured JSON). AI Agent can parse CSV and submit.",
        "operationId": "recon_import_transactions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "bankAccountId": {
                    "type": "string"
                  },
                  "transactions": {
                    "type": "string"
                  },
                  "transaction_date": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "running_balance": {
                    "type": "number"
                  },
                  "reference": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "check_number": {
                    "type": "string"
                  },
                  "importBatch": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "bankAccountId",
                  "transactions",
                  "transaction_date",
                  "description",
                  "amount",
                  "running_balance",
                  "reference",
                  "category",
                  "check_number",
                  "importBatch"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-start": {
      "post": {
        "summary": "Start a new bank reconciliation for a period.",
        "operationId": "recon_start",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "bankAccountId": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  },
                  "glBalance": {
                    "type": "number"
                  },
                  "bankBalance": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "bankAccountId",
                  "period",
                  "glBalance",
                  "bankBalance"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-run-matching": {
      "post": {
        "summary": "Auto-match bank transactions to GL journal entries. Returns match suggestions.",
        "operationId": "recon_run_matching",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "reconciliationId": {
                    "type": "string"
                  },
                  "maxConfidenceThreshold": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "reconciliationId",
                  "maxConfidenceThreshold"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-mark-cleared": {
      "post": {
        "summary": "Manually mark a bank transaction as cleared and link it to a GL entry or categorize it.",
        "operationId": "recon_mark_cleared",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "transactionId": {
                    "type": "string"
                  },
                  "reconciliationId": {
                    "type": "string"
                  },
                  "itemType": {
                    "type": "string"
                  },
                  "glEntryId": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "transactionId",
                  "reconciliationId",
                  "itemType",
                  "glEntryId",
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-finalize": {
      "post": {
        "summary": "Finalize a bank reconciliation. Calculates difference and closes the period.",
        "operationId": "recon_finalize",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "reconciliationId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "reconciliationId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/recon-get-report": {
      "post": {
        "summary": "Get the current reconciliation status report with all details.",
        "operationId": "recon_get_report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "reconciliationId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "reconciliationId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-audit-trail": {
      "post": {
        "summary": "Query cross-module audit trails (AP/AR/GL/Finance) with filters for date range, action type, and performer.",
        "operationId": "safety_audit_trail",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "module": {
                    "type": "string"
                  },
                  "action": {
                    "type": "string"
                  },
                  "timeRange": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "module",
                  "action",
                  "timeRange",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-anomalies": {
      "post": {
        "summary": "Detect anomalies in financial data: duplicate invoices, unusually large transactions, stale approvals, unposted entries, unmatched POs.",
        "operationId": "safety_anomalies",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "timeRange": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "timeRange"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-approval-status": {
      "post": {
        "summary": "Check the status of all pending approvals and queued actions across the system.",
        "operationId": "safety_approval_status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-admin-diagnostics": {
      "post": {
        "summary": "Run an admin diagnostic snapshot for stale workflows, pending approvals, payment execution mode, and demo/prod safety. Read-only operational support tool.",
        "operationId": "safety_admin_diagnostics",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "staleHours": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "staleHours"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-beta-readiness": {
      "post": {
        "summary": "Evaluate LedgerBeaver demonstration, customer-onboarding, and general-availability readiness from current controls and rollout prerequisites. Read-only. The legacy tool name is retained for compatibility.",
        "operationId": "safety_beta_readiness",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domainConfigured": {
                    "type": "boolean"
                  },
                  "oauthConfigured": {
                    "type": "boolean"
                  },
                  "inboundEmailConfigured": {
                    "type": "boolean"
                  },
                  "multiTenantHardened": {
                    "type": "boolean"
                  },
                  "diagnosticsOverall": {
                    "type": "string"
                  },
                  "buildPassing": {
                    "type": "boolean"
                  },
                  "focusedTestsPassing": {
                    "type": "boolean"
                  },
                  "hasDemoData": {
                    "type": "boolean"
                  },
                  "hasLaunchScript": {
                    "type": "boolean"
                  },
                  "hasIncidentRunbook": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "domainConfigured",
                  "oauthConfigured",
                  "inboundEmailConfigured",
                  "multiTenantHardened",
                  "diagnosticsOverall",
                  "buildPassing",
                  "focusedTestsPassing",
                  "hasDemoData",
                  "hasLaunchScript",
                  "hasIncidentRunbook"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/safety-guidelines": {
      "post": {
        "summary": "Return the AI agent safety guidelines — what the AI can and cannot do within LedgerBeaver. Call this before executing any write operations.",
        "operationId": "safety_guidelines",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-create-payment-link": {
      "post": {
        "summary": "Create a Stripe-hosted payment link for an AR invoice. Share the URL with the customer so they can pay by card/bank.",
        "operationId": "stripe_create_payment_link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "invoiceId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "customerName": {
                    "type": "string"
                  },
                  "customerEmail": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "invoiceId",
                  "amount",
                  "customerName",
                  "customerEmail"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-pay-vendor": {
      "post": {
        "summary": "Pay a vendor via Stripe Connect transfer. The vendor must be onboarded with a Stripe connected account.",
        "operationId": "stripe_pay_vendor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "apInvoiceId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "vendorStripeAccountId": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "apInvoiceId",
                  "amount",
                  "vendorStripeAccountId",
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-create-subscription-checkout": {
      "post": {
        "summary": "Create a Stripe Checkout session for subscription. The user clicks the returned URL to enter payment details and subscribe.",
        "operationId": "stripe_create_subscription_checkout",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "customerName": {
                    "type": "string"
                  },
                  "customerEmail": {
                    "type": "string"
                  },
                  "tier": {
                    "type": "string"
                  },
                  "successUrl": {
                    "type": "string"
                  },
                  "cancelUrl": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "customerName",
                  "customerEmail",
                  "tier",
                  "successUrl",
                  "cancelUrl"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-get-subscription": {
      "post": {
        "summary": "Check the current subscription status for a company.",
        "operationId": "stripe_get_subscription",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-cancel-subscription": {
      "post": {
        "summary": "Cancel a company's Stripe subscription. Their access will continue until the end of the current billing period.",
        "operationId": "stripe_cancel_subscription",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/stripe-check-payment-status": {
      "post": {
        "summary": "Check whether a customer has paid a Stripe payment link, or the status of a vendor payout.",
        "operationId": "stripe_check_payment_status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "paymentId": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  }
                },
                "required": [
                  "paymentId",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/tax-1099-summary": {
      "post": {
        "summary": "Generate 1099 report — vendor payments eligible for 1099-NEC/MISC filing.",
        "operationId": "tax_1099_summary",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "taxYear": {
                    "type": "string"
                  },
                  "threshold": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "taxYear",
                  "threshold"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/tax-1099-export": {
      "post": {
        "summary": "Export 1099 data as CSV for IRS IRIS, Tax1099.com, or track1099 upload.",
        "operationId": "tax_1099_export",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "taxYear": {
                    "type": "string"
                  },
                  "threshold": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "taxYear",
                  "threshold"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/tax-sales-summary": {
      "post": {
        "summary": "Generate sales tax summary — taxable AR invoices for the period.",
        "operationId": "tax_sales_summary",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "endDate": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "startDate",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/tax-pnl-for-accountant": {
      "post": {
        "summary": "Generate a tax-ready P&L categorized for Schedule C or corporate tax filing.",
        "operationId": "tax_pnl_for_accountant",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "taxYear": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "taxYear"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-list-profiles": {
      "post": {
        "summary": "List all AI agent treasury profiles for the company. Shows spending limits, policies, and card counts.",
        "operationId": "treasury_list_profiles",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-get-profile": {
      "post": {
        "summary": "Get full details of a treasury profile including active policies and recent activity.",
        "operationId": "treasury_get_profile",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "profileId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-create-profile": {
      "post": {
        "summary": "Create a new treasury profile for an AI agent. Requires approval. Sets spending limits, mode, and vendor restrictions.",
        "operationId": "treasury_create_profile",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "agentId": {
                    "type": "string"
                  },
                  "spendingMode": {
                    "type": "string"
                  },
                  "dailyLimit": {
                    "type": "number"
                  },
                  "monthlyLimit": {
                    "type": "number"
                  },
                  "perTxnLimit": {
                    "type": "number"
                  },
                  "allowedCategories": {
                    "type": "string"
                  },
                  "allowedVendors": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "name",
                  "agentId",
                  "spendingMode",
                  "dailyLimit",
                  "monthlyLimit",
                  "perTxnLimit",
                  "allowedCategories",
                  "allowedVendors",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-list-intents": {
      "post": {
        "summary": "List payment intents for a profile with optional status filter.",
        "operationId": "treasury_list_intents",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "profileId",
                  "status",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-create-intent": {
      "post": {
        "summary": "Create a payment intent from an AI agent. Routes through policy engine, then to approval. Agent must have an active treasury profile.",
        "operationId": "treasury_create_intent",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  },
                  "intentType": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "apInvoiceId": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "description": {
                    "type": "string"
                  },
                  "paymentMethod": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "profileId",
                  "intentType",
                  "vendorId",
                  "apInvoiceId",
                  "amount",
                  "description",
                  "paymentMethod"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-list-cards": {
      "post": {
        "summary": "List virtual cards for a profile or the whole company.",
        "operationId": "treasury_list_cards",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "profileId",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-create-virtual-card": {
      "post": {
        "summary": "Create a virtual card for an AI agent's treasury profile. Card inherits profile limits but can override. Requires approval. Provider integration (Stripe/Marqeta) simulated in sandbox.",
        "operationId": "treasury_create_virtual_card",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "spendLimit": {
                    "type": "number"
                  },
                  "dailyLimit": {
                    "type": "number"
                  },
                  "monthlyLimit": {
                    "type": "number"
                  },
                  "singleUse": {
                    "type": "boolean"
                  },
                  "merchantCategories": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "profileId",
                  "name",
                  "spendLimit",
                  "dailyLimit",
                  "monthlyLimit",
                  "singleUse",
                  "merchantCategories",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-freeze-card": {
      "post": {
        "summary": "Freeze a virtual card immediately. Agent cannot use a frozen card. Can be unfrozen later.",
        "operationId": "treasury_freeze_card",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "cardId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "cardId",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-get-audit-log": {
      "post": {
        "summary": "Get the audit trail for treasury activity: profile changes, policy evaluations, payment intents, card actions.",
        "operationId": "treasury_get_audit_log",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "profileId": {
                    "type": "string"
                  },
                  "eventType": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "profileId",
                  "eventType",
                  "severity",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/treasury-dashboard": {
      "post": {
        "summary": "Agent Treasury dashboard: profiles, active cards, pending intents, recent activity, and policy status.",
        "operationId": "treasury_dashboard",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-portal-poll": {
      "post": {
        "summary": "Auto-poll for new vendor portal submissions. Checks for status='submitted' entries, creates AP invoices, marks them processing. Run this every 1-2 minutes during demo.",
        "operationId": "vendor_portal_poll",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "autoApprove": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "autoApprove"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-portal-poll-start": {
      "post": {
        "summary": "Start continuous auto-polling for vendor submissions (every 60s, max 10 cycles). Perfect for demos — vendors submit and AI processes automatically.",
        "operationId": "vendor_portal_poll_start",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "cycles": {
                    "type": "number"
                  },
                  "autoApprove": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "cycles",
                  "autoApprove"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-list": {
      "post": {
        "summary": "List vendors for a company with optional status filter.",
        "operationId": "vendor_list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "onboardingStatus": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "status",
                  "onboardingStatus",
                  "search",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-get": {
      "post": {
        "summary": "Get complete vendor details including banking status and recent audit entries.",
        "operationId": "vendor_get",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "includeAuditLog": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "includeAuditLog"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-get-audit-log": {
      "post": {
        "summary": "Get the audit trail for a vendor (banking changes, status changes, etc.)",
        "operationId": "vendor_get_audit_log",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "limit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-register": {
      "post": {
        "summary": "Register a new vendor with complete information. Returns an audit log entry. Banking info requires separate verification.",
        "operationId": "vendor_register",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "contactName": {
                    "type": "string"
                  },
                  "contactTitle": {
                    "type": "string"
                  },
                  "addressLine1": {
                    "type": "string"
                  },
                  "addressLine2": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "zip": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  },
                  "taxId": {
                    "type": "string"
                  },
                  "paymentTerms": {
                    "type": "string"
                  },
                  "paymentMethod": {
                    "type": "string"
                  },
                  "bankName": {
                    "type": "string"
                  },
                  "bankRouting": {
                    "type": "string"
                  },
                  "bankAccount": {
                    "type": "string"
                  },
                  "bankAccountType": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "name",
                  "email",
                  "phone",
                  "contactName",
                  "contactTitle",
                  "addressLine1",
                  "addressLine2",
                  "city",
                  "state",
                  "zip",
                  "country",
                  "website",
                  "taxId",
                  "paymentTerms",
                  "paymentMethod",
                  "bankName",
                  "bankRouting",
                  "bankAccount",
                  "bankAccountType",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-update-info": {
      "post": {
        "summary": "Update vendor contact details, address, payment terms, or general info. Does NOT include banking updates.",
        "operationId": "vendor_update_info",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "contactName": {
                    "type": "string"
                  },
                  "contactTitle": {
                    "type": "string"
                  },
                  "addressLine1": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "zip": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  },
                  "paymentTerms": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "name",
                  "email",
                  "phone",
                  "contactName",
                  "contactTitle",
                  "addressLine1",
                  "city",
                  "state",
                  "zip",
                  "website",
                  "paymentTerms",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-update-banking": {
      "post": {
        "summary": "Update vendor bank account or routing information. HIGH RISK - triggers re-verification requirement. All banking changes are logged in the audit trail.",
        "operationId": "vendor_update_banking",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "bankName": {
                    "type": "string"
                  },
                  "bankRouting": {
                    "type": "string"
                  },
                  "bankAccount": {
                    "type": "string"
                  },
                  "bankAccountType": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "bankName",
                  "bankRouting",
                  "bankAccount",
                  "bankAccountType"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-suspend": {
      "post": {
        "summary": "Suspend or deactivate a vendor. Suspended vendors cannot receive payments.",
        "operationId": "vendor_suspend",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "reason"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-bank-verify-initiate": {
      "post": {
        "summary": "Initiate Plaid micro-deposit verification for a vendor's bank account. Sends two small deposits that must be confirmed within 7 days.",
        "operationId": "vendor_bank_verify_initiate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "plaidItemId": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "plaidItemId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-bank-verify-confirm": {
      "post": {
        "summary": "Confirm the two micro-deposit amounts received at the vendor's bank account. On success, vendor bank account is verified and onboarding is complete.",
        "operationId": "vendor_bank_verify_confirm",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "verificationId": {
                    "type": "string"
                  },
                  "deposit1": {
                    "type": "number"
                  },
                  "deposit2": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "verificationId",
                  "deposit1",
                  "deposit2"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-portal-invite": {
      "post": {
        "summary": "Invite a vendor to the LedgerBeaver self-service portal. Sends a magic link email so the vendor can submit invoices and track status.",
        "operationId": "vendor_portal_invite",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "vendorEmail": {
                    "type": "string"
                  },
                  "sendEmail": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "vendorEmail",
                  "sendEmail"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/vendor-notify-status": {
      "post": {
        "summary": "Send a status update notification to a vendor about their invoice (approved, scheduled, paid, rejected).",
        "operationId": "vendor_notify_status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "invoiceId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "invoiceId",
                  "status",
                  "notes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/submit-vendor-invoice": {
      "post": {
        "summary": "Submit a vendor invoice with line items. Creates the invoice and line items in a single atomic transaction.",
        "operationId": "submit_vendor_invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "vendorId": {
                    "type": "string"
                  },
                  "invoiceNumber": {
                    "type": "string"
                  },
                  "invoiceDate": {
                    "type": "string"
                  },
                  "dueDate": {
                    "type": "string"
                  },
                  "totalAmount": {
                    "type": "number"
                  },
                  "description": {
                    "type": "string"
                  },
                  "lineItems": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "rate": {
                    "type": "number"
                  }
                },
                "required": [
                  "companyId",
                  "vendorId",
                  "invoiceNumber",
                  "invoiceDate",
                  "dueDate",
                  "totalAmount",
                  "description",
                  "lineItems",
                  "description",
                  "quantity",
                  "rate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  }
}
