Create a Purchase
You can register a purchase programmatically to compensate for carbon emissions on this endpoint. You must quote for pricing beforehand and pass the returned pricing ID as a parameter.
Alternatively, you can use the payment_link from the pricing endpoint to
finalize the purchase using SQUAKE's provided checkout page.
Lifecycle
When purchasing via API (this endpoint)
-
reserved: A successful purchase starts in the state "reserved"; SQUAKE registered your purchase and reserved carbon credits accordingly.
-
canceled: SQUAKE offers 14 days to cancel a purchase worry-free. This is a terminal state.
-
confirmed: The refundable period has passed. If you need to cancel the purchase beyond this point, please request a refund on the refunds endpoint.
-
invoiced: Without further action, a purchase is invoiced after the grace period and transitions to "invoiced".
When purchasing via the checkout page
-
payment_initiated: the end customer entered the payment flow on the checkout page
-
payment_aborted: the payment failed permanently, for example, because the customer exited the page without finalizing the payment and didn''t return before the pricing''s validity ended. This is a terminal state.
-
confirmed: the payment provider informed SQUAKE about the successful payment. In this flow, this state exists only for a short time; the purchase immediately continues to "settled".
Both
-
settled: SQUAKE has received the payment.
-
refunded: a refund request was successfully processed. This is a terminal state.
-
certificates_confirmed: all certificates for the carbon credits have been confirmed from all project partners related to the purchase.
-
certificates_retired: all certificates have been retired in the corresponding registries. This is a terminal state.
Bearer-AuthAuthorizationBearer <token>application/json- body
pricing*stringThe ID from the pricing endpoint
confirmation_document?certificate_document?expand?array<"files">Receive either the file-id, or the file-object of a requested document. If omitted, only IDs are returned.
metadata?A set of key-value pairs of yours that helps you link this record in your system. Never displayed to users.
external_reference?stringIf given, this reference must be unique. Suppose you need idempotency on the purchase endpoint: in that case, the external reference must be provided, meaning you can retry a purchase call with the same pricing id multiple times without registering multiple purchases, e.g., to recover from a network failure. Remember: with a valid pricing id, you can register as many purchases as you need. The reference should have enough entropy; a great choice is a V4 UUID.
Created
application/json- response
id*stringpurchase_[a-zA-Z0-9]*files?array<|>Contains for example the certificate document if it was requested during the purchase.
payment_method*Payment-MethodMode of payment. The batch settlement means SQUAKE will invoice you regularly for a batch of purchases. The checkout page is SQUAKEs self-fulfillment solution where end-customers can purchase a product directly from SQUAKE as the merchant of record.
"batch_settlement""batch_settlement""stripe"state*Purchase State"reserved""confirmed""invoiced""settled""certificates_confirmed""certificates_retired""payment_initiated""canceled""voided""refunded""payment_aborted"metadata?A set of key-value pairs of yours that helps you link this record in your system. Never displayed to users.
checkout_page?Present if the payment method is stripe, meaning self-fulfillment by the customer on SQUAKEs payment page.
carbon_quantity*numbercarbon_unit*Carbon UnitSQUAKE uses The International System of Units (SI), commonly referred to as "metric system".
"tonne""kilogram""gram"total*integercurrency*Currency3-letter ISO 4217 alpha code of the currency.
^[A-Z]{3}$3 <= length <= 3"EUR""AED""AMD""ARS""AUD""AZN""BAM""BGN""BHD""BRL""CAD""CHF""CLP""CNY""COP""CRC""CZK""DKK""DZD""EGP""ETB""EUR""GBP""GEL""HKD""HUF""IDR""INR""ISK""JMD""JOD""JPY""KES""KRW""KWD""KZT""LKR""LYD""MAD""MUR""MXN""MYR""NOK""NZD""OMR""PHP""PKR""PLN""QAR""RSD""RUB""SAR""SEK""SGD""SYP""THB""TND""TRY""TTD""TWD""UAH""USD""VND""XAF""XOF""ZAR"external_reference?stringUnique identifier from your system; used as idempotency when creating this resource.
cancellable_until?stringThe date until which purchase can be cancelled
date-timecurl -X POST 'https://api.sandbox.squake.earth/v2/purchases' \ -H 'Content-Type: application/json' \ -d '{ "pricing": "string"}'{ "id": "purchase_sd234asdfl23", "files": [ "file_34sdfgJH9df4g35" ], "payment_method": "batch_settlement", "state": "reserved", "metadata": {}, "checkout_page": { "url": "https://checkout.squake.earth", "return_url": "https://example.com" }, "carbon_quantity": 0, "carbon_unit": "tonne", "total": 0, "currency": "EUR", "external_reference": "string", "cancellable_until": "2019-08-24T14:15:22Z"}Cancel a Purchase
A purchase can be canceled as long as it is not confirmed; this is in the state `reserved`. After the cancelation period passes, the purchase transitions to `confirmed`. Confirmed purchases go to the batch settlement.
Delete a Travel Data Trip
Deletes a trip and everything hanging off it: all of its activities — routing legs included — and their calculations. Responds with `204` and an empty body. **Audit logs are kept.** They are an immutable record of what was calculated, so deleting a trip does not remove the audit logs its calculations produced. **Reporting lags a delete.** Dashboards and reporting views are refreshed periodically, so a deleted trip can still appear in them until the next refresh. This cannot be undone — re-submit the trip to `POST /v2/travel-data` to restore it, which recalculates its emissions and creates new IDs. A trip you cannot access responds with `404` and error code `travel_data_not_found`, and nothing is deleted.