# Cancel a Purchase A purchase can be canceled as long as it is not confirmed; this is in the state . After the cancelation period passes, the purchase transitions to . Confirmed purchases go to the batch settlement. Endpoint: POST /v2/purchases/{id}/cancel Security: Bearer-Auth ## Path parameters: - `id` (string, required) ## Response 200 fields (application/json): - `id` (string, required) - `files` (array) Contains for example the certificate document if it was requested during the purchase. - `payment_method` (string, required) Mode 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. Enum: "batch_settlement", "stripe" - `state` (string, required) Enum: "reserved", "confirmed", "invoiced", "settled", "certificates_confirmed", "certificates_retired", "payment_initiated", "canceled", "voided", "refunded", "payment_aborted" - `metadata` (object) A set of key-value pairs of yours that helps you link this record in your system. Never displayed to users. - `checkout_page` (object) Present if the payment method is , meaning self-fulfillment by the customer on SQUAKEs payment page. - `checkout_page.url` (string) Send your customer to this URL to finalise the purchase. This link is not the stateless payment link, but bound to this purchase. - `checkout_page.return_url` (string) If the customer does not exit the browser after the purchase, on success, SQUAKE will redirect the customer to this link. - `carbon_quantity` (number, required) - `carbon_unit` (string, required) SQUAKE uses The International System of Units (SI), commonly referred to as "metric system". Enum: "tonne", "kilogram", "gram" - `total` (integer, required) - `currency` (string, required) 3-letter ISO 4217 alpha code of the currency. Enum: "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` (string) Unique identifier from your system; used as idempotency when creating this resource. - `cancellable_until` (string) The date until which purchase can be cancelled Example: "2025-01-01T15:00:00+00:00" ## Response 400 fields (application/json): - `errors` (array) - `errors.code` (string, required) An application-specific error code, expressed as a string value. Enum: "field_validation_error", "server_error", "not_authorized", "not_found", "invalid_methodology", "invalid_type" - `errors.detail` (string) A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. - `errors.source` (object) An object containing references to the primary source of the error - `errors.source.id` (string) - `errors.source.attribute` (string, required) - `errors.source.model` (string) ## Response 401 fields (application/json): - `errors` (array) - `errors.code` (string, required) An application-specific error code, expressed as a string value. Enum: "field_validation_error", "server_error", "not_authorized", "not_found", "invalid_methodology", "invalid_type" - `errors.detail` (string) A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. - `errors.source` (object) An object containing references to the primary source of the error - `errors.source.id` (string) - `errors.source.attribute` (string, required) - `errors.source.model` (string) ## Response 403 fields (application/json): - `errors` (array) - `errors.code` (string, required) An application-specific error code, expressed as a string value. Enum: "field_validation_error", "server_error", "not_authorized", "not_found", "invalid_methodology", "invalid_type" - `errors.detail` (string) A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. - `errors.source` (object) An object containing references to the primary source of the error - `errors.source.id` (string) - `errors.source.attribute` (string, required) - `errors.source.model` (string) ## Response 404 fields (application/json): - `errors` (array) - `errors.code` (string, required) An application-specific error code, expressed as a string value. Enum: "field_validation_error", "server_error", "not_authorized", "not_found", "invalid_methodology", "invalid_type" - `errors.detail` (string) A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. - `errors.source` (object) An object containing references to the primary source of the error - `errors.source.id` (string) - `errors.source.attribute` (string, required) - `errors.source.model` (string)