Retrieving invoice data with the Cleura Cloud REST API
You may download some or all of your Cleura Cloud invoice data using the Cleura Cloud REST API.
Prerequisites
Before retrieving any of your invoice data, you need to create a token for the current session.
Saving invoice data
To save JSON data about all available invoices locally, submit a Cleura Cloud REST API request like this:
curl -H "X-AUTH-LOGIN: your_username" \
-H "X-AUTH-TOKEN: your_token" \
-o invoices.json \
https://rest.cleura.cloud/account/v1/invoices
A command like the above will download the data of up to 20 invoices
and save them as JSON objects into the file invoices.json
. You may
change the number of invoices with the limit
parameter:
curl -H "X-AUTH-LOGIN: your_username" \
-H "X-AUTH-TOKEN: your_token" \
-o invoices.json \
https://rest.cleura.cloud/account/v1/invoices?limit=2
That will limit the number of invoices to 2. Please note that you may download data from up to 100 invoices.
Sifting through invoice data
Once you have your invoice data, you may sift through it with a tool
like jq
. For example, here is a quick way to check if all downloaded
invoices are already paid:
jq '.[].status' invoices.json
"paid"
"paid"
To get a list with all invoice IDs, type the following:
jq '.[].id' invoices.json
"164..."
"163..."
You may now get more information regarding a specific invoice. Find
out, for instance, when is (or was) the due date for the invoice with
ID 164...
:
jq '.[] | select(.id=="164...") .dueDate' invoices.json
"2023-01-23"