Skip to main content
BR-KSA-26ErrorZATCA Phase 2 UBL 2.1implemented

Previous Invoice Hash (PIH) Base64 SHA-256 Format

The PIH EmbeddedDocumentBinaryObject must be a valid Base64-encoded SHA-256 digest chaining to the previous invoice.

Scope
Hash Chain & Security
Applicable Invoice Types
Standard (B2B), Simplified (B2C), Credit Note, Debit Note
Catalog Version
v1.0.0 (2026-11-23)
Target XPath
/Invoice/cac:AdditionalDocumentReference[cbc:ID='PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject

Typical Reason for Failure

Raw unencoded text like '0' or truncated hex strings are placed inside the PIH tag.

Invalid Synthetic Example

Before (Fails)xml
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">0</cbc:EmbeddedDocumentBinaryObject>

Corrected Synthetic Example

After (Fixed)xml
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==</cbc:EmbeddedDocumentBinaryObject>

Explanation of the Fix

Encode the SHA-256 digest of the previous invoice (or '0' for ICV=1) as Base64.

Official Source Reference

ZATCA Electronic Invoice XML Implementation Standard (Phase 2)

Open official specification

Related Rules

Test your invoice against BR-KSA-26 now

Browser quick check; raw XML is never stored.

Open Validator