BR-KSA-26: Previous invoice hash (PIH) is in the wrong form

A warning: the invoice is accepted with a note; fix the cause in the next invoices.

Official text

If the invoice contains the previous invoice hash (KSA-13), this hash must be base64 encoded SHA256. The hash shall be computed using the following method as described in the ds:transforms block in the XML Invoice Specifications: 1. Remove the <Invoice><ext:UBLExtensions/> block 2. Remove the <Invoice><cac:AdditionalDocumentReference/> block where <cbc:ID/> = QR 3. Remove the <Invoice><cac:Signature/> block 4. Canonicalize the Invoice using the C14N11 standard 5. Hash the resulting string using SHA256 to a binary object 6. Base64 encode the binary object to generate the digest value For the first invoice, the previous invoice hash is "NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==", the equivalent for base64 encoded SHA256 of "0" (zero) character.

Warning · Source: ZATCA E-Invoicing SDK 238-R3.3.8 · Electronic Invoice XML Implementation Standard v1.2, 19 May 2023, §13.3.1, p. 53 · Checked: 26 October 2026

What it means

Each invoice carries the SHA-256 hash of the invoice before it, Base64 encoded, with type text/plain. The first invoice carries a fixed value published by ZATCA (the hash of the character 0).

When it happens

How to fix it

  1. Write mimeCode="text/plain".
  2. Store the hash of the last accepted invoice and use it in the very next one.
  3. Compute the hash the way the rule text describes: remove UBLExtensions, the QR reference and Signature, then C14N11, then SHA-256, then Base64.

Example

Wrong: raises BR-KSA-26
<cac:AdditionalDocumentReference>
  <cbc:ID>PIH</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="application/octet-stream">NWZlY2Vi…</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>
Correct
<cac:AdditionalDocumentReference>
  <cbc:ID>PIH</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2Vi…</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>

We ran the wrong example through ZATCA's SDK 238-R3.3.8 on 26 October 2026 and it raised BR-KSA-26, along with BR-KSA-61, BR-KSA-CL-03. The example is an excerpt of ZATCA's sample Simplified/Invoice/Simplified_Invoice.xml with one change; the sample without it does not raise the code.

Related codes

Terms on this page

Frequently asked questions

What does BR-KSA-26 mean?

Each invoice carries the SHA-256 hash of the invoice before it, Base64 encoded, with type text/plain. The first invoice carries a fixed value published by ZATCA (the hash of the character 0).

Is the invoice rejected when BR-KSA-26 appears?

A warning: the invoice is accepted with a note; fix the cause in the next invoices. This is its severity in ZATCA's SDK 238-R3.3.8.

How do I fix BR-KSA-26?

1. Write mimeCode="text/plain". 2. Store the hash of the last accepted invoice and use it in the very next one. 3. Compute the hash the way the rule text describes: remove UBLExtensions, the QR reference and Signature, then C14N11, then SHA-256, then Base64.

Last updated: 26 October 2026 · What we don't do · Methodology · Correct us · Changelog

First published 2026-10-26 · Archived copy

First 500 restaurants, cafés, bakeries and sweet shops: a SAR 99 monthly cap.

Instead of SAR 149, per branch, for a full year. Free to join, no commitment.

Reserve your seat