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:

  • invoice generation;
  • credit-memo generation;
  • invoice mass actions;
  • credit-memo generation 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.

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.