Create draft invoice
create_invoiceCreate a new draft invoice. Review it with the user, then emit it with finalize_invoice (or from the dashboard). Tax rates supported: 21, 10, 4, 0, per invoice, or per line when one invoice mixes rates. IRPF retention: 0, 7, 15, 19. If you may retry this call, pass external_id: the same id twice is refused instead of billing the customer a second time. Returns the new draft's id and total; a repeated external_id instead returns the id and number of the invoice already created for it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | ||
| notes | No | ||
| tax_rate | No | VAT % for the whole invoice; a line may override it with its own tax_rate | |
| referencia | No | Short human reference shown on the PDF and searchable in the invoice list: the customer's purchase order number, a project or a domain name. NOT an idempotency key. | |
| customer_id | Yes | ||
| external_id | No | Your own id for this invoice, unique per account. Send it again for the same job and the call is rejected with a 409 naming the invoice that already exists, so a retry cannot create a duplicate. Never reuse one id for two different invoices. | |
| numero_pedido | No | Purchase order / commitment number the PUBLIC customer requires (nº de pedido, código de compromiso, disposición). Printed on the PDF and written as ReceiverTransactionReference in every Facturae line; without it administrations like universities cannot route the e-invoice. | |
| product_group | No | Optional product group (grupo de producto), one of the names returned by get_product_groups. Unknown names are rejected. Leave it out to use the customer's saved default, if any. | |
| retention_rate | No |