---
title: "Preview Refund Allocation"
method: POST
path: "/v1/checkout/sessions/{id}/refund_allocation"
tags: ["Checkout Sessions"]
---

# Preview Refund Allocation

`POST /v1/checkout/sessions/{id}/refund_allocation`

Computes how a refund would be allocated across the Checkout Session's payment methods,
without executing any refund. Takes the same request body as the refund endpoint and
returns the per-payment-method allocations so you can preview a split-cart refund before
committing.

## Path parameters

- `id` string, required

## Request body

- CheckoutSessionBodyForRefundCheckoutSessionRequest — An envelope wrapping a single checkout session object.
  - `checkout_session` RefundCheckoutSessionRequest, required — Parameters for refunding a Checkout Session. Specify what to refund either by `line_items` or by a total `amount`; omit both to refund the full remaining amount.
    - `refund_metadata` object, nullable — Set of key-value pairs to set on the Checkout Session's `metadata` when the refund succeeds. `null` to leave the session metadata unchanged.
    - `amount_tax` integer, nullable — Portion of the refund attributable to tax, in the smallest currency unit (e.g., `175` = $1.75 USD).
    - `amount_shipping` integer, nullable — Portion of the refund attributable to shipping, in the smallest currency unit (e.g., `599` = $5.99 USD).
    - `amount_discount` integer, nullable — Portion of the refund attributable to discounts, in the smallest currency unit (e.g., `500` = $5.00 USD).
    - `payment_methods` PaymentMethodRefundRequest[], nullable — Explicit allocation to specific payment methods. When provided, bypasses automatic HSA-based allocation and refunds exact amounts to each payment method. This feature is currently in beta. Contact the Flex team to request access.
      - `payment_method_id` string, required — ID of the PaymentMethod to refund to.
      - `amount` integer, required — Amount to refund to this payment method, in the smallest currency unit (e.g., `2500` = $25.00 USD). Must be non-negative.
    - `line_items` LineItemRefundRequest[] — The line items to refund, with the amount to refund for each.
      - `amount_to_refund` integer, nullable — The amount to refund for this line item, in the smallest currency unit (e.g., `2500` = $25.00 USD). Omit to refund the full amount for the item.
      - `product` string — ID of the Product identifying the line item.
      - `price` string — ID of the Price identifying the line item.
    - `amount` integer — The total amount to refund, in the smallest currency unit (e.g., `2500` = $25.00 USD).

## Response `200`

Preview of how a refund would be distributed across the session's payment methods.

- RefundAllocationResponse — Preview of how a refund would be distributed across the session's payment methods.
  - `allocations` RefundAllocation[], required — The computed refund amount allocated to each payment method. No refund is executed.
    - `payment_method_id` string, required — ID of the PaymentMethod this portion of the refund would be returned to.
    - `last4` string, required — Last four digits of the payment method's card, for display. Falls back to `"unknown"` if it cannot be resolved.
    - `amount` integer, required — Amount that would be refunded to this payment method, in the smallest currency unit (e.g., `2500` = $25.00 USD).

## Other responses

- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `409` — Conflict
- `422` — Validation Error
- `429` — Too Many Requests

---

[API](https://skmtc.dev/withflex/apis/flex-api.md) · [All operations](https://skmtc.dev/withflex/apis/flex-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/withflex/flex-api/revisions/b1560fc2f199/schema)
