Lune Docs Logo

Transactions

Calculate the CO₂e emissions for your transactions using the Lune API.

Pre-requisites

Complete the following setup steps before using this guide:
/illustrations/stamp-key.png
Generate an API key and authenticate your account.
/illustrations/stamp-accounts.png
Set up Client Accounts to track emissions for your individual customers.

1. Gather transaction details

Basic requirements
To calculate emissions, you need the value and merchant for each transaction. You can include up to 100 transactions in a single API request. If one transaction can’t be processed, the response will include results for the other transactions, and an error for the invalid one.The request requires an array of transaction objects, each containing value and merchant fields:
  • Array of transaction objects
  • Value
    Specify the value of each transaction using a monetary amount and an ISO 4217 3-character currency code:
  • Value object
  • Merchant
    The merchant object can be customised based on the type of transaction.
    Card transactions
    For card transactions, add the category and country code to the merchant object in ISO 18245 and ISO 3166-1 alpha-3 formats, respectively.
  • Merchant object for card transactions
  • Non-card transactions
    For transactions that are not processed by card, provide a search term and a country code and Lune will figure out the rest. For the best results, add category to the object.For example, if you have a transaction for a desk chair, you can provide the following merchant object for the calculation:
  • Merchant object for non-card transactions
  • Optional properties
    To make full use of Lune’s emissions reporting capabilities, we recommend including the following properties for each transaction in the request:
    • is_transaction: Set this property to true for a processed transaction. If the calculation is for a quote or forecast, set it to false.
    • transaction_processed_at: Provide this property as the date and time of processing for the transaction in RFC 3339 format. This will improve reporting accuracy.

    2. Make the API request

    Use the estimates/transactions/batch/ 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 generated Bearer Token, as well as a Lune Account header with the client account that this emission is being calculated for.
  • Sample request
    The following request estimates emissions for three transactions:
    1. First transaction: A $1200.99 USD purchase from Herman Miller.
    2. Second transaction: A $120.00 USD purchase from American Airlines.
    3. Third transaction: A $550.49 USD purchase from Hyatt Hotels.
  • CURL request for a batch of transactions
  • The request above allows you to submit several transactions at once. If you’d like to submit only one transaction, you can use the endpoint above, or the single transaction endpoint.

    3. Interpret the results

    The response will be returned as an array of calculations for each transaction. Refer to the mass property of each object for the CO₂e estimate for each transaction.In the sample request from Step 2, the CO₂e estimates are 0.002391 tonnes for the Herman Miller purchase, 0.11448 tonnes for the American Airlines purchase, and 0.024536 tonnes for the Hyatt Hotels purchase.
  • Results for transaction emission estiamtes
  • Each transaction object also provides details on the emission factors and methodology used in the calculation.Make sure to save the id for each of the transactions in the response for future reference. You can use this property later on for reporting, analytics, and any updates to the calculation.For details on additional properties, go to the full API reference.

    4. Update the estimate

    If the initial estimate was for a quote or forecast, you'll need to update it once the final details are confirmed.Use the estimate’s id with the estimates/transactions/{id} endpoint, and send a PUT request that includes the updated transaction. Ensure that is_transaction is set to true. See the reference for this endpoint here.Success! You’ve successfully calculated emissions for your transactions. This brings you one step closer to climate compliance!

    What to do next…

    Now that you have your estimate, there are several actions you can take!