create_invoice
Generate professional invoices in FreshBooks by specifying customer details and line items with quantities and costs.
Instructions
Create a new invoice. Lines format: [{"name": "Service", "description": "...", "qty": 1, "unit_cost": {"amount": "100.00", "code": "USD"}}]
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer_id | Yes | ||
| lines | Yes | ||
| due_offset_days | No | ||
| currency_code | No | USD | |
| notes | No | ||
| po_number | No |
Implementation Reference
- src/mcp_freshbooks/server.py:148-170 (handler)The 'create_invoice' handler function, responsible for creating a new invoice in FreshBooks using the accounting client.
async def create_invoice( customer_id: int, lines: list[dict], due_offset_days: int = 30, currency_code: str = "USD", notes: str = "", po_number: str = "", ) -> str: """Create a new invoice. Lines format: [{"name": "Service", "description": "...", "qty": 1, "unit_cost": {"amount": "100.00", "code": "USD"}}]""" data = { "customerid": customer_id, "create_date": _today(), "due_offset_days": due_offset_days, "currency_code": currency_code, "lines": lines, } if notes: data["notes"] = notes if po_number: data["po_number"] = po_number result = await client.accounting_create("invoices/invoices", "invoice", data) inv = result.get("invoice", result) return f"Invoice #{inv.get('invoice_number', '?')} created (ID: {inv.get('id')}). Amount: ${inv.get('amount', {}).get('amount', '0')}"