Quote a price
Get a price and a pricing ID for a carbon quantity or a fixed amount of money.
Returns the price of a product for a carbon quantity, or the carbon quantity a fixed amount of money buys. The response holds a pricing ID that you pass to Create a purchase. With the payment method stripe, it also holds a payment_link to the SQUAKE checkout page.
This endpoint is fast and creates no obligation, so you can use it to show a price before anyone buys.
Request
GET /v2/pricing
Send either carbon_quantity with carbon_unit, or fixed_total.
productstringThe ID of the product to price, such as product_2rsg35sfsdf.
carbon_quantitynumberThe quantity of carbon to price.
carbon_unitstringUnit of carbon_quantity: tonne, kilogram or gram.
fixed_totalintegerA fixed amount of money to spend, in the smallest unit of currency: 1234 with EUR means 12.34 EUR.
currencystringThree-letter ISO 4217 currency code.
expand[]arrayproduct or price to receive the full object instead of its ID.
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.
GET /v2/pricing in the API referencecurl -G "https://api.sandbox.squake.earth/v2/pricing" \
--header "Authorization: Bearer $SQUAKE_API_KEY" \
--data-urlencode "product=product_2rsg35sfsdf" \
--data-urlencode "carbon_quantity=0.123" \
--data-urlencode "carbon_unit=tonne" \
--data-urlencode "expand[]=price"Response
The response to the carbon quantity request, with the price expanded:
{
"id": "eyJhbGciOiJIUzI1NiJ9.eyJwIjoicHJpY2VfMU1Ncm9MMmVaIn0...",
"price": {
"id": "price_1MMroL2eZvKYlo2CxbxAACvb",
"product": "product_2rsg35sfsdf",
"unit_amount": 15000,
"carbon_unit": "tonne",
"currency": "EUR"
},
"product": "product_2rsg35sfsdf",
"valid_until": "2026-11-24",
"carbon_quantity": 0.123,
"carbon_unit": "tonne",
"currency": "EUR",
"total": 1845
}| Field | Type | Description |
|---|---|---|
id | string | The pricing token. Pass it as pricing to create a purchase. |
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, with expand[]=price, as an object. |
product | string or object | The product, as an ID or, with expand[]=product, as an object. |
valid_until | string (date) | The last day the pricing is valid. |
carbon_quantity | number | The carbon quantity the pricing covers. |
carbon_unit | string | Unit of carbon_quantity. |
currency | string | Currency of total. |
total | integer | The total price in the smallest unit of the currency. 1845 is 18.45 EUR. |
Here, 0.123 tonnes at 150.00 EUR per tonne cost 18.45 EUR.
Payment links
With payment_method=stripe, the response includes a payment_link:
{
"id": "eyJhbGciOiJIUzI1NiJ9.eyJwIjoicHJpY2VfMU1Ncm9MMmVaIn0...",
"payment_link": "https://checkout.squake.earth/?t=eyJhbGciOiJIUzI1NiJ9.eyJwIjoicHJpY2VfMU1Ncm9MMmVaIn0...",
"price": "price_1MMroL2eZvKYlo2CxbxAACvb",
"product": "product_2rsg35sfsdf",
"valid_until": "2026-11-24",
"carbon_quantity": 0.123,
"carbon_unit": "tonne",
"currency": "EUR",
"total": 1845
}Send your customer to the link to pay on the SQUAKE checkout page. You can append parameters to it:
locale, a two-letter ISO 639-1 language code such as&locale=de, sets the language of the checkout page.- Any
utm_*tracking parameter, such as&utm_medium=email. external_reference, which SQUAKE sends back to you in theorderwebhook. See Webhooks.
The same link works for repeated purchases.
Validity
A pricing is valid for two weeks from the moment you request it, until valid_until. After that, you can still use it as long as the underlying price hasn't changed. One pricing can back many purchases, so you can fetch one pricing per product and quantity and show it to every customer while it's valid.
Errors
| Status | Meaning |
|---|---|
400 | The request is invalid, for example because it has neither carbon_quantity with carbon_unit nor fixed_total. |
401 | The API key is missing or invalid. |
Related
- Create a purchase
- Calculate and price in one request
- Quote a Pricing in the API reference