# Invoice validate works with the same Ref value

**URL:** <https://www.dolibarr.org/forum/t/invoice-validate-works-with-the-same-ref-value/30587>\
**Category:** Financial modules\
**Created:** [August 22, 2025, 10:44am UTC](https://www.dolibarr.org/forum/t/invoice-validate-works-with-the-same-ref-value/30587 "2025-08-22T10:44:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lali](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/l/5e9695/32.png) [@Lali](https://www.dolibarr.org/forum/u/Lali)\
**Post date:** [August 22, 2025, 10:44am UTC](https://www.dolibarr.org/forum/t/invoice-validate-works-with-the-same-ref-value/30587/1 "2025-08-22T10:44:19Z")

</div>

Hi everyone,

I want to validate invoices through the API, several at the same time. However, sometimes two API calls try to validate (not the same) invoice, but the second one fails because the getNextNumRef(…) gave the same ref. When the validate method want to update the invoice, the database throw “duplicate value” error.

Has anyone encountered this issue, and does anyone have a solution for it?

---

<div class="post-metadata">

**Author:** ![jonbendtsen](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jonbendtsen](https://www.dolibarr.org/forum/u/jonbendtsen)\
**Post date:** [August 22, 2025, 5:28pm UTC](https://www.dolibarr.org/forum/t/invoice-validate-works-with-the-same-ref-value/30587/2 "2025-08-22T17:28:04Z")

</div>

which dolibarr version are you running?

---

<div class="post-metadata">

**Author:** ![tindoshox](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/7cd45c/32.png) [@tindoshox](https://www.dolibarr.org/forum/u/tindoshox)\
**Post date:** [September 4, 2025, 4:30am UTC](https://www.dolibarr.org/forum/t/invoice-validate-works-with-the-same-ref-value/30587/3 "2025-09-04T04:30:18Z")

</div>

Depending on what method your using to perform the requests, you can either have the requests run sequentially or you can have a retry mechanism. If the same user is sending multiple request, send the requests sequentially, each request waiting for the preceding request to complete.
