curl --request POST \
--url https://api.withflex.com/v1/checkout/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": {
"allow_promotion_codes": false,
"line_items": [
{
"price": "fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"price_data": {
"description": "Premium SPF 50 mineral sunscreen",
"unit_amount": 2500,
"recurring": {
"interval": "day",
"interval_count": 0,
"trial_period_days": 0
},
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"product": "fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"product_data": {
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"upc_code": "example_value",
"gtin": "example_value",
"reference_gtin": "example_value",
"url": "https://example.com",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"image_urls": [
"https://example.com/image.png"
],
"categories": [
"string"
],
"components": [
"string"
]
}
},
"quantity": 0,
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"tax_rate": {
"amount": 2500
},
"components": [
{
"quantity": 1,
"dressing_mode": "MIXED",
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "string"
}
]
}
],
"cancel_url": "https://example.com",
"capture_method": "automatic",
"client_reference_id": "example_value",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"discounts": [
{
"coupon_id": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"promo_code_id": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"coupon_data": {
"applies_to": {
"products": [
"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA"
]
},
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": {
"key": "value"
}
}
}
],
"mode": "payment",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"shipping_address_collection": false,
"subscription_data": {
"trial_end": "2026-06-15T14:30:00Z",
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": {
"missing_payment_method": "cancel"
}
}
},
"success_url": "https://example.com",
"tax_rate": {
"amount": 2500
},
"tax_calculation_mode": "exclusive",
"setup_future_use": "on_session",
"payment_method_options": {
"card": {
"request_three_d_secure": "automatic"
}
},
"payment_method": "fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "string",
"fees": [
{
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"amount": 2500,
"fee_type": "lmn_consultation"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": false,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
}
}
}
'import requests
url = "https://api.withflex.com/v1/checkout/sessions"
payload = { "checkout_session": {
"allow_promotion_codes": False,
"line_items": [
{
"price": "fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"price_data": {
"description": "Premium SPF 50 mineral sunscreen",
"unit_amount": 2500,
"recurring": {
"interval": "day",
"interval_count": 0,
"trial_period_days": 0
},
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"product": "fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"product_data": {
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"upc_code": "example_value",
"gtin": "example_value",
"reference_gtin": "example_value",
"url": "https://example.com",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"image_urls": ["https://example.com/image.png"],
"categories": ["string"],
"components": ["string"]
}
},
"quantity": 0,
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"tax_rate": { "amount": 2500 },
"components": [
{
"quantity": 1,
"dressing_mode": "MIXED",
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "string"
}
]
}
],
"cancel_url": "https://example.com",
"capture_method": "automatic",
"client_reference_id": "example_value",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"discounts": [
{
"coupon_id": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"promo_code_id": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"coupon_data": {
"applies_to": { "products": ["fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA"] },
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
}
}
],
"mode": "payment",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"shipping_address_collection": False,
"subscription_data": {
"trial_end": "2026-06-15T14:30:00Z",
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": False,
"trial_period_days": 0,
"trial_settings": { "end_behavior": { "missing_payment_method": "cancel" } }
},
"success_url": "https://example.com",
"tax_rate": { "amount": 2500 },
"tax_calculation_mode": "exclusive",
"setup_future_use": "on_session",
"payment_method_options": { "card": { "request_three_d_secure": "automatic" } },
"payment_method": "fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "string",
"fees": [
{
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"amount": 2500,
"fee_type": "lmn_consultation"
}
],
"custom_text": {
"after_submit": { "message": "Premium SPF 50 mineral sunscreen" },
"shipping_address": { "message": "Premium SPF 50 mineral sunscreen" },
"submit": { "message": "Premium SPF 50 mineral sunscreen" },
"terms_of_service_acceptance": { "message": "Premium SPF 50 mineral sunscreen" },
"terms_of_service_checkbox_required": False,
"payment": { "message": "Premium SPF 50 mineral sunscreen" }
}
} }
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: {
allow_promotion_codes: false,
line_items: [
{
price: 'fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
price_data: {
description: 'Premium SPF 50 mineral sunscreen',
unit_amount: 2500,
recurring: {interval: 'day', interval_count: 0, trial_period_days: 0},
metadata: {order_id: '8842', channel: 'shopify'},
product: 'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
product_data: {
name: 'Example',
description: 'Premium SPF 50 mineral sunscreen',
upc_code: 'example_value',
gtin: 'example_value',
reference_gtin: 'example_value',
url: 'https://example.com',
client_reference_id: 'example_value',
metadata: {order_id: '8842', channel: 'shopify'},
image_urls: ['https://example.com/image.png'],
categories: ['string'],
components: ['string']
}
},
quantity: 0,
shipping_options: {
shipping_rate_id: 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
shipping_rate_data: {
display_name: 'Example',
amount: 2500,
metadata: {order_id: '8842', channel: 'shopify'}
}
},
tax_rate: {amount: 2500},
components: [
{
quantity: 1,
dressing_mode: 'MIXED',
component_id: 'fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
client_reference_id: 'string'
}
]
}
],
cancel_url: 'https://example.com',
capture_method: 'automatic',
client_reference_id: 'example_value',
defaults: {
customer_id: 'fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
email: 'john.doe@example.com',
first_name: 'John',
last_name: 'Doe',
phone: '+14155550142'
},
discounts: [
{
coupon_id: 'fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
promo_code_id: 'fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
coupon_data: {
applies_to: {products: ['fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA']},
name: 'Coupon',
amount_off: 100,
duration: 'once',
percent_off: 10,
max_redemptions: 100,
metadata: {key: 'value'}
}
}
],
mode: 'payment',
metadata: {order_id: '8842', channel: 'shopify'},
shipping_options: {
shipping_rate_id: 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
shipping_rate_data: {
display_name: 'Example',
amount: 2500,
metadata: {order_id: '8842', channel: 'shopify'}
}
},
shipping_address_collection: false,
subscription_data: {
trial_end: '2026-06-15T14:30:00Z',
cancel_at: '2026-06-15T14:30:00Z',
cancel_at_period_end: false,
trial_period_days: 0,
trial_settings: {end_behavior: {missing_payment_method: 'cancel'}}
},
success_url: 'https://example.com',
tax_rate: {amount: 2500},
tax_calculation_mode: 'exclusive',
setup_future_use: 'on_session',
payment_method_options: {card: {request_three_d_secure: 'automatic'}},
payment_method: 'fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
customer: 'string',
fees: [
{
name: 'Example',
description: 'Premium SPF 50 mineral sunscreen',
amount: 2500,
fee_type: 'lmn_consultation'
}
],
custom_text: {
after_submit: {message: 'Premium SPF 50 mineral sunscreen'},
shipping_address: {message: 'Premium SPF 50 mineral sunscreen'},
submit: {message: 'Premium SPF 50 mineral sunscreen'},
terms_of_service_acceptance: {message: 'Premium SPF 50 mineral sunscreen'},
terms_of_service_checkbox_required: false,
payment: {message: 'Premium SPF 50 mineral sunscreen'}
}
}
})
};
fetch('https://api.withflex.com/v1/checkout/sessions', 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",
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' => [
'allow_promotion_codes' => false,
'line_items' => [
[
'price' => 'fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'price_data' => [
'description' => 'Premium SPF 50 mineral sunscreen',
'unit_amount' => 2500,
'recurring' => [
'interval' => 'day',
'interval_count' => 0,
'trial_period_days' => 0
],
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'product' => 'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'product_data' => [
'name' => 'Example',
'description' => 'Premium SPF 50 mineral sunscreen',
'upc_code' => 'example_value',
'gtin' => 'example_value',
'reference_gtin' => 'example_value',
'url' => 'https://example.com',
'client_reference_id' => 'example_value',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'image_urls' => [
'https://example.com/image.png'
],
'categories' => [
'string'
],
'components' => [
'string'
]
]
],
'quantity' => 0,
'shipping_options' => [
'shipping_rate_id' => 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'shipping_rate_data' => [
'display_name' => 'Example',
'amount' => 2500,
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
]
]
],
'tax_rate' => [
'amount' => 2500
],
'components' => [
[
'quantity' => 1,
'dressing_mode' => 'MIXED',
'component_id' => 'fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'client_reference_id' => 'string'
]
]
]
],
'cancel_url' => 'https://example.com',
'capture_method' => 'automatic',
'client_reference_id' => 'example_value',
'defaults' => [
'customer_id' => 'fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'email' => 'john.doe@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'phone' => '+14155550142'
],
'discounts' => [
[
'coupon_id' => 'fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'promo_code_id' => 'fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'coupon_data' => [
'applies_to' => [
'products' => [
'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA'
]
],
'name' => 'Coupon',
'amount_off' => 100,
'duration' => 'once',
'percent_off' => 10,
'max_redemptions' => 100,
'metadata' => [
'key' => 'value'
]
]
]
],
'mode' => 'payment',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'shipping_options' => [
'shipping_rate_id' => 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'shipping_rate_data' => [
'display_name' => 'Example',
'amount' => 2500,
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
]
]
],
'shipping_address_collection' => false,
'subscription_data' => [
'trial_end' => '2026-06-15T14:30:00Z',
'cancel_at' => '2026-06-15T14:30:00Z',
'cancel_at_period_end' => false,
'trial_period_days' => 0,
'trial_settings' => [
'end_behavior' => [
'missing_payment_method' => 'cancel'
]
]
],
'success_url' => 'https://example.com',
'tax_rate' => [
'amount' => 2500
],
'tax_calculation_mode' => 'exclusive',
'setup_future_use' => 'on_session',
'payment_method_options' => [
'card' => [
'request_three_d_secure' => 'automatic'
]
],
'payment_method' => 'fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'customer' => 'string',
'fees' => [
[
'name' => 'Example',
'description' => 'Premium SPF 50 mineral sunscreen',
'amount' => 2500,
'fee_type' => 'lmn_consultation'
]
],
'custom_text' => [
'after_submit' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'shipping_address' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'submit' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'terms_of_service_acceptance' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'terms_of_service_checkbox_required' => false,
'payment' => [
'message' => 'Premium SPF 50 mineral sunscreen'
]
]
]
]),
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"
payload := strings.NewReader("{\n \"checkout_session\": {\n \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": {\n \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/checkout/sessions")
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 \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\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": [
"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",
"payment_intents": [
"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",
"applied": true,
"waived_reason": "existing_letter"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": true,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
},
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription_data": {
"cancel_at": "2026-06-15T14:30:00Z",
"trial_end": "string",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": {
"missing_payment_method": "cancel"
}
}
},
"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": {
"discounts": [
{
"discount": {
"discount_id": "fdi_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"checkout_session": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"source": {
"coupon": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"type": "coupon"
},
"promo_code": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"test_mode": false,
"end": "string",
"start": "string"
}
}
]
}
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {
"card": {
"request_three_d_secure": "automatic"
}
},
"next_action": {
"type": "collect_letter_of_medical_necessity",
"collect_letter_of_medical_necessity": {
"url": "https://example.com"
},
"payment_failed": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"decline_code": "string",
"error_code": "string"
},
"provide_second_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"eligible_amount": 0,
"ineligible_amount": 0
},
"provide_alternative_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com"
}
},
"partner": "facct_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"platform_fees": {
"letter_fee": {
"amount": 2500,
"type": "string",
"status": "pending"
}
}
}
}{
"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"
}Create Checkout Session
Creates a Checkout Session. The response includes a hosted redirect_url where the
customer completes payment, along with the computed totals and eligibility. Flex
classifies the line items
for HSA/FSA eligibility and, when a Letter of Medical Necessity is required, sets up the
collection flow. The session’s mode determines whether it results in a one-time
payment, a subscription, an off-session charge against a saved payment method, or a
setup-only flow. When the line items mix eligible and non-eligible products, a split
cart is created so each portion can be paid with the appropriate payment method.
curl --request POST \
--url https://api.withflex.com/v1/checkout/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": {
"allow_promotion_codes": false,
"line_items": [
{
"price": "fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"price_data": {
"description": "Premium SPF 50 mineral sunscreen",
"unit_amount": 2500,
"recurring": {
"interval": "day",
"interval_count": 0,
"trial_period_days": 0
},
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"product": "fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"product_data": {
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"upc_code": "example_value",
"gtin": "example_value",
"reference_gtin": "example_value",
"url": "https://example.com",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"image_urls": [
"https://example.com/image.png"
],
"categories": [
"string"
],
"components": [
"string"
]
}
},
"quantity": 0,
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"tax_rate": {
"amount": 2500
},
"components": [
{
"quantity": 1,
"dressing_mode": "MIXED",
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "string"
}
]
}
],
"cancel_url": "https://example.com",
"capture_method": "automatic",
"client_reference_id": "example_value",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"discounts": [
{
"coupon_id": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"promo_code_id": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"coupon_data": {
"applies_to": {
"products": [
"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA"
]
},
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": {
"key": "value"
}
}
}
],
"mode": "payment",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"shipping_address_collection": false,
"subscription_data": {
"trial_end": "2026-06-15T14:30:00Z",
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": {
"missing_payment_method": "cancel"
}
}
},
"success_url": "https://example.com",
"tax_rate": {
"amount": 2500
},
"tax_calculation_mode": "exclusive",
"setup_future_use": "on_session",
"payment_method_options": {
"card": {
"request_three_d_secure": "automatic"
}
},
"payment_method": "fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "string",
"fees": [
{
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"amount": 2500,
"fee_type": "lmn_consultation"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": false,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
}
}
}
'import requests
url = "https://api.withflex.com/v1/checkout/sessions"
payload = { "checkout_session": {
"allow_promotion_codes": False,
"line_items": [
{
"price": "fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"price_data": {
"description": "Premium SPF 50 mineral sunscreen",
"unit_amount": 2500,
"recurring": {
"interval": "day",
"interval_count": 0,
"trial_period_days": 0
},
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"product": "fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"product_data": {
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"upc_code": "example_value",
"gtin": "example_value",
"reference_gtin": "example_value",
"url": "https://example.com",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"image_urls": ["https://example.com/image.png"],
"categories": ["string"],
"components": ["string"]
}
},
"quantity": 0,
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"tax_rate": { "amount": 2500 },
"components": [
{
"quantity": 1,
"dressing_mode": "MIXED",
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "string"
}
]
}
],
"cancel_url": "https://example.com",
"capture_method": "automatic",
"client_reference_id": "example_value",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"discounts": [
{
"coupon_id": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"promo_code_id": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"coupon_data": {
"applies_to": { "products": ["fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA"] },
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
}
}
],
"mode": "payment",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": {
"order_id": "8842",
"channel": "shopify"
}
}
},
"shipping_address_collection": False,
"subscription_data": {
"trial_end": "2026-06-15T14:30:00Z",
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": False,
"trial_period_days": 0,
"trial_settings": { "end_behavior": { "missing_payment_method": "cancel" } }
},
"success_url": "https://example.com",
"tax_rate": { "amount": 2500 },
"tax_calculation_mode": "exclusive",
"setup_future_use": "on_session",
"payment_method_options": { "card": { "request_three_d_secure": "automatic" } },
"payment_method": "fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "string",
"fees": [
{
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"amount": 2500,
"fee_type": "lmn_consultation"
}
],
"custom_text": {
"after_submit": { "message": "Premium SPF 50 mineral sunscreen" },
"shipping_address": { "message": "Premium SPF 50 mineral sunscreen" },
"submit": { "message": "Premium SPF 50 mineral sunscreen" },
"terms_of_service_acceptance": { "message": "Premium SPF 50 mineral sunscreen" },
"terms_of_service_checkbox_required": False,
"payment": { "message": "Premium SPF 50 mineral sunscreen" }
}
} }
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: {
allow_promotion_codes: false,
line_items: [
{
price: 'fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
price_data: {
description: 'Premium SPF 50 mineral sunscreen',
unit_amount: 2500,
recurring: {interval: 'day', interval_count: 0, trial_period_days: 0},
metadata: {order_id: '8842', channel: 'shopify'},
product: 'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
product_data: {
name: 'Example',
description: 'Premium SPF 50 mineral sunscreen',
upc_code: 'example_value',
gtin: 'example_value',
reference_gtin: 'example_value',
url: 'https://example.com',
client_reference_id: 'example_value',
metadata: {order_id: '8842', channel: 'shopify'},
image_urls: ['https://example.com/image.png'],
categories: ['string'],
components: ['string']
}
},
quantity: 0,
shipping_options: {
shipping_rate_id: 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
shipping_rate_data: {
display_name: 'Example',
amount: 2500,
metadata: {order_id: '8842', channel: 'shopify'}
}
},
tax_rate: {amount: 2500},
components: [
{
quantity: 1,
dressing_mode: 'MIXED',
component_id: 'fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
client_reference_id: 'string'
}
]
}
],
cancel_url: 'https://example.com',
capture_method: 'automatic',
client_reference_id: 'example_value',
defaults: {
customer_id: 'fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
email: 'john.doe@example.com',
first_name: 'John',
last_name: 'Doe',
phone: '+14155550142'
},
discounts: [
{
coupon_id: 'fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
promo_code_id: 'fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
coupon_data: {
applies_to: {products: ['fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA']},
name: 'Coupon',
amount_off: 100,
duration: 'once',
percent_off: 10,
max_redemptions: 100,
metadata: {key: 'value'}
}
}
],
mode: 'payment',
metadata: {order_id: '8842', channel: 'shopify'},
shipping_options: {
shipping_rate_id: 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
shipping_rate_data: {
display_name: 'Example',
amount: 2500,
metadata: {order_id: '8842', channel: 'shopify'}
}
},
shipping_address_collection: false,
subscription_data: {
trial_end: '2026-06-15T14:30:00Z',
cancel_at: '2026-06-15T14:30:00Z',
cancel_at_period_end: false,
trial_period_days: 0,
trial_settings: {end_behavior: {missing_payment_method: 'cancel'}}
},
success_url: 'https://example.com',
tax_rate: {amount: 2500},
tax_calculation_mode: 'exclusive',
setup_future_use: 'on_session',
payment_method_options: {card: {request_three_d_secure: 'automatic'}},
payment_method: 'fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
customer: 'string',
fees: [
{
name: 'Example',
description: 'Premium SPF 50 mineral sunscreen',
amount: 2500,
fee_type: 'lmn_consultation'
}
],
custom_text: {
after_submit: {message: 'Premium SPF 50 mineral sunscreen'},
shipping_address: {message: 'Premium SPF 50 mineral sunscreen'},
submit: {message: 'Premium SPF 50 mineral sunscreen'},
terms_of_service_acceptance: {message: 'Premium SPF 50 mineral sunscreen'},
terms_of_service_checkbox_required: false,
payment: {message: 'Premium SPF 50 mineral sunscreen'}
}
}
})
};
fetch('https://api.withflex.com/v1/checkout/sessions', 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",
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' => [
'allow_promotion_codes' => false,
'line_items' => [
[
'price' => 'fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'price_data' => [
'description' => 'Premium SPF 50 mineral sunscreen',
'unit_amount' => 2500,
'recurring' => [
'interval' => 'day',
'interval_count' => 0,
'trial_period_days' => 0
],
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'product' => 'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'product_data' => [
'name' => 'Example',
'description' => 'Premium SPF 50 mineral sunscreen',
'upc_code' => 'example_value',
'gtin' => 'example_value',
'reference_gtin' => 'example_value',
'url' => 'https://example.com',
'client_reference_id' => 'example_value',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'image_urls' => [
'https://example.com/image.png'
],
'categories' => [
'string'
],
'components' => [
'string'
]
]
],
'quantity' => 0,
'shipping_options' => [
'shipping_rate_id' => 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'shipping_rate_data' => [
'display_name' => 'Example',
'amount' => 2500,
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
]
]
],
'tax_rate' => [
'amount' => 2500
],
'components' => [
[
'quantity' => 1,
'dressing_mode' => 'MIXED',
'component_id' => 'fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'client_reference_id' => 'string'
]
]
]
],
'cancel_url' => 'https://example.com',
'capture_method' => 'automatic',
'client_reference_id' => 'example_value',
'defaults' => [
'customer_id' => 'fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'email' => 'john.doe@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'phone' => '+14155550142'
],
'discounts' => [
[
'coupon_id' => 'fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'promo_code_id' => 'fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'coupon_data' => [
'applies_to' => [
'products' => [
'fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA'
]
],
'name' => 'Coupon',
'amount_off' => 100,
'duration' => 'once',
'percent_off' => 10,
'max_redemptions' => 100,
'metadata' => [
'key' => 'value'
]
]
]
],
'mode' => 'payment',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'shipping_options' => [
'shipping_rate_id' => 'fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'shipping_rate_data' => [
'display_name' => 'Example',
'amount' => 2500,
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
]
]
],
'shipping_address_collection' => false,
'subscription_data' => [
'trial_end' => '2026-06-15T14:30:00Z',
'cancel_at' => '2026-06-15T14:30:00Z',
'cancel_at_period_end' => false,
'trial_period_days' => 0,
'trial_settings' => [
'end_behavior' => [
'missing_payment_method' => 'cancel'
]
]
],
'success_url' => 'https://example.com',
'tax_rate' => [
'amount' => 2500
],
'tax_calculation_mode' => 'exclusive',
'setup_future_use' => 'on_session',
'payment_method_options' => [
'card' => [
'request_three_d_secure' => 'automatic'
]
],
'payment_method' => 'fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA',
'customer' => 'string',
'fees' => [
[
'name' => 'Example',
'description' => 'Premium SPF 50 mineral sunscreen',
'amount' => 2500,
'fee_type' => 'lmn_consultation'
]
],
'custom_text' => [
'after_submit' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'shipping_address' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'submit' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'terms_of_service_acceptance' => [
'message' => 'Premium SPF 50 mineral sunscreen'
],
'terms_of_service_checkbox_required' => false,
'payment' => [
'message' => 'Premium SPF 50 mineral sunscreen'
]
]
]
]),
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"
payload := strings.NewReader("{\n \"checkout_session\": {\n \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": {\n \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/checkout/sessions")
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 \"allow_promotion_codes\": false,\n \"line_items\": [\n {\n \"price\": \"fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"price_data\": {\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"unit_amount\": 2500,\n \"recurring\": {\n \"interval\": \"day\",\n \"interval_count\": 0,\n \"trial_period_days\": 0\n },\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"product\": \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"product_data\": {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"upc_code\": \"example_value\",\n \"gtin\": \"example_value\",\n \"reference_gtin\": \"example_value\",\n \"url\": \"https://example.com\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"image_urls\": [\n \"https://example.com/image.png\"\n ],\n \"categories\": [\n \"string\"\n ],\n \"components\": [\n \"string\"\n ]\n }\n },\n \"quantity\": 0,\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"components\": [\n {\n \"quantity\": 1,\n \"dressing_mode\": \"MIXED\",\n \"component_id\": \"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"client_reference_id\": \"string\"\n }\n ]\n }\n ],\n \"cancel_url\": \"https://example.com\",\n \"capture_method\": \"automatic\",\n \"client_reference_id\": \"example_value\",\n \"defaults\": {\n \"customer_id\": \"fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"email\": \"john.doe@example.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone\": \"+14155550142\"\n },\n \"discounts\": [\n {\n \"coupon_id\": \"fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"promo_code_id\": \"fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"coupon_data\": {\n \"applies_to\": {\n \"products\": [\n \"fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA\"\n ]\n },\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n }\n ],\n \"mode\": \"payment\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"shipping_options\": {\n \"shipping_rate_id\": \"fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"shipping_rate_data\": {\n \"display_name\": \"Example\",\n \"amount\": 2500,\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n }\n }\n },\n \"shipping_address_collection\": false,\n \"subscription_data\": {\n \"trial_end\": \"2026-06-15T14:30:00Z\",\n \"cancel_at\": \"2026-06-15T14:30:00Z\",\n \"cancel_at_period_end\": false,\n \"trial_period_days\": 0,\n \"trial_settings\": {\n \"end_behavior\": {\n \"missing_payment_method\": \"cancel\"\n }\n }\n },\n \"success_url\": \"https://example.com\",\n \"tax_rate\": {\n \"amount\": 2500\n },\n \"tax_calculation_mode\": \"exclusive\",\n \"setup_future_use\": \"on_session\",\n \"payment_method_options\": {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n }\n },\n \"payment_method\": \"fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA\",\n \"customer\": \"string\",\n \"fees\": [\n {\n \"name\": \"Example\",\n \"description\": \"Premium SPF 50 mineral sunscreen\",\n \"amount\": 2500,\n \"fee_type\": \"lmn_consultation\"\n }\n ],\n \"custom_text\": {\n \"after_submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"shipping_address\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"submit\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_acceptance\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n },\n \"terms_of_service_checkbox_required\": false,\n \"payment\": {\n \"message\": \"Premium SPF 50 mineral sunscreen\"\n }\n }\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": [
"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",
"payment_intents": [
"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",
"applied": true,
"waived_reason": "existing_letter"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": true,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
},
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription_data": {
"cancel_at": "2026-06-15T14:30:00Z",
"trial_end": "string",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": {
"missing_payment_method": "cancel"
}
}
},
"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": {
"discounts": [
{
"discount": {
"discount_id": "fdi_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"checkout_session": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"source": {
"coupon": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"type": "coupon"
},
"promo_code": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"test_mode": false,
"end": "string",
"start": "string"
}
}
]
}
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {
"card": {
"request_three_d_secure": "automatic"
}
},
"next_action": {
"type": "collect_letter_of_medical_necessity",
"collect_letter_of_medical_necessity": {
"url": "https://example.com"
},
"payment_failed": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"decline_code": "string",
"error_code": "string"
},
"provide_second_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"eligible_amount": 0,
"ineligible_amount": 0
},
"provide_alternative_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com"
}
},
"partner": "facct_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"platform_fees": {
"letter_fee": {
"amount": 2500,
"type": "string",
"status": "pending"
}
}
}
}{
"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.
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
{
"allow_promotion_codes": false,
"line_items": [
{
"price": "fprice_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"price_data": {
"description": "Premium SPF 50 mineral sunscreen",
"unit_amount": 2500,
"recurring": {
"interval": "day",
"interval_count": 0,
"trial_period_days": 0
},
"metadata": { "order_id": "8842", "channel": "shopify" },
"product": "fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"product_data": {
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"upc_code": "example_value",
"gtin": "example_value",
"reference_gtin": "example_value",
"url": "https://example.com",
"client_reference_id": "example_value",
"metadata": { "order_id": "8842", "channel": "shopify" },
"image_urls": ["https://example.com/image.png"],
"categories": ["string"],
"components": ["string"]
}
},
"quantity": 0,
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": { "order_id": "8842", "channel": "shopify" }
}
},
"tax_rate": { "amount": 2500 },
"components": [
{
"quantity": 1,
"dressing_mode": "MIXED",
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"client_reference_id": "string"
}
]
}
],
"cancel_url": "https://example.com",
"capture_method": "automatic",
"client_reference_id": "example_value",
"defaults": {
"customer_id": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+14155550142"
},
"discounts": [
{
"coupon_id": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"promo_code_id": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"coupon_data": {
"applies_to": {
"products": ["fprod_01J9XR8M3K7VZ8N2YB4WJ6T0RA"]
},
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
}
}
],
"mode": "payment",
"metadata": { "order_id": "8842", "channel": "shopify" },
"shipping_options": {
"shipping_rate_id": "fshr_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"shipping_rate_data": {
"display_name": "Example",
"amount": 2500,
"metadata": { "order_id": "8842", "channel": "shopify" }
}
},
"shipping_address_collection": false,
"subscription_data": {
"trial_end": "2026-06-15T14:30:00Z",
"cancel_at": "2026-06-15T14:30:00Z",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": { "missing_payment_method": "cancel" }
}
},
"success_url": "https://example.com",
"tax_rate": { "amount": 2500 },
"tax_calculation_mode": "exclusive",
"setup_future_use": "on_session",
"payment_method_options": {
"card": { "request_three_d_secure": "automatic" }
},
"payment_method": "fpm_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "string",
"fees": [
{
"name": "Example",
"description": "Premium SPF 50 mineral sunscreen",
"amount": 2500,
"fee_type": "lmn_consultation"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": false,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
}
}
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",
"payment_intents": ["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",
"applied": true,
"waived_reason": "existing_letter"
}
],
"custom_text": {
"after_submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"shipping_address": {
"message": "Premium SPF 50 mineral sunscreen"
},
"submit": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_acceptance": {
"message": "Premium SPF 50 mineral sunscreen"
},
"terms_of_service_checkbox_required": true,
"payment": {
"message": "Premium SPF 50 mineral sunscreen"
}
},
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription_data": {
"cancel_at": "2026-06-15T14:30:00Z",
"trial_end": "string",
"cancel_at_period_end": false,
"trial_period_days": 0,
"trial_settings": {
"end_behavior": { "missing_payment_method": "cancel" }
}
},
"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": {
"discounts": [
{
"discount": {
"discount_id": "fdi_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"checkout_session": "fcs_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"customer": "fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"subscription": "fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"invoice": "fin_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"source": {
"coupon": "fcoup_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"type": "coupon"
},
"promo_code": "fpromo_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"test_mode": false,
"end": "string",
"start": "string"
}
}
]
}
},
"visit_type": "cbtSleep",
"setup_future_use": "on_session",
"payment_method_options": {
"card": { "request_three_d_secure": "automatic" }
},
"next_action": {
"type": "collect_letter_of_medical_necessity",
"collect_letter_of_medical_necessity": { "url": "https://example.com" },
"payment_failed": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"decline_code": "string",
"error_code": "string"
},
"provide_second_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com",
"eligible_amount": 0,
"ineligible_amount": 0
},
"provide_alternative_payment_method": {
"message": "Premium SPF 50 mineral sunscreen",
"url": "https://example.com"
}
},
"partner": "facct_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"platform_fees": {
"letter_fee": {
"amount": 2500,
"type": "string",
"status": "pending"
}
}
}