Start now for free
14 days free trial - no credit card needed
Hisab
Pricing
Sales: +212 649 22 43 64
Start now for free

14 days free trial - no credit card needed

Login
E-Invoicing
December 9, 202512 min read

What is UBL 2.1? The Complete Guide to Universal Business Language for E-Invoicing

Learn everything about UBL 2.1 (Universal Business Language), the XML standard required for Morocco's DGI e-invoicing compliance. Technical overview, structure, and implementation guide.

What is UBL 2.1? The Complete Guide to Universal Business Language for E-Invoicing
H

Hisab Team

Updated 12/9/2025

What is UBL 2.1? The Complete Guide for Moroccan Businesses

If you're preparing for Morocco's 2026 e-invoicing mandate, you've probably heard about UBL 2.1. But what exactly is it, and why does it matter for your business? This comprehensive guide explains everything you need to know.

What is UBL (Universal Business Language)?

UBL 2.1 (Universal Business Language version 2.1) is an international XML-based standard developed by OASIS (Organization for the Advancement of Structured Information Standards) for electronic business documents. It provides a standardized format for:

  • Invoices
  • Credit notes
  • Debit notes
  • Purchase orders
  • Delivery notes
  • And many more business documents

Why UBL 2.1?

Morocco's Direction Générale des Impôts (DGI) has chosen UBL 2.1 as the standard format for electronic invoices because:

BenefitDescription
International StandardRecognized globally, facilitating cross-border trade
XML-BasedMachine-readable and easily validated
ComprehensiveCovers all invoice data requirements
ExtensibleCan be adapted for local requirements
ProvenUsed by EU countries and worldwide

UBL 2.1 Invoice Structure

A UBL 2.1 invoice contains several key sections:

1. Invoice Header

<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
  <UBLVersionID>2.1UBLVersionID>
  <ID>INV-2024-001234ID>
  <IssueDate>2024-01-15IssueDate>
  <InvoiceTypeCode>380InvoiceTypeCode>
  <DocumentCurrencyCode>MADDocumentCurrencyCode>
Invoice>

2. Supplier Information (AccountingSupplierParty)

Contains your business details:

  • Legal name and trade name
  • Tax identification (ICE, IF, RC)
  • Address
  • Contact information

3. Customer Information (AccountingCustomerParty)

Contains buyer details:

  • Company or individual name
  • Tax identifiers
  • Delivery address
  • Contact details

4. Invoice Lines (InvoiceLine)

Each product or service includes:

  • Description
  • Quantity and unit
  • Unit price
  • Tax category and rate
  • Line total

5. Tax Summary (TaxTotal)

Breakdown of all applicable taxes:

  • VAT amounts per rate
  • Tax categories
  • Taxable amounts

6. Monetary Totals (LegalMonetaryTotal)

Financial summary:

  • Line extension amount (subtotal)
  • Tax exclusive amount
  • Tax inclusive amount
  • Payable amount

Key UBL 2.1 Elements for Morocco

For DGI compliance, these fields are mandatory:

ElementDescriptionExample
ICEIdentifiant Commun de l'Entreprise001234567000089
IFIdentifiant Fiscal12345678
RCRegistre de Commerce123456
IssueDateInvoice date2024-01-15
DueDatePayment due date2024-02-15
TaxTotalVAT breakdown20% rate

UBL 2.1 vs Other Formats

FeatureUBL 2.1Factur-XPEPPOL BIS
Base FormatPure XMLPDF + XMLUBL subset
ComplexityMediumLowMedium
Morocco Support✅ Required❌ Not accepted❌ Not used
Human ReadableNo (XML)Yes (PDF)No (XML)

How Hisab Handles UBL 2.1

With Hisab, you don't need to worry about XML complexity. Our platform:

  1. Automatic Generation - Creates valid UBL 2.1 XML from your invoice data
  2. Validation - Ensures compliance with DGI requirements
  3. Digital Signatures - Adds required cryptographic signatures
  4. Archive Storage - Maintains 10-year compliant archive
  5. API Access - Download UBL XML for any invoice via our API

Example API Response

{
  "invoice_id": "INV-2024-001234",
  "ubl_xml": "https://api.hisab.ma/v1/invoices/123/ubl",
  "validation_status": "valid",
  "dgi_submission": "pending"
}

Technical Implementation Tips

For Developers

If you're integrating with the DGI system directly, remember:

  1. Use UTF-8 encoding for all XML documents
  2. Include XML namespace declarations correctly
  3. Validate against official XSD schemas before submission
  4. Handle Arabic text with proper Unicode support
  5. Test with DGI sandbox environment first

Common Validation Errors

ErrorCauseSolution
Invalid ICE formatWrong length or charactersEnsure 15 digits
Missing TaxTotalNo tax breakdownAdd VAT calculation
Invalid date formatWrong formatUse YYYY-MM-DD
Schema violationMissing required elementCheck all mandatory fields

Conclusion

UBL 2.1 is the foundation of Morocco's e-invoicing system. While it may seem complex, using a compliant platform like Hisab handles all the technical details automatically. Start your transition today to be ready for the 2026 mandate.

Ready to get started? Create your free Hisab account and generate your first UBL 2.1 compliant invoice in minutes.

ubl
ubl-2.1
xml
e-invoicing
technical-standards
dgi
morocco

Ready for e-invoicing?

Start your free trial today and simplify your invoicing