Lune Docs Logo

Multi-leg shipments

Calculate the CO₂e emissions for your shipment 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 shipment details

Basic requirements
To calculate an emissions estimate with Lune, you need three essential pieces of information: the shipment’s quantity, the distance travelled, and the transport method used. This data is provided within the legs and shipment objects in your API request.The legs object is an array, with each element detailing the route and method for a specific segment of the shipment's journey. At least one leg is required in this array to generate a calculation.
  • Legs
  • In addition to specifying the routes and methods, add a shipment property, to define the shipment's quantity. You can provide this as a specific mass (in tonnes, kilograms, or grams) or as a number of TEUs. The example below shows a shipment provided in tonnes.
  • Mass in tonnes
  • Route
    You can specify a route by providing the distance in either kilometres or miles, as shown below:
  • Route by total distance
  • Alternatively, you can specify a source and destination, and Lune will calculate the distance automatically. You can enter the source and destination using an address, geographic coordinates, a UN/LOCODE, or an airport code. The source and destination don’t need to be entered using the same properties; a source can use an airport code, while a destination can use a UN/LOCODE, as seen in the example below:
  • Route by source and destination
  • Method
    You can implement the method property in several ways, depending on how much information you have available. Lune offers multiple calculation methodologies. Some require minimal data, while others use more detailed inputs for greater accuracy. For example, a CO₂e calculation can be generated by specifying simply the type of truck used for the leg:
  • Single input method
  • Alternatively, for a more precise calculation, you can provide additional details such as vehicle type, fuel blend, road topology, and emission standards:
  • Method with additional details
  • Lune supports a wide range of options for defining the legs of your shipment. Once you complete this guide, refer to the resources below for details on implementing various transport method.
    Optional properties
    To make full use of Lune’s emissions reporting capabilities, we recommend including the following properties in emission calculation requests:
    is_shipment
    Set this property to true for confirmed shipments. If the shipment is still in the booking phase and has not been purchased, set it to false.

    2. Make the API request

    Use the estimates/shipping/multi-leg/ endpoint to calculate emissions for multi-leg shipments. 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.
  • The following request estimates emissions for a confirmed 2.2 tonnes shipment across two legs:
    1. First leg: Shipment by cargo plane from Toronto Pearson Airport to London Heathrow Airport.
    2. Second leg: Shipment by truck from London Heathrow Airport to Cambridge, United Kingdom.
    Sample request
  • Sample request
  • 3. Interpret the results

    After receiving a response, refer to the mass property for the total CO₂e estimate for the entire shipment. In the sample request from Step 2, the total CO₂e estimate of 8.084842 tonnes.
  • Calculated emissions
  • In addition to the total estimate, each leg includes a specific mass value for that segment, with all segments summing up to the total mass. In the sample request, the cargo plane contributes 8.028877 tonnes of CO₂e, while the truck adds 0.055965 tonnes.Each leg also provides details on the emission factors and methodology used in the calculation.Make sure to save the id 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 created during the booking phase, you'll need to update it once the final details are confirmed. Any changes after booking confirmation will also require an estimate update.Use the estimate’s id with the estimates/shipping/multi-leg/{id} endpoint, and send a PUT request that includes the updated legs. Ensure that is_shipment is set to true.Success! You’ve successfully calculated emissions for your shipment. 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!