beel_create_invoice_derivation
Duplicate an existing invoice into a new draft, copying key details while resetting fiscal data. Validates series compatibility to prevent errors.
Instructions
Creates a draft invoice derived from an existing invoice of this company, named in
from_invoice_id with mode: DUPLICATE. Recipient, lines, payment method, series and
observations are copied; number, status, dates, VeriFactu data and PDF are reset. The
source invoice is not modified.
The series — the one sent in series_id or the source's, inherited — is validated against
the type of the copy, which is not always the source's: the copy of a CORRECTIVE is born
STANDARD. An incompatible series fails with 422 SERIES_INCOMPATIBLE_DOC_TYPE.
Endpoint: POST /v1/companies/{company_id}/invoices/derivations
⚠️ 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)
For the exhaustive rules and worked examples, call beel_docs_search.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| 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. | |
| 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. |