Create invoice
Create a sales invoice for a contact as a draft or an open invoice.
MCP tool alegra_write → create_invoice
Creates a sales invoice with one or more lines and returns its ID, number, totals and status. With status draft nothing is issued and the invoice can still be edited in Alegra. With status open the invoice is saved as open, and with generate_stamp true Alegra also tries to stamp it with your tax authority; if stamping fails, the invoice stays a draft and the error is returned. The invoice is not emailed: use email_invoice for that. If you give no number_template_id, Alegra uses your preferred numbering. By default you confirm each call; you can switch that off for this tool.
Parameters
| Name | Type | Description |
|---|---|---|
| contact_id string required | string | Client contact ID from list_contacts. |
| items array required | array | Lines of the invoice. Each line has item_id from list_items, quantity and price, plus optional discount in percent without the % sign and tax_ids. |
| date date required | date | Invoice date, YYYY-MM-DD. |
| due_date date required | date | Due date, YYYY-MM-DD. |
| status enum | enum | draft or open. Default: draft when nothing is paid. |
| generate_stamp boolean | boolean | true asks Alegra to stamp the invoice with your tax authority where your country requires it. Default: false. |
| number_template_id string | string | Numbering to use. Default: your preferred numbering. |
tools/call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "alegra_write",
"arguments": {
"operation": "create_invoice",
"arguments": {
"contact_id": "20",
"items": [
{
"item_id": "12",
"quantity": 2,
"price": 400,
"tax_ids": [
"3"
]
},
{
"item_id": "15",
"quantity": 1,
"price": 150,
"tax_ids": [
"3"
]
}
],
"date": "2026-10-20",
"due_date": "2026-11-19",
"status": "draft"
}
}
}
} Example response
{
"content": [
{
"type": "text",
"text": "{ ... same JSON as structuredContent ... }"
}
],
"structuredContent": {
"invoice_id": "1042",
"number": "FV-0042",
"status": "draft",
"date": "2026-10-20",
"due_date": "2026-11-19",
"currency": "USD",
"client": {
"contact_id": "20",
"name": "Northwind Studio"
},
"items": [
{
"item_id": "12",
"quantity": 2,
"price": 400,
"line_total": 800
},
{
"item_id": "15",
"quantity": 1,
"price": 150,
"line_total": 150
}
],
"subtotal": 950,
"tax_total": 180.5,
"total": 1130.5,
"balance": 1130.5
},
"isError": false
}