On this page
  1. Authentication and permissions
  2. Generate one document
  3. Generate a batch
  4. The force parameter
  5. Include document content in Magento sales APIs
  6. Checkout extension attributes
  7. Security and data handling
  8. What the API does not provide
  9. Related

REST API

The module adds authenticated generation endpoints and can enrich Magento's invoice and credit-memo repository responses with document contents. Content enrichment is disabled by default because invoice XML and PDF can be large and sensitive.

Authentication and permissions

Use normal Magento REST authentication. The integration or admin token needs the specific E-Invoice ACL resource for the operation:

  • MageB2B_EInvoice::invoice_generate for the single-invoice route;
  • MageB2B_EInvoice::creditmemo_generate for the single-credit-memo route;
  • MageB2B_EInvoice::invoice_mass_actions for the bulk invoice route;
  • MageB2B_EInvoice::creditmemo_mass_actions for the bulk credit-memo route.

Do not expose these routes to anonymous storefront clients.

Generate one document

POST /rest/V1/einvoice/invoice/{invoiceId}/generate
POST /rest/V1/einvoice/creditmemo/{creditmemoId}/generate

invoiceId and creditmemoId are numeric Magento entity IDs, not increment IDs printed on the document.

The result contains:

{
  "success": true,
  "entity_id": 42,
  "entity_type": "invoice",
  "status": "generated",
  "format": "zugferd",
  "message": "E-Invoice generated successfully",
  "skipped": false
}

Exact Magento REST serialization may wrap interface data according to your platform version, but these are the service-contract fields.

Generate a batch

POST /rest/V1/einvoice/invoices/generate
Content-Type: application/json

{
  "invoiceIds": [42, 43, 44]
}

For credit memos:

POST /rest/V1/einvoice/creditmemos/generate
Content-Type: application/json

{
  "creditmemoIds": [17, 18]
}

The bulk result returns total_count, success_count, error_count, skipped_count and one generation result per entity. Inspect individual results even when the request itself returns successfully.

The force parameter

All generation endpoints accept force (default false). Without it, a document already marked generated is returned as skipped, and an error document is reported with "Force is required to retry a failed E-Invoice generation." With "force": true, both cases regenerate and overwrite the stored document.

Use force only deliberately — regeneration is an explicit operational decision, not a default for integrations.

Include document content in Magento sales APIs

Enable these separately per store view:

  • Include E-Invoice in Invoice API
  • Include E-Invoice in Credit Memo API

Then normal repository reads can include:

GET /rest/V1/invoices/{invoiceId}
GET /rest/V1/creditmemos/{creditmemoId}
{
  "extension_attributes": {
    "einvoice_xml": "<?xml version=\"1.0\" ...",
    "einvoice_pdf": "JVBERi0xLjcK..."
  }
}
  • einvoice_xml is the XML string.
  • einvoice_pdf is base64-encoded and is null for XML-only formats.
  • both are null when no document is available.
  • with on-demand storage, reading the repository can trigger document generation.

That last point matters for performance and side effects. Do not enable API enrichment on broad invoice-list integrations without measuring payload size and generation behavior.

Checkout extension attributes

Two additional extension attributes are declared for headless or custom-checkout integrations:

Attribute Declared on Written through Effect
einvoice_buyer_reference Magento\Quote\Api\Data\PaymentInterface POST /V1/carts/{cartId}/payment-information (and the carts/mine / guest-carts variants) as paymentMethod.extension_attributes.einvoice_buyer_reference Copied onto sales_order.einvoice_buyer_reference at order placement; used as Buyer Reference / Leitweg-ID (BT-10) and, with order-reference detection, marks the order as B2G
peppol_endpoint_id / peppol_endpoint_scheme Magento\Sales\Api\Data\OrderInterface No module write path — set by custom code on the order Read first by the PEPPOL BIS formatter as the buyer endpoint; see Buyer endpoint resolution

The module stores einvoice_buyer_reference in real quote/sales_order columns. The PEPPOL endpoint attributes are a read-time integration point: the module declares them but keeps no storage for them, so an integration must populate the order's extension attributes before generation.

Security and data handling

E-invoices contain company, address, tax, payment and purchase information. Limit token permissions, avoid logging response bodies, and do not cache enriched API responses in a public layer.

What the API does not provide

  • no GraphQL fields in this module;
  • no PEPPOL access-point transmission;
  • no government-portal upload;
  • no delivery-status callback model.

Display preferences

Adjust how this website is displayed. Changes apply immediately.

Text size
Text spacing
Reading aids

Follows the pointer. Move it with Alt + Up/Down outside input fields. Hidden while a dialog is open.

Uses the voices provided by your browser, which may use an online service. Reading starts only when you press Read aloud.

Your choices are saved in this browser for this website.