Calculate and price in one request

Calculate the emissions of one or more activities and get a price and a payment link in the same call.

Calculates the emissions of the activities you send and quotes a price for compensating them, in one request. The response holds a pricing ID for Create a purchase and, with the payment method stripe, a payment_link to the SQUAKE checkout page.

Every feature of POST /v2/calculations and GET /v2/pricing works here too. If you only need emissions or only a price, call the specific endpoint instead: it responds faster and is simpler to integrate.

Request

POST /v2/calculations-with-pricing

itemsarrayrequired

The activities to calculate, in the same format as POST /v2/calculations. See the calculation guides.

productstringrequired

The ID of the product to price, such as product_2rsg35sfsdf.

currencystring

Three-letter ISO 4217 currency code of the price.

carbon_unitstring

Unit of the returned carbon quantities: tonne, kilogram or gram.

distance_unitstring

Unit of the returned distances, such as kilometer.

payment_methodstring

batch_settlement to buy through the API, or stripe to receive a payment_link to the checkout page.

payment_link_return_urlstring

Where the checkout page sends your customer after a successful payment, if they're still in the browser.

expandarray

items for the emissions of each item, legs for the legs of routed flights (with items), product and price for full objects, and items.pricing for a pricing token per item.

See every field of POST /v2/calculations-with-pricing in the API reference

This request prices the outbound flight of a booking and asks for a payment link:

{
  "expand": ["items"],
  "product": "product_2rsg35sfsdf",
  "carbon_unit": "kilogram",
  "currency": "EUR",
  "payment_method": "stripe",
  "payment_link_return_url": "https://www.example.com/booking/BK-2026-0042/thank-you",
  "items": [
    {
      "type": "flight",
      "methodology": "TIM",
      "external_reference": "BK-2026-0042-OUT",
      "origin": "BER",
      "destination": "LHR",
      "departure_date": "2026-03-10",
      "airline": "LH",
      "flight_number": "LH2472",
      "booking_class": "economy",
      "number_of_travelers": 1
    }
  ]
}

Save it as calculation-with-pricing.json and send it:

curl --request POST "https://api.sandbox.squake.earth/v2/calculations-with-pricing" \
  --header "Authorization: Bearer $SQUAKE_API_KEY" \
  --header "Content-Type: application/json" \
  --data @calculation-with-pricing.json

Response

200 OKapplication/json
{
  "id": "eyJhbGciOiJIUzI1NiJ9.eyJwIjoicHJpY2VfMU1Ncm9MMmVaIn0...",
  "carbon_quantity": 142.6,
  "carbon_unit": "kilogram",
  "payment_link": "https://checkout.squake.earth/?t=eyJhbGciOiJIUzI1NiJ9.eyJwIjoicHJpY2VfMU1Ncm9MMmVaIn0...",
  "price": "price_1MMroL2eZvKYlo2CxbxAACvb",
  "product": "product_2rsg35sfsdf",
  "valid_until": "2026-11-24",
  "currency": "EUR",
  "total": 2139,
  "items": [
    {
      "carbon_quantity": 142.6,
      "carbon_unit": "kilogram",
      "type": "flight",
      "methodology": "TIM",
      "external_reference": "BK-2026-0042-OUT",
      "distance": 930.0,
      "distance_unit": "kilometer"
    }
  ]
}
FieldTypeDescription
idstringThe pricing token. Pass it as pricing to create a purchase.
carbon_quantitynumberTotal emissions of all items, in carbon_unit.
carbon_unitstringUnit of the carbon quantities.
payment_linkstringA link to the SQUAKE checkout page, returned with the payment method stripe.
pricestring or objectThe price used, as an ID or as an object with expand: ["price"].
productstring or objectThe product, as an ID or as an object with expand: ["product"].
valid_untilstring (date)The last day the pricing is valid.
currencystringCurrency of total.
totalintegerThe total price in the smallest unit of the currency. 2139 is 21.39 EUR.
itemsarrayThe emissions of each item, returned with expand: ["items"].

Calculations are stateless: SQUAKE returns no ID for the calculation itself. Store the carbon quantity, or the pricing ID, if you need it later. For the payment link parameters and the validity of a pricing, see Quote a price.

Errors

StatusMeaning
400The request is malformed or misses a required field.
401The API key is missing or invalid.

On this page

POST/v2/calculations-with-pricing

Run this request against the sandbox with your test key.

Open in API reference