Skip to main content
Glama
BeeL MCP server

BeeL MCP server

Official
by beel-es

beel_create_invoices_bulk

Idempotent

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 400 or 422 with nothing created:

    • an empty invoices array 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_tax or total_including_tax);

    • an external_ref missing or repeated within the request;

    • a type other than STANDARD or SIMPLIFIED, the types whose external_ref is unique per company;

    • options.issue_directly: true.

    error.details names 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 back FAILED with the same error.code that POST /v1/companies/{company_id}/invoices answers for it, and the others are still created. The answer is 200 even when no invoice could be created.

  • external_ref is 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 back EXISTING with its invoice_id and status, 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 as EXISTING.

  • Recipient by NIF: unlike the single creation, an inline recipient with a nif on a STANDARD invoice 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 FAILED with the code the customer creation answers: NIF_NOT_IN_CENSUS (the NIF does not exist in the census or, for a natural person, legal_name does not match it; for a legal entity the name is not checked), NIF_INVALID_FORMAT or NIF_INVALID_CONTROL_DIGIT. A recipient without legal_name or address is 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_name or address differ from the ones sent: the invoice is not created and comes back FAILED with error.code CUSTOMER_DATA_DIFFERS.

    • A customer with that NIF that differs only in email, phone or trade_name: the invoice is created with the stored customer and the entry carries a CUSTOMER_CONTACT_DIFFERS warning.

    recipient.customer_id and an inline recipient with alternative_id work as in the single creation. A SIMPLIFIED invoice whose recipient carries a nif comes back FAILED with 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 both invoices:write and customers:write, even when every invoice uses recipient.customer_id; without either one the request answers 403 INSUFFICIENT_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 FAILED with COMPANY_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-Key the stored response is replayed. A request sent again with a new key never duplicates an invoice: the drafts already created come back EXISTING. 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

NameRequiredDescriptionDefault
bodyYes
company_idYesUnique 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_keyNoOptional 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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.12.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Far beyond the annotations, it discloses the request-first-then-per-invoice validation model, partial success reporting in `results`, concrete failure codes (NIF_NOT_IN_CENSUS, CUSTOMER_DATA_DIFFERS, COMPANY_ACCESS_REVOKED), the required scopes ('invoices:write and customers:write' else 403), the 2 MB body limit, and the idempotency/resume semantics that match the idempotentHint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Heavily front-loaded with bold section headers and tight bullets, so it scans well despite its length. Some repetition exists (the `external_ref` uniqueness/race rule is restated in the retries bullet) and it defers to an external 'Request body size' section, which slightly dilutes self-containment.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter tool wrapping a 100-item nested array, the description covers validation, partial-failure reporting, scope prerequisites, mid-run access revocation, size limits and retry/resume behavior. With no output schema, it also describes the `results`/`EXISTING` response shape enough to interpret outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Given 67% schema coverage, the description adds bulk-specific meaning the nested schema cannot: `external_ref` is required and unique within the request (else EXISTING/race behavior), `type` is limited to STANDARD or SIMPLIFIED, `options.issue_directly: true` is rejected, and inline `recipient.nif` resolution/creation differs from single creation. These are semantic constraints not expressed in the schema's conditional requirements.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence states a precise verb, resource, quantity cap (up to 100) and resulting state (drafts), and immediately contrasts the outcome with the two ways to issue them ('one by one or with POST /invoices/batches'). An agent can distinguish this from beel_create_invoice and other siblings without reading the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It names the alternative issuance paths explicitly and the condition ('Nothing is issued or numbered') under which one of them must be used afterwards. It also routes the agent to prerequisites (beel_rules_list and specific guardrails resources) for fiscal rules, line pricing and NIF validation, leaving little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools