# PIH validation errors

**URL:** <https://zatca1.discourse.group/t/pih-validation-errors/2474>\
**Category:** Clearance and Reporting\
**Created:** [August 18, 2024, 1:27pm UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474 "2024-08-18T13:27:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hadi](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@Hadi](https://zatca1.discourse.group/u/Hadi)\
**Post date:** [August 18, 2024, 1:27pm UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/1 "2024-08-18T13:27:34Z")

</div>

Dears ,

Hope this finds you well .

I keep getting this error when validating my invoices using fatoora SDK :

```auto
[INFO] ValidationProcessorImpl - [PIH] validation result : FAILED
[ERROR] ValidationProcessorImpl - pih validation errors :
[ERROR] ValidationProcessorImpl - CODE : KSA-13, MESSAGE : PIH is inValid
[INFO] InvoiceValidationService - *** GLOBAL VALIDATION RESULT = FAILED

```

I’m using the standard invoice provided in the sample folder in the SDK \Data\Samples\Standard\Invoice\Standard\_Invoice.xml

I Tried modifying the PIH to 0 or to “MA==” (which is the equilivent of 0 in base64 with no luck .

Please advice .

---

<div class="post-metadata">

**Author:** ![Malik](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/malik/32/708_2.png) [@Malik](https://zatca1.discourse.group/u/Malik)\
**Post date:** [August 21, 2024, 4:31am UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/2 "2024-08-21T04:31:21Z")

</div>

Please note that there is a PIH text file to keep last invoice hash please check if it is there  
C:\zatca-einvoicing-sdk-238-R3.3.3\Data\PIH

and for very first invoice your hash should be  
NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==

where means 0 (zero)

---

<div class="post-metadata">

**Author:** ![sayedrahman](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/sayedrahman/32/475_2.png) [@sayedrahman](https://zatca1.discourse.group/u/sayedrahman)\
**Post date:** [September 22, 2024, 10:17pm UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/3 "2024-09-22T22:17:43Z")

</div>

Do i have to keep it?? If i use it as first PIH, what about Second on will be??  
thanks in Advance

---

<div class="post-metadata">

**Author:** ![Ather](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ather/32/848_2.png) [@Ather](https://zatca1.discourse.group/u/Ather)\
**Post date:** [September 23, 2024, 3:34am UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/4 "2024-09-23T03:34:48Z")

</div>

You need to update the PIH whenever you generate a new invoice, First Invoice PIH will be

**NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==**

and the hash of first invoice will be the PIH of Next invoice.  
Example:  
Invoice 1

Invoice Hash: **ZNMSA9pKhIlUDf/Lb5JbS37HIMfYmvRy8SJS41sTKAM=**  
PIH : NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==

Invoice 2:  
Invoice Hash : 5yfF/cx7h0oe9oESilAGXfyLHMWYJ0ASIzJAjjt9K/o=  
PIH : **ZNMSA9pKhIlUDf/Lb5JbS37HIMfYmvRy8SJS41sTKAM=**

Invoice 3 :  
Invoice Hash : 268oIbm9asXQXwmM5aDR2poh7kKqgui5BDqNQdhqS0A=  
PIH : **5yfF/cx7h0oe9oESilAGXfyLHMWYJ0ASIzJAjjt9K/o=**

---

<div class="post-metadata">

**Author:** ![sayedrahman](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/sayedrahman/32/475_2.png) [@sayedrahman](https://zatca1.discourse.group/u/sayedrahman)\
**Post date:** [September 23, 2024, 10:57am UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/5 "2024-09-23T10:57:56Z")

</div>

@Ather thanks a lot for your information, if the invoice does not have reported what about that?? should i still take next PIH??  
I am facing The invoice hash API body does not match the (calculated) Hash of the XML, everytime, How to solve it, Can you help me out??

---

<div class="post-metadata">

**Author:** ![Ather](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ather/32/848_2.png) [@Ather](https://zatca1.discourse.group/u/Ather)\
**Post date:** [September 24, 2024, 4:26am UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/6 "2024-09-24T04:26:14Z")

</div>

@sayedrahman  
Which SDK are you using?

---

<div class="post-metadata">

**Author:** ![Ather](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ather/32/848_2.png) [@Ather](https://zatca1.discourse.group/u/Ather)\
**Post date:** [September 24, 2024, 5:30am UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/7 "2024-09-24T05:30:29Z")

</div>

> [@sayedrahman](#):
>
> if the invoice does not have reported what about that?? should i still take next PIH??

**If invoice is rejected by ZATCA, then tax payers can fix the  
errors and submit the XML just like a new invoice having its own Invoice Counter Value and Hash.**

[Detailed Guidelines for E-Invoicing](https://zatca.gov.sa/en/E-Invoicing/Introduction/Guidelines/Documents/E-Invoicing_Detailed__Guideline.pdf)

Page 63

---

<div class="post-metadata">

**Author:** ![anas1](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/anas1/32/1447_2.png) [@anas1](https://zatca1.discourse.group/u/anas1)\
**Post date:** [December 1, 2025, 3:22pm UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/8 "2025-12-01T15:22:38Z")

</div>

In my case it was just the line break, make sure it’s all in one line

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/2X/8/8200dcd46c4c278a1f633054c5a6252448dc498a.png)

---

<div class="post-metadata">

**Author:** ![ser](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ser/32/1443_2.png) [@ser](https://zatca1.discourse.group/u/ser)\
**Post date:** [December 1, 2025, 5:38pm UTC](https://zatca1.discourse.group/t/pih-validation-errors/2474/9 "2025-12-01T17:38:38Z")

</div>

@Hadi  
**The PIH must contain a valid and correct hash value of the previous invoice in the invoice chain.**

It cannot be:

- Empty

- Zero

- “MA==”

- An incorrectly encoded value  
@Malik
