beel_create_invoices_bulk
Creates up to 100 draft invoices in one call, validating the whole batch first and reporting each invoice's result separately. Use it for bulk billing with unique external references.
Instructions
Creates up to 100 invoices of this company as drafts in a single call. Nothing is issued
or numbered: issue the drafts afterwards, one by one or with
POST /v1/companies/{company_id}/invoices/batches.
Request first, then each invoice: the request is checked as a whole before anything is created, and any of these rejects it with
400or422with nothing created:an empty
invoicesarray or more than 100;an invoice that breaks its schema (a required field missing, a value of the wrong type or format, a value outside its declared limits, a malformed
phone);an invoice whose fields cannot be read together, which the single creation also rejects before applying any invoicing rule (for instance a line without exactly one of
unit_price,total_excluding_taxortotal_including_tax);an
external_refmissing or repeated within the request;a
typeother thanSTANDARDorSIMPLIFIED, the types whoseexternal_refis unique per company;options.issue_directly: true.
error.detailsnames the offending field with its index (invoices[3].external_ref).Partial operation: once the request is accepted, each invoice is created on its own and reported in
results, in the order it was sent. One that the invoicing rules reject comes backFAILEDwith the sameerror.codethatPOST /v1/companies/{company_id}/invoicesanswers for it, and the others are still created. The answer is200even when no invoice could be created.external_refis required in every invoice and must be unique within the request. When the company already has a standard or simplified invoice with that reference, in any status, the entry comes backEXISTINGwith itsinvoice_idandstatus, and that invoice is not modified. This also holds when two requests race for the same reference: it is created once and the other request reports it asEXISTING.Recipient by NIF: unlike the single creation, an inline
recipientwith anifon aSTANDARDinvoice is resolved against the customers of this company, and the customer is never modified:No customer with that NIF: it is created once per distinct NIF of the request, with exactly the data sent, and the invoice uses it. The NIF is checked against the AEAT census whether or not the company uses VeriFactu, as when creating a customer. When the customer cannot be created, every invoice with that NIF comes back
FAILEDwith the code the customer creation answers:NIF_NOT_IN_CENSUS(the NIF does not exist in the census or, for a natural person,legal_namedoes not match it; for a legal entity the name is not checked),NIF_INVALID_FORMATorNIF_INVALID_CONTROL_DIGIT. A recipient withoutlegal_nameoraddressis rejected first by the invoicing rules, with the codes of the single creation (RECIPIENT_FISCAL_NAME_REQUIRED,RECIPIENT_ADDRESS_REQUIRED).A customer with that NIF whose
legal_nameoraddressdiffer from the ones sent: the invoice is not created and comes backFAILEDwitherror.codeCUSTOMER_DATA_DIFFERS.A customer with that NIF that differs only in
email,phoneortrade_name: the invoice is created with the stored customer and the entry carries aCUSTOMER_CONTACT_DIFFERSwarning.
recipient.customer_idand an inline recipient withalternative_idwork as in the single creation. ASIMPLIFIEDinvoice whose recipient carries anifcomes backFAILEDwith the same code the single creation answers.Same rules as the single creation: validation, access to the company and environment are those of
POST /v1/companies/{company_id}/invoices. The credential needs bothinvoices:writeandcustomers:write, even when every invoice usesrecipient.customer_id; without either one the request answers403INSUFFICIENT_SCOPE.Access withdrawn midway: if your access to the company is withdrawn while the request runs, the drafts already created stay created and the remaining invoices come back
FAILEDwithCOMPANY_ACCESS_REVOKED.Size: besides the 100 invoices, the body is bound by the 2 MB limit described under Request body size; split larger sets into several requests.
Retries: with the same
Idempotency-Keythe stored response is replayed. A request sent again with a new key never duplicates an invoice: the drafts already created come backEXISTING. That is the way to resume after a server error, whose answer the same key would replay.
BeeL API endpoint: POST /v1/companies/{company_id}/invoices/bulk (reference: https://docs.beel.es)
⚠️ Read before calling:
Fiscal rules, domains simplified, contents, taxes: beel_rules_list with domain, or resource beel://guardrails/.
How a line states its price, and which field combinations are rejected. (resource: beel://guardrails/invoice-lines)
Why a name that does not match the census makes an invoice unsubmittable. (resource: beel://guardrails/nif-validation)
The status names, the proforma lifecycle, and which tool performs each operation. (resource: beel://guardrails/invoice-state-machine)
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"company_id": "<company_id>",
"body": "<body>"
},
"name": "beel_create_invoices_bulk"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| company_id | Yes | Unique identifier (UUID) of the company the operation acts on — its identifier, not its NIF. 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 company you do not reach answers `403`, and so does a company that does not exist, so the existence of a company 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. |