key_commit: Fixed a bug in the api invoices routine