Can not create invoice using API

I have faced with the issue, that if for instance I have created invoice with number = ‘WMR9ES-0006’

  1. Create client
  2. create invoice for the client with number=‘WMR9ES-0006’
  3. delete from admin panel client
  4. invoice of deleted client is not market as deleted and impossible to create invoice for the same number.
    Number is in use.

What can I do to fix all of such invoices that alive but clients marked as deleted ???

Well, I know how to fix it on my side…

I will get all not deleted invoices and check invoice client ‘is_deleted’ and if it is True → mark invoice as deleted too. And then, I believe, the invoice number will be available for creation.


All invoice numbers in the system need to be unique, if you delete an invoice the app should add “_deleted” to the number to free it up.

the app should add “_deleted” to the number to free it up.

There is no problem when to delete invoice itself, it works like a charm.
The problem seems when you delete client, client’s invoices numbers are not updated as you described above (add ‘_deleted’ to invoice number)

Thanks, understood. Not sure the best solution here…

cc @david

@hillel ,

When I try to update invoice and free number I get error:

"message": "Record is deleted and cannot be edited. Restore the record to enable editing"

How to perform invoice restore ?

You can restore the invoices in the admin portal, there is a filter at the bottom to view deleted records.

Note: if the client is deleted you’d need to filter by the client to see the deleted invoices.

1 Like