Skip to main content

Create a shipping emission estimate (multi-leg)

Each leg can be fulfilled by a different method, eg a truck, a plane or other options.

Parameters

Either a mass given in kilograms or tonnes (mass) or the number of Twenty-foot Equivalent Units (TEUs) (with their cargo type, optionally). Note that providing mass will result in more accurate estimates for methods other than container_ship. Estimates using container_ship are more precise when the shipment is given in TEUs.


legsarray of oneOfrequired

An array representing all the legs of a shipment.


namestring

A name to reference this calculation.


bundle_selectionarray of object

Bundle selection percentages.

The sum of all percentages must equal 100.

If not specified, the preconfigured allocation ratios are going to be used.

If, for each selection, percentage is not provided, the selection is divided equally (best effort) between bundles. percentage must be provided for all or none of the bundles.


quantity_truncenum

Unit, t for tonne, kg for kilogram, g for gram

Enum:
  • g
  • kg
  • t

is_shipmentboolean

When true, the emission estimate refers to an actual shipment of goods, will be included in Lune analytics and can be included in any CO2 emissions reporting.

This property exists to distinguish booking quotes or forecasts from actual shipments where goods are moved.

You can mark an estimate as shipment at any time.


shipped_atstringdate-time

The date and time of shipping the goods for the purpose of analytics (it doesn't affect emission calculations in any way).

If a value is provided when creating or updating an estimate we use the value. Otherwise defaults to the current time when creating estimates and remains unchanged when updating estimates.

This property must be formatted as RFC 3339, section 5.6 timestamp.

Examples:

  • 2023-12-01T12:30:30.000Z
  • 2023-12-01T12:30:30Z
  • 2023-12-01T11:30:30+01.00

metadataobject

An arbitrary dictionary (key-value pairs) to store application-specific information.

Lune doesn't use this information for order processing. Its purpose is for the API clients to be able to attach arbitrary information (to an order for example) and then retrieve it.


idempotency_keystring

Account-unique identifier provided by the client.

idempotency_key has two purposes:

  1. Clients can safely retry estimate requests without accidentally performing the same operation multiple times.
  2. Clients can use idempotency_key to reconcile estimates with entities on their system.
Returns
is_shipmentbooleanrequired

When true, the emission estimate refers to an actual shipment of goods, will be included in Lune analytics and can be included in any CO2 emissions reporting.

This property exists to distinguish booking quotes or forecasts from actual shipments where goods are moved.

You can mark an estimate as shipment at any time.


shipped_atstringdate-timerequired

The date and time of shipping the goods for the purpose of analytics (it doesn't affect emission calculations in any way).

If a value is provided when creating or updating an estimate we use the value. Otherwise defaults to the current time when creating estimates and remains unchanged when updating estimates.

This property must be formatted as RFC 3339, section 5.6 timestamp.

Examples:

  • 2023-12-01T12:30:30.000Z
  • 2023-12-01T12:30:30Z
  • 2023-12-01T11:30:30+01.00

legsarray of objectrequired

An array representing a leg's emission estimate.

Returned in the same order as the request.


distanceobjectrequired

adjusted_distanceobjectrequired

Distance estimation after distance adjustment factors have been applied. Adjusted factors are decided by GLEC and are added to make distances more realistic.


requestobjectrequired

Parameters for estimating multi-leg shipping emissions


massobjectrequired

metadataobject

An arbitrary dictionary (key-value pairs) to store application-specific information.

Lune doesn't use this information for order processing. Its purpose is for the API clients to be able to attach arbitrary information (to an order for example) and then retrieve it.


idempotency_keystring

Account-unique identifier provided by the client.

idempotency_key has two purposes:

  1. Clients can safely retry estimate requests without accidentally performing the same operation multiple times.
  2. Clients can use idempotency_key to reconcile estimates with entities on their system.

idstringrequired

The emission calculation unique identifier


quoterequired
  • POST /estimates/shipping/multi-leg
  • curl 'https://api.lune.co/v1/estimates/shipping/multi-leg' \
      -H 'Authorization: Bearer <API_KEY>' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{
        "is_shipment": true,
        "shipped_at": "2023-11-20T10:20:30Z",
        "shipment": {
          "mass": {
            "amount": "10.36",
            "unit": "t"
          }
        },
        "legs": [
          {
            "route": {
              "source": {
                "lat": 24.211893,
                "lon": 120.608696
              },
              "destination": {
                "locode": "TWTXG"
              }
            },
            "method": "diesel_truck"
          },
          {
            "route": {
              "source": {
                "locode": "TWTXG"
              },
              "destination": {
                "locode": "TWTPE"
              }
            },
            "method": {
              "vessel_type": "container_ship"
            }
          },
          {
            "route": {
              "source": {
                "locode": "TWTPE"
              },
              "destination": {
                "locode": "DEHAM"
              }
            },
            "method": {
              "vessel_imo_number": "9893890"
            }
          },
          {
            "method": "maritime_container_terminal"
          },
          {
            "route": {
              "source": {
                "locode": "DEHAM"
              },
              "destination": {
                "street_line1": "Märkische Allee 71",
                "postcode": "14979",
                "city": "Großbeeren",
                "country_code": "DEU"
              }
            },
            "method": "truck_articulated_34t"
          }
        ]
      }'
      
  • Response
  • {
      "id": "08QD7GPaBx5b6Y6mJlWyONXLvrZljRE2",
      "is_shipment": false,
      "shipped_at": "2023-11-20T10:20:30Z",
      "mass": {
        "amount": "1.105698",
        "unit": "t"
      },
      "quote": {
        "estimated_quantity": "1.105697",
        "estimated_commission": "3.02",
        "estimated_total_cost": "30.13",
        "estimated_offset_cost": "27.11",
        "requested_value": null,
        "requested_quantity": "1.105698",
        "currency": "USD",
        "bundles": [
          {
            "bundle_id": "q9aKx7b6nNXMk3Yv3pD1mlW5Od2eLZE8",
            "bundle_name": "Conserving forests in Asia",
            "quantity": "1.050413",
            "unit_price": "12.65",
            "gross_unit_price": "14.06",
            "offset_cost": "13.29",
            "insufficient_available_quantity": null
          },
          {
            "bundle_id": "xWaKJL3okjD46VpJ4yGXnQNZRe1vzP0w",
            "bundle_name": "Ocean Carbon Removal",
            "quantity": "0.055284",
            "unit_price": "250",
            "gross_unit_price": "277.78",
            "offset_cost": "13.82",
            "insufficient_available_quantity": null
          }
        ]
      },
      "distance": {
        "amount": "22951.682",
        "unit": "km"
      },
      "legs": [
        {
          "mass": {
            "amount": "0.018195",
            "unit": "t"
          },
          "distance": {
            "amount": "19.09",
            "unit": "km"
          },
          "methodology": []
        },
        {
          "mass": {
            "amount": "0.019576",
            "unit": "t"
          },
          "distance": {
            "amount": "267.02",
            "unit": "km"
          },
          "methodology": []
        },
        {
          "mass": {
            "amount": "0.901448",
            "unit": "t"
          },
          "distance": {
            "amount": "22350.48",
            "unit": "km"
          },
          "methodology": []
        },
        {
          "mass": {
            "amount": "0.031184",
            "unit": "t"
          },
          "methodology": []
        },
        {
          "mass": {
            "amount": "0.135294",
            "unit": "t"
          },
          "distance": {
            "amount": "47.2081",
            "unit": "km"
          },
          "methodology": []
        }
      ],
      "request": {
        "shipment": {
          "mass": {
            "amount": "10.36",
            "unit": "t"
          }
        },
        "legs": [
          {
            "route": {
              "source": {
                "lat": 24.211893,
                "lon": 120.608696
              },
              "destination": {
                "locode": "TWTXG"
              }
            },
            "method": "diesel_truck"
          },
          {
            "route": {
              "source": {
                "locode": "TWTXG"
              },
              "destination": {
                "locode": "TWTPE"
              }
            },
            "method": {
              "vessel_type": "container_ship"
            }
          },
          {
            "route": {
              "source": {
                "locode": "TWTPE"
              },
              "destination": {
                "locode": "DEHAM"
              }
            },
            "method": {
              "vessel_imo_number": "9893890"
            }
          },
          {
            "method": "maritime_container_terminal"
          },
          {
            "route": {
              "source": {
                "locode": "DEHAM"
              },
              "destination": {
                "street_line1": "Märkische Allee 71",
                "postcode": "14979",
                "city": "Großbeeren",
                "country_code": "DEU"
              }
            },
            "method": "truck_articulated_34t"
          }
        ]
      }
    }