curl --request POST \
--url https://api.withflex.com/v1/checkout/sessions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": {
"line_items": []
}
}
'import requests
url = "https://api.withflex.com/v1/checkout/sessions/{id}/refund"
payload = { "checkout_session": { "line_items": [] } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({checkout_session: {line_items: []}})
};
fetch('https://api.withflex.com/v1/checkout/sessions/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withflex.com/v1/checkout/sessions/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'checkout_session' => [
'line_items' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withflex.com/v1/checkout/sessions/{id}/refund"
payload := strings.NewReader("{\n \"checkout_session\": {\n \"line_items\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.withflex.com/v1/checkout/sessions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": {\n \"line_items\": []\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/checkout/sessions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"checkout_session\": {\n \"line_items\": []\n }\n}"
response = http.request(request)
puts response.read_body{
"checkout_session": {
"allow_promotion_codes": false,
"amount_total": 2500,
"amount_subtotal": 2500,
"amount_received": 2500,
"amount_refunded": 2500,
"amount_disputed": 2500,
"cancel_url": "https://example.com",
"captures": [],
"disputes": [],
"capture_method": "automatic",
"checkout_session_id": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "example_value",
"created_at": 2500,
"defaults": {},
"expires_at": 2500,
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"hsa_fsa_eligible": false,
"letter_of_medical_necessity_required": false,
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"mode": "payment",
"origin": "shopify",
"redirect_url": "https://example.com",
"refunds": [],
"setup_intent": "fseti_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_options": {},
"shipping_address_collection": false,
"shipping_details": {},
"status": "open",
"success_url": "https://example.com",
"fees": [
{}
],
"custom_text": {},
"subscription_data": {},
"tax_rate": {},
"tax_calculation_mode": "exclusive",
"test_mode": false,
"total_details": {
"amount_discount": 2500,
"amount_tax": 2500,
"amount_shipping": 2500,
"amount_iias": 2500,
"amount_vision": 2500,
"amount_prescription": 2500,
"amount_service": 2500,
"amount_fee": 2500
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {},
"platform_fees": {}
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Refund Checkout Session
Refunds a captured Checkout Session, in whole or in part. Refund a total amount,
specific line_items, or omit both to refund the full remaining amount; component
amounts (tax, shipping, discount) can be supplied for accurate allocation. For split
carts the refund is allocated across the eligible and non-eligible payment intents based
on HSA/FSA eligibility; the explicit payment_methods allocation is gated behind a
beta feature that must be enabled for your account. Use the refund allocation
preview endpoint to inspect the split before refunding. A
checkout.session.refunded event is emitted.
curl --request POST \
--url https://api.withflex.com/v1/checkout/sessions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": {
"line_items": []
}
}
'import requests
url = "https://api.withflex.com/v1/checkout/sessions/{id}/refund"
payload = { "checkout_session": { "line_items": [] } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({checkout_session: {line_items: []}})
};
fetch('https://api.withflex.com/v1/checkout/sessions/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withflex.com/v1/checkout/sessions/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'checkout_session' => [
'line_items' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withflex.com/v1/checkout/sessions/{id}/refund"
payload := strings.NewReader("{\n \"checkout_session\": {\n \"line_items\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.withflex.com/v1/checkout/sessions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": {\n \"line_items\": []\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/checkout/sessions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"checkout_session\": {\n \"line_items\": []\n }\n}"
response = http.request(request)
puts response.read_body{
"checkout_session": {
"allow_promotion_codes": false,
"amount_total": 2500,
"amount_subtotal": 2500,
"amount_received": 2500,
"amount_refunded": 2500,
"amount_disputed": 2500,
"cancel_url": "https://example.com",
"captures": [],
"disputes": [],
"capture_method": "automatic",
"checkout_session_id": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "example_value",
"created_at": 2500,
"defaults": {},
"expires_at": 2500,
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"hsa_fsa_eligible": false,
"letter_of_medical_necessity_required": false,
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"mode": "payment",
"origin": "shopify",
"redirect_url": "https://example.com",
"refunds": [],
"setup_intent": "fseti_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_options": {},
"shipping_address_collection": false,
"shipping_details": {},
"status": "open",
"success_url": "https://example.com",
"fees": [
{}
],
"custom_text": {},
"subscription_data": {},
"tax_rate": {},
"tax_calculation_mode": "exclusive",
"test_mode": false,
"total_details": {
"amount_discount": 2500,
"amount_tax": 2500,
"amount_shipping": 2500,
"amount_iias": 2500,
"amount_vision": 2500,
"amount_prescription": 2500,
"amount_service": 2500,
"amount_fee": 2500
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {},
"platform_fees": {}
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Authorizations
Use a Bearer token to access this API.
Path Parameters
"fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA"
Query Parameters
Comma-separated list of related objects to expand in the response.
""
Body
An envelope wrapping a single checkout session object.
An envelope wrapping a single checkout session object.
The checkout session payload.
Show child attributes
Show child attributes
{ "line_items": [{}] }
Response
An envelope wrapping a single checkout session object.
An envelope wrapping a single checkout session object.
The checkout session payload.
Show child attributes
Show child attributes
{
"allow_promotion_codes": false,
"amount_total": 2500,
"amount_subtotal": 2500,
"amount_received": 2500,
"amount_refunded": 2500,
"amount_disputed": 2500,
"cancel_url": "https://example.com",
"captures": ["fcap_01J9XR8M3K7VZ8N2YB4WJ6T0RA"],
"disputes": ["fdp_01J9XR8M3K7VZ8N2YB4WJ6T0RA"],
"capture_method": "automatic",
"checkout_session_id": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "example_value",
"created_at": 2500,
"customer": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"expires_at": 2500,
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"hsa_fsa_eligible": false,
"letter_of_medical_necessity_required": false,
"metadata": { "order_id": "8842", "channel": "shopify" },
"mode": "payment",
"origin": "shopify",
"payment_intent": "fpi_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"redirect_url": "https://example.com",
"refunds": ["fre_01J9XR8M3K7VZ8N2YB4WJ6T0RA"],
"setup_intent": "fseti_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_amount": 2500,
"display_name": "Example"
},
"shipping_address_collection": false,
"shipping_details": {
"shipping_address_id": "fsh_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"line1": "123 Main St",
"line2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"postal_code": "94107",
"country": "US"
},
"split_cart": "fsplit_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"status": "open",
"success_url": "https://example.com",
"fees": [
{
"fee_id": "ffee_1234567890",
"amount": 2500,
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"fee_type": "lmn_consultation"
}
],
"custom_text": {},
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription_data": {
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": false
},
"tax_rate": { "amount": 2500 },
"tax_calculation_mode": "exclusive",
"test_mode": false,
"total_details": {
"amount_discount": 2500,
"amount_tax": 2500,
"amount_shipping": 2500,
"amount_iias": 2500,
"amount_vision": 2500,
"amount_prescription": 2500,
"amount_service": 2500,
"amount_fee": 2500,
"breakdown": {}
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {},
"next_action": {
"type": "collect_letter_of_medical_necessity"
},
"partner": "facct_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"platform_fees": { "letter_fee": {} }
}