Skip to main content
POST
/
v2
/
checkout
Create Checkout Session
curl --request POST \
  --url https://api.example.com/v2/checkout

Create Checkout Session

Create a checkout session for a customer. Returns a checkout URL where the customer completes payment on Gale’s hosted page. Gale handles card collection, eligibility detection, and LMN flow automatically.
All monetary amounts are integers in cents (e.g., 4995 = $49.95).

Endpoint

POST /v2/checkout

Authentication

Authorization: Bearer glm_test_YOUR_API_KEY

Request Body

{
  "reference_id": "your-order-123",
  "customer": {
    "email": "jane@example.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "phone": "+1-555-123-4567"
  },
  "line_items": [
    {
      "product_id": "BP-MONITOR-001",
      "name": "Digital Blood Pressure Monitor",
      "image_url": "https://yourcdn.com/bp-monitor.jpg",
      "price": 4995,
      "quantity": 1,
      "currency": "USD"
    },
    {
      "product_id": "VITAMINS-030",
      "name": "Daily Multivitamins (30-day)",
      "image_url": "https://yourcdn.com/vitamins.jpg",
      "price": 1999,
      "quantity": 2,
      "currency": "USD"
    }
  ],
  "shipping_info": {
    "address_line_1": "123 Main St",
    "address_line_2": "Apt 4B",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "US"
  },
  "billing_info": {
    "address_line_1": "123 Main St",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "US"
  },
  "shipping": 500,
  "tax": 410,
  "discount": 0,
  "success_url": "https://yoursite.com/order/success",
  "failure_url": "https://yoursite.com/order/failed",
  "metadata": {
    "platform": "CUSTOM",
    "webhook_url": "https://your-server.com/webhooks/gale"
  }
}

Parameters

ParameterTypeRequiredDescription
reference_idstringYesYour order or cart ID for correlation
customerobjectYesCustomer information
customer.emailstringYesCustomer email
customer.first_namestringYesCustomer first name
customer.last_namestringYesCustomer last name
customer.phonestringNoCustomer phone number
line_itemsarrayYesProducts being purchased
line_items[].product_idstringYesYour product ID (must match synced product)
line_items[].namestringYesProduct name
line_items[].image_urlstringNoProduct image URL
line_items[].priceintegerYesUnit price in cents
line_items[].quantityintegerYesQuantity
line_items[].currencystringYesCurrency code (e.g., "USD")
shipping_infoobjectYesShipping address
shipping_info.address_line_1stringYesAddress line 1
shipping_info.address_line_2stringNoAddress line 2
shipping_info.citystringYesCity
shipping_info.statestringYesState
shipping_info.postal_codestringYesZIP/Postal code
shipping_info.countrystringYesCountry code (e.g., "US")
billing_infoobjectNoBilling address (defaults to shipping if omitted)
billing_info.address_line_1stringYesAddress line 1
billing_info.address_line_2stringNoAddress line 2
billing_info.citystringYesCity
billing_info.statestringYesState
billing_info.postal_codestringYesZIP/Postal code
billing_info.countrystringYesCountry code (e.g., "US")
shippingintegerNoShipping amount in cents
taxintegerNoTax amount in cents
discountintegerNoDiscount amount in cents
success_urlstringYesRedirect URL after successful payment
failure_urlstringYesRedirect URL if payment fails or customer cancels
metadataobjectNoCustom key-value pairs
metadata.webhook_urlstringNoURL to receive payment webhooks (recommended)

Response

{
  "success": true,
  "checkout_id": "01HXYZ...",
  "checkout_url": "https://checkout.withgale.com/checkout/01HXYZ...",
  "status": "open",
  "expires_at": "2026-02-26T14:30:00Z"
}
FieldTypeDescription
checkout_idstringUnique checkout session identifier
checkout_urlstringHosted checkout page URL — redirect customer here
statusstringSession status (open)
expires_attimestampWhen session expires (24 hours)

Example

curl -X POST https://api.withgale.com/v2/checkout \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "order-789",
    "customer": {
      "email": "jane@example.com",
      "first_name": "Jane",
      "last_name": "Doe"
    },
    "line_items": [
      {
        "product_id": "BP-MONITOR-001",
        "name": "Digital Blood Pressure Monitor",
        "price": 4995,
        "quantity": 1,
        "currency": "USD"
      }
    ],
    "shipping_info": {
      "address_line_1": "123 Main St",
      "city": "New York",
      "state": "NY",
      "postal_code": "10001",
      "country": "US"
    },
    "shipping": 500,
    "tax": 410,
    "success_url": "https://yoursite.com/order/success",
    "failure_url": "https://yoursite.com/order/failed"
  }'

Subscription Checkout Beta

curl -X POST https://api.withgale.com/v2/checkout \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "membership-456",
    "customer": {
      "email": "member@example.com",
      "first_name": "Jane",
      "last_name": "Doe"
    },
    "line_items": [
      {
        "product_id": "MEMBERSHIP-PREMIUM",
        "name": "Premium Membership",
        "price": 9900,
        "quantity": 1,
        "currency": "USD"
      }
    ],
    "payment_type": "subscription",
    "subscription": {
      "interval": "monthly",
      "trial_period_days": 14
    },
    "success_url": "https://yoursite.com/welcome",
    "failure_url": "https://yoursite.com/pricing"
  }'

Checkout Types

Gale automatically determines the checkout type based on product eligibility:
TypeDescription
eligibleAll items are HSA/FSA eligible
splitMix of eligible and non-eligible items
regularNo items are eligible
You don’t need to specify the type — Gale handles this automatically based on the products in the checkout.

Checkout Status

StatusDescription
openCheckout session created, awaiting customer
paidCustomer completed payment, order created
expiredSession expired (24 hours)

Webhooks

When payment completes, you receive an order.created webhook:
{
  "type": "order.created",
  "data": {
    "id": "ord_abc123",
    "checkout_id": "01HXYZ...",
    "reference_id": "your-order-123",
    "status": "completed",
    "customer": {
      "email": "jane@example.com"
    }
  }
}
See Webhooks Reference for setup and all event types.

Errors

Status CodeError CodeDescription
400bad_requestMissing or invalid parameters
401unauthorizedInvalid API key
422validation_errorField validation failed
See Error Reference for details.