How to update clients and invoices data through the API

We need to interact with the InvoiceNinja using the exposed API (
It is indicated that we could update the client data specifying a value for ‘id’. Nevertheless, we haven’t been able to achieve it, we always receive a response error, for example:

*When we have tried the “PUT” method with; the response is:
Something went wrong…

*If we have tried the “PUT” method with (client id=2 exists); the response is:
“Something went wrong… ErrorException”.

Note: We have tried with different bodies:

On the other side, we also need to update the invoices data (in draft status). However, in the documentation, it is not commented anything about this functionality (we have tried to use PUSH + invoice id, but it is not working).

We wonder if you could provide an example of how to update the client data and confirm us if we could update the invoices through the API REST.

This is the correct URL:

Try changing contact to contacts and make it an array.

You should be able to update the invoice through the API, we use it for our iPhone app.

Thank you for your answer, and sorry for the late response. Now, all the calls are working correctly, even for updating invoices. I would like to post here the curl calls for everybody.

$ curl -X PUT -H “Content-Type:application/json” -d ‘{“id”: 23,“name”: “ClientName”,“contacts”: [{“id”: 19,“first_name”: “example”,“last_name”: “last name”,“email”: “”}]}’ -H “X-Ninja-Token: YqN8zeC0JKRNHW6HCsfplAeib2akgLng” -H “X-Requested-With: XMLHttpRequest”

$ curl -X PUT -H “Content-Type:application/json” -d ‘{“id”: 12,“client_id”: 23,“invoice_items”: [{“id”: 21,“product_key”: “lamp”,“notes”: “lamp notes”,“cost”: 22,“qty”: 5},{“id”: 22,“product_key”: “other”,“notes”: “other notes”, “cost”: 44,“qty”: 10}] }’ -H “X-Ninja-Token: token_Id” -H “X-Requested-With: XMLHttpRequest”

By the way, I have only one more question regarding the clients, I have tried to obtain only the registry for one client but the system give an error “Something went wrong… ReflectionException” ). The call is this one:
$ curl -X GET -H “X-Ninja-Token: token_id” -H “X-Requested-With: XMLHttpRequest”

Nevertheless, for the invoice data is working correctly:
$ curl -X GET -H “X-Ninja-Token: YqN8zeC0JKRNHW6HCsfplAeib2akgLng” -H “X-Requested-With: XMLHttpRequest”

I can create another ticket in the support system, if you consider that it should be covered in another thread. Thank you in advance.

If you send an email to with the email address of your account I’ll check our error logs for more details.

I am having some trouble with my curl. I would like to number all of my clients (id_number=A001, A002, etc) similar to the database id (1,2,etc). Any advice?

curl -X PUT -H “Content-Type:application/json” -d ‘{“id_number”: "A001"}’ -H “X-Ninja-Token: a-long-token”

{“error”:{“message”:“Invalid token”}}curl: (3) [globbing] unmatched close brace/bracket in column 5
curl: (3) Failed to convert plffhfkl667pizbq2bcvpuujkzfnjrby” to ACE; string contains a disallowed character

I see two possible issues:

  • You may be using the wrong type of quotes: ” vs " (unless that’s just from the forum)

  • Updating an invoice requires passing all current invoice values