Pricing and purchases
Quote a price for carbon credits, buy them through the API or the SQUAKE checkout page, and track each purchase.
These endpoints turn an emissions figure into a compensation: you quote a price for a product, buy it, and follow the purchase until the certificates are retired.
How a purchase works
- Know the emissions to compensate. Calculate them with the Calculations API, or use any carbon quantity you have.
- Pick a product.
- Quote a price with Quote a price, or calculate and quote in one request with Calculate and price in one request.
- Buy the credits, in one of two ways:
- Through the API, with the payment method
batch_settlement. You create the purchase with the pricing ID, and SQUAKE invoices you regularly for a batch of purchases. - Through the SQUAKE checkout page, with the payment method
stripe. Your customer pays on the page behind thepayment_link, and SQUAKE is the merchant of record. See Fulfillment with self-checkout.
- Through the API, with the payment method
- Track the purchase with Retrieve a purchase, or let SQUAKE notify you with webhooks.
- Download the confirmation and certificate documents with Retrieve a file.
Pricing tokens
A pricing is a token that encodes a product, a carbon quantity or fixed amount, and a price.
- A pricing is valid for two weeks from the moment you request it. An expired pricing still works as long as the underlying price hasn't changed.
- You can use one pricing for many purchases. Requests for the same product and quantity can return the same pricing ID.
- To make retries safe, send an
external_referencewith each purchase. A retried call with the sameexternal_referencedoesn't register a second purchase.
Purchase states
Purchases made through the API go through these states:
| State | Meaning |
|---|---|
reserved | SQUAKE registered the purchase and reserved the carbon credits. You can cancel it for 14 days. |
canceled | The purchase was canceled while it was reserved. Final state. |
confirmed | The cancellation period has passed. The API can no longer cancel the purchase. |
invoiced | SQUAKE invoiced the purchase after the grace period. |
Purchases made on the checkout page go through these states:
| State | Meaning |
|---|---|
payment_initiated | The customer started the payment flow on the checkout page. |
payment_aborted | The payment failed for good, for example because the customer left the page and didn't come back before the pricing expired. Final state. |
confirmed | The payment provider reported a successful payment. The purchase moves on to settled right away. |
Both kinds of purchase can reach these states:
| State | Meaning |
|---|---|
settled | SQUAKE received the payment. |
refunded | A refund was processed. Final state. |
certificates_confirmed | All project partners confirmed the certificates for the purchase's carbon credits. |
certificates_retired | All certificates were retired in their registries. Final state. |
The state field can also be voided.
Guides
| Task | Endpoint | Guide |
|---|---|---|
| Quote a price for a quantity or an amount | GET /v2/pricing | Quote a price |
| Calculate emissions and quote a price together | POST /v2/calculations-with-pricing | Calculate and price in one request |
| Buy credits | POST /v2/purchases | Create a purchase |
| Check a purchase | GET /v2/purchases/{id} | Retrieve a purchase |
| Change document details or metadata | PATCH /v2/purchases/{id} | Update a purchase |
| Cancel a reserved purchase | POST /v2/purchases/{id}/cancel | Cancel a purchase |
| Download a confirmation or certificate | GET /v2/files/{id} | Retrieve a file |