Transaction documents
Use documents, such as receipts, and invoices, to calculate the CO₂e emissions of transactions with Lune.Pre-requisites
Complete the following setup steps before using this guide:
Generate an API key and authenticate your account.

Set up Client Accounts to track emissions for your individual customers.

Review how to calculate emissions for individual transactions using the API.
1. Extract transaction documents
The first step is extracting data from any documents that contain useful information into a key-value pair format.While Object Character Recognition (OCR) software is commonly used to extract data from documents, you can use any method of your choice. The extracted data must be formatted as JSON, with no predefined schema requirements. Lune will process this input to determine the transaction details.If multiple data sources reference the same transaction, they can be combined to build a more comprehensive unstructured data object.Lune is optimised to work with outputs from OCR software like Mindee but can process any unstructured data submitted.
2. Build the document request
At minimum, the request must include theunstructured_data
property, with a key_value
object:
unstructured_data.key_value
name
is_transaction_document
transaction_document_processed_at
3. Make the API request
The API processes one transaction per request. Use theestimates/transaction-documents/
endpoint to calculate emissions for several transactions. Send a POST
request to this endpoint to create the estimate.Remember to add the Authorization header with your API Key as Bearer Token, as well as a Lune Account header with the client account that this emission is being calculated for.
Sample Request
The request includes unstructured data from an actual invoice, as well as a generatedname
input to allow for easier reconciliation of the transaction in the your system.
4. Interpret the results
The API response contains:- Emission calculation for the document: Refer to the
mass
property of the results. - Interpretation of detected items: The
line_items
property shows how Lune interpreted each line item. Additionally, each line item includes amass
for the emissions calculated for that item, and theemission_factor
used to calculate the estimate.
line_items
property to verify accuracy the first few times you use this request. If anything looks unexpected, get in touch - we are continually improving our data interpretation algorithms.Currently, only transaction type estimates are available. Future updates will include activity-based emissions (for example, use of sheets of A4 paper).
Sample response
See the sample response below for a transaction document. The total emissions calculated for the document is 1.12 tonnes CO₂e. The document contained two line items, an office chair and standing desk. These line items emitted 0.51 and 0.61 tonnes of CO₂e respectively.
What to do next...
Now that you have your estimate, there are several actions you can take!
Offset the calculated emissions by purchasing carbon credits through the API.

Generate an analytics report for your customers about their emissions.
Troubleshooting
If you receive a422
status code, it could mean one of the following issues has occurred:transaction_document_inference_failure
transaction_document_creation_failure