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
itemsarrayrequiredThe activities to calculate, in the same format as POST /v2/calculations. See the calculation guides.
productstringrequiredThe ID of the product to price, such as product_2rsg35sfsdf.
currencystringThree-letter ISO 4217 currency code of the price.
carbon_unitstringUnit of the returned carbon quantities: tonne, kilogram or gram.
distance_unitstringUnit of the returned distances, such as kilometer.
payment_methodstringbatch_settlement to buy through the API, or stripe to receive a payment_link to the checkout page.
payment_link_return_urlstringWhere the checkout page sends your customer after a successful payment, if they're still in the browser.
expandarrayitems 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.
POST /v2/calculations-with-pricing in the API referenceThis 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.jsonResponse
{
"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"
}
]
}| Field | Type | Description |
|---|---|---|
id | string | The pricing token. Pass it as pricing to create a purchase. |
carbon_quantity | number | Total emissions of all items, in carbon_unit. |
carbon_unit | string | Unit of the carbon quantities. |
payment_link | string | A link to the SQUAKE checkout page, returned with the payment method stripe. |
price | string or object | The price used, as an ID or as an object with expand: ["price"]. |
product | string or object | The product, as an ID or as an object with expand: ["product"]. |
valid_until | string (date) | The last day the pricing is valid. |
currency | string | Currency of total. |
total | integer | The total price in the smallest unit of the currency. 2139 is 21.39 EUR. |
items | array | The 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
| Status | Meaning |
|---|---|
400 | The request is malformed or misses a required field. |
401 | The API key is missing or invalid. |
Related
- Quote a price
- Fulfillment with self-checkout
- Perform a Calculation including a Price Quote in the API reference