beel_issue_invoice
Finalize a draft invoice by assigning its definitive number and making it immutable, then submit it for PDF and VeriFactu processing.
Instructions
Finalizes a draft invoice of this company: assigns its definitive number from the configured series and makes it immutable. Irreversible — an issued invoice is corrected with a corrective invoice or voided, never edited.
PDF and VeriFactu submission are asynchronous: a 200 means accepted for submission,
never registered with AEAT.
Endpoint: POST /v1/companies/{company_id}/invoices/{invoice_id}/issue
⚠️ Fiscal guardrails — read before calling:
When an invoice can still be changed, and what to do once it cannot. (resource: beel://guardrails/invoice-state-machine)
Why an issued invoice may never reach AEAT, and how to tell before issuing. (resource: beel://guardrails/verifactu-gates)
For the exhaustive rules and worked examples, call beel_docs_search.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company_id | Yes | NIF (company) the operation acts on. It is the only source of context: the account that owns it is derived from it, and the `BeeL-Active-Company` header plays no part. A NIF you do not reach answers `403`, and so does a NIF that does not exist, so the existence of a NIF in another account is never disclosed. | |
| invoice_id | Yes | Invoice ID | |
| wait_for_pdf | No | If `true`, waits for PDF generation and returns the URL in the response. Adds ~1-2s of latency but guarantees the PDF is immediately available. | |
| idempotency_key | No | Optional idempotency key for this operation. Omit it and one is derived from the request itself, which makes a blind retry safe but also collapses a SECOND, deliberately identical operation into the first for 24 hours. Set it — to an order id, or anything unique per intended operation — whenever you mean to create something that may look identical to what you just created. | |
| attach_source_invoices | No | Only applies when the invoice has automatic email sending enabled. If `true`, the email sent after issuing also attaches a ZIP (`suplidos_<invoice-number>.zip`) with the PDFs of the source invoices referenced by the invoice's SUPLIDO consolidation lines. Access to sources owned by managed accounts is re-checked with the same rules as issuing, and the request fails synchronously with an actionable error — never a partial ZIP — if the invoice has no consolidation sources (`ATTACH_SOURCE_INVOICES_NO_SOURCES`), a source is not reachable (`ATTACH_SOURCE_INVOICE_UNAVAILABLE`) or a source has no generated PDF (`ATTACH_SOURCE_PDF_MISSING`). |