Retrieve a Purchase

GET /v2/purchases/{id}

Retrieve a purchase placed earlier. Useful to check for its state. To avoid short polling, you can register a webhook to stay informed about all your purchases automatically.

You can use the external_reference as ID as well for the lookup; i.e. your unique identifier.

Path parameters

  • id string Required

Query parameters

  • expand[] string

    Include e.g. "files" to retrieve files as a full object (defaults to just their IDs)

Responses

  • 200 application/json

    OK

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

    Hide response attributes Show response attributes object
    • id string Required

      Format should match the following pattern: purchase_[a-zA-Z0-9]*.

    • files array[string | object]

      Contains for example the certificate document if it was requested during the purchase.

      One of:

      Format should match the following pattern: file_[A-Za-z0-9]*.

    • 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.

      Values are batch_settlement or stripe. Default value is batch_settlement.

    • state string Required

      Values are reserved, confirmed, invoiced, settled, certificates_confirmed, certificates_retired, payment_initiated, canceled, voided, refunded, or 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.

      Additional properties are allowed.

    • Present if the payment method is stripe, meaning self-fulfillment by the customer on SQUAKEs payment page.

      Additional properties are allowed.

      Hide checkout_page attributes Show checkout_page attributes object
      • url string(uri)

        Send your customer to this URL to finalise the purchase. This link is not the stateless payment link, but bound to this purchase.

      • return_url string(uri)

        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".

      Values are tonne, kilogram, or gram.

    • total integer Required
    • currency string Required

      3-letter ISO 4217 alpha code of the currency.

      Minimum length is 3, maximum length is 3. Format should match the following pattern: ^[A-Z]{3}$. Values are 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, or ZAR. Default value is EUR.

    • Unique identifier from your system; used as idempotency when creating this resource.

  • 401 application/json

    Example response

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

      Format should match the following pattern: req_[a-zA-Z0-9-]+.

    Hide response attributes Show response attributes object
    • code string Required

      An application-specific error code, expressed as a string value.

      Values are field_validation_error, server_error, not_authorized, not_found, invalid_methodology, or invalid_type.

    • detail string

      A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.

    • source object

      An object containing references to the primary source of the error

      Additional properties are allowed.

      Hide source attributes Show source attributes object
  • 404 application/json

    Example response

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

    Hide response attributes Show response attributes object
    • code string Required

      An application-specific error code, expressed as a string value.

      Values are field_validation_error, server_error, not_authorized, not_found, invalid_methodology, or invalid_type.

    • detail string

      A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.

    • source object

      An object containing references to the primary source of the error

      Additional properties are allowed.

      Hide source attributes Show source attributes object
GET /v2/purchases/{id}
curl \
 -X GET https://api.sandbox.squake.earth/v2/purchases/{id} \
 -H "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
# Headers

# Payload
{
  "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": 42.0,
  "carbon_unit": "tonne",
  "total": 42,
  "currency": "EUR",
  "external_reference": "string"
}
Response examples (401)
# Headers
SQUAKE-Request-Id: req_70394c00-728e-4d70-90bc-2b589c9ebdf8

# Payload
[
  {
    "code": "field_validation_error",
    "detail": "string",
    "source": {
      "id": "string",
      "attribute": "string",
      "model": "string"
    }
  }
]
Response examples (404)
# Headers

# Payload
[
  {
    "code": "field_validation_error",
    "detail": "string",
    "source": {
      "id": "string",
      "attribute": "string",
      "model": "string"
    }
  }
]