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.
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:
| Benefit | Description |
|---|---|
| International Standard | Recognized globally, facilitating cross-border trade |
| XML-Based | Machine-readable and easily validated |
| Comprehensive | Covers all invoice data requirements |
| Extensible | Can be adapted for local requirements |
| Proven | Used 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:
| Element | Description | Example |
|---|---|---|
ICE | Identifiant Commun de l'Entreprise | 001234567000089 |
IF | Identifiant Fiscal | 12345678 |
RC | Registre de Commerce | 123456 |
IssueDate | Invoice date | 2024-01-15 |
DueDate | Payment due date | 2024-02-15 |
TaxTotal | VAT breakdown | 20% rate |
UBL 2.1 vs Other Formats
| Feature | UBL 2.1 | Factur-X | PEPPOL BIS |
|---|---|---|---|
| Base Format | Pure XML | PDF + XML | UBL subset |
| Complexity | Medium | Low | Medium |
| Morocco Support | ✅ Required | ❌ Not accepted | ❌ Not used |
| Human Readable | No (XML) | Yes (PDF) | No (XML) |
How Hisab Handles UBL 2.1
With Hisab, you don't need to worry about XML complexity. Our platform:
- Automatic Generation - Creates valid UBL 2.1 XML from your invoice data
- Validation - Ensures compliance with DGI requirements
- Digital Signatures - Adds required cryptographic signatures
- Archive Storage - Maintains 10-year compliant archive
- 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:
- Use UTF-8 encoding for all XML documents
- Include XML namespace declarations correctly
- Validate against official XSD schemas before submission
- Handle Arabic text with proper Unicode support
- Test with DGI sandbox environment first
Common Validation Errors
| Error | Cause | Solution |
|---|---|---|
| Invalid ICE format | Wrong length or characters | Ensure 15 digits |
| Missing TaxTotal | No tax breakdown | Add VAT calculation |
| Invalid date format | Wrong format | Use YYYY-MM-DD |
| Schema violation | Missing required element | Check 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.