mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:24:42 -04:00
Update API docs
This commit is contained in:
parent
28e43df833
commit
b2e8457c3a
32
docs/api.rst
32
docs/api.rst
@ -15,30 +15,45 @@ Reading Data
|
||||
|
||||
Here’s an example of reading the list of clients using cURL from the command line.
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
For invoices, quotes, tasks and payments simply change the object type. ie,
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
To load a single record specify the Id in the URL. Note: you can add ?invoice_number=0001 to search invoices by invoice number.
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
You can download a PDF using the following URL
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/download/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X GET ninja.dev/api/v1/download/1 -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
Creating Data
|
||||
"""""""""""""
|
||||
|
||||
Here’s an example of creating a client. Note that email address is a property of the client’s contact not the client itself.
|
||||
|
||||
``curl -X POST ninja.dev/api/v1/clients -H "Content-Type:application/json" -d '{"name":"Client","contact":{"email":"test@gmail.com"}}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X POST ninja.dev/api/v1/clients -H "Content-Type:application/json"
|
||||
-d '{"name":"Client","contact":{"email":"test@gmail.com"}}' -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
You can also update a client by specifying a value for ‘id’. Next, here’s an example of creating an invoice.
|
||||
|
||||
``curl -X POST ninja.dev/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id":"1", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}]}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X POST ninja.dev/api/v1/invoices -H "Content-Type:application/json"
|
||||
-d '{"client_id":"1", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}]}'
|
||||
-H "X-Ninja-Token: TOKEN"
|
||||
|
||||
If the product_key is set and matches an existing record the product fields will be auto-populated. If the email field is set then we’ll search for a matching client. If no matches are found a new client will be created. To email the invoice set email_invoice to true.
|
||||
|
||||
@ -51,8 +66,9 @@ To email an invoice use the email_invoice command passing the id of the invoice.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
curl -X POST ninja.dev/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":1}'
|
||||
-H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
|
||||
curl -X POST ninja.dev/api/v1/email_invoice -d '{"id":1}'
|
||||
-H "Content-Type:application/json" -H "X-Ninja-Token: TOKEN"
|
||||
|
||||
|
||||
Optional Settings
|
||||
"""""""""""""""""
|
||||
|
Loading…
x
Reference in New Issue
Block a user