---
title: "Create Checkout Session"
method: POST
path: "/api/v1/checkout-sessions"
tags: ["Checkout Sessions", "Purchases"]
---

# Create Checkout Session

`POST /api/v1/checkout-sessions`

## Request body

- object — Use this schema for new checkout sessions.
  - `checkoutSession` union, required
    - IdentifiedProductCheckoutSessionInput
      - `customerExternalId` string, required — The id of the Customer for this purchase session, as defined in your system
      - `successUrl` string, required — The URL to redirect to after the purchase is successful
      - `cancelUrl` string, required — The URL to redirect to after the purchase is canceled or fails
      - `outputMetadata` Metadata — JSON object
      - `outputName` string — The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.
      - `type` 'product', required
      - `priceId` string — The ID of the price the customer shall purchase. If not provided, priceSlug is required.
      - `priceSlug` string — The slug of the price the customer shall purchase. If not provided, priceId is required.
      - `quantity` integer — The quantity of the purchase or subscription created when this checkout session succeeds. Must be a positive integer. Defaults to 1 if not provided.
      - `anonymous` false
      - `preserveBillingCycleAnchor` boolean — Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.
    - AnonymousProductCheckoutSessionInput
      - `customerExternalId` unknown
      - `successUrl` string, required — The URL to redirect to after the purchase is successful
      - `cancelUrl` string, required — The URL to redirect to after the purchase is canceled or fails
      - `outputMetadata` Metadata — JSON object
      - `outputName` string — The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.
      - `type` 'product', required
      - `priceId` string — The ID of the price the customer shall purchase. If not provided, priceSlug is required.
      - `priceSlug` string — The slug of the price the customer shall purchase from the organization's default pricing model. If not provided, priceId is required.
      - `quantity` integer — The quantity of the purchase or subscription created when this checkout session succeeds. Must be a positive integer. Defaults to 1 if not provided.
      - `anonymous` true, required
      - `preserveBillingCycleAnchor` boolean — Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.
    - object
      - `customerExternalId` string, required — The id of the Customer for this purchase session, as defined in your system
      - `successUrl` string, required — The URL to redirect to after the purchase is successful
      - `cancelUrl` string, required — The URL to redirect to after the purchase is canceled or fails
      - `outputMetadata` Metadata — JSON object
      - `outputName` string — The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.
      - `type` 'activate_subscription', required
      - `targetSubscriptionId` string, required
      - `preserveBillingCycleAnchor` boolean — Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.
    - object
      - `customerExternalId` string, required — The id of the Customer for this purchase session, as defined in your system
      - `successUrl` string, required — The URL to redirect to after the purchase is successful
      - `cancelUrl` string, required — The URL to redirect to after the purchase is canceled or fails
      - `outputMetadata` Metadata — JSON object
      - `outputName` string — The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.
      - `type` 'add_payment_method', required
      - `targetSubscriptionId` string — The id of the subscription that the payment method will be added to as the default payment method.
      - `automaticallyUpdateSubscriptions` boolean, nullable — Whether to automatically update all current subscriptions to the new payment method. Defaults to false.

## Response `200`

Successful response

- object
  - `checkoutSession` union, required
    - PurchaseCheckoutSessionRecord
      - `id` string, required
      - `createdAt` integer, required — Epoch milliseconds.
      - `updatedAt` integer, required — Epoch milliseconds.
      - `livemode` boolean, required
      - `pricingModelId` string, required
      - `status` 'open' | 'pending' | 'succeeded' | 'failed' | 'expired', required
      - `billingAddress` BillingAddress
        - `name` string, nullable
        - `firstName` string, nullable
        - `lastName` string, nullable
        - `email` string, email, nullable
        - `address` object, required
          - `name` string, nullable
          - `line1` string, nullable
          - `line2` string, nullable
          - `city` string, nullable
          - `state` string, nullable
          - `postal_code` string, nullable
          - `country` string, required
        - `phone` string, nullable
      - `priceId` string, required
      - `purchaseId` string, required
      - `invoiceId` string, nullable, required
      - `quantity` integer, required
      - `organizationId` string, required
      - `customerName` string, nullable, required
      - `customerEmail` string, nullable, required
      - `customerId` string, nullable, required
      - `paymentMethodType` 'card' | 'link' | 'us_bank_account' | 'sepa_debit', nullable
      - `discountId` string, nullable, required
      - `successUrl` string, uri, nullable
      - `cancelUrl` string, uri, nullable
      - `type` 'purchase', required
      - `preserveBillingCycleAnchor` false
      - `outputMetadata` Metadata — JSON object
      - `outputName` string, nullable, required
      - `targetSubscriptionId` unknown
      - `automaticallyUpdateSubscriptions` unknown
      - `expires` integer, required — Epoch milliseconds.
    - ProductCheckoutSessionRecord
      - `id` string, required
      - `createdAt` integer, required — Epoch milliseconds.
      - `updatedAt` integer, required — Epoch milliseconds.
      - `livemode` boolean, required
      - `pricingModelId` string, required
      - `status` 'open' | 'pending' | 'succeeded' | 'failed' | 'expired', required
      - `billingAddress` BillingAddress
        - `name` string, nullable
        - `firstName` string, nullable
        - `lastName` string, nullable
        - `email` string, email, nullable
        - `address` object, required
          - `name` string, nullable
          - `line1` string, nullable
          - `line2` string, nullable
          - `city` string, nullable
          - `state` string, nullable
          - `postal_code` string, nullable
          - `country` string, required
        - `phone` string, nullable
      - `priceId` string, required
      - `purchaseId` string, nullable, required
      - `invoiceId` unknown
      - `quantity` integer, required
      - `organizationId` string, required
      - `customerName` string, nullable, required
      - `customerEmail` string, nullable, required
      - `customerId` string, nullable, required
      - `paymentMethodType` 'card' | 'link' | 'us_bank_account' | 'sepa_debit', nullable
      - `discountId` string, nullable, required
      - `successUrl` string, uri, nullable
      - `cancelUrl` string, uri, nullable
      - `type` 'product', required
      - `preserveBillingCycleAnchor` boolean — Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.
      - `outputMetadata` Metadata — JSON object
      - `outputName` string, nullable, required
      - `targetSubscriptionId` unknown
      - `automaticallyUpdateSubscriptions` unknown
      - `expires` integer, required — Epoch milliseconds.
    - AddPaymentMethodCheckoutSessionRecord
      - `id` string, required
      - `createdAt` integer, required — Epoch milliseconds.
      - `updatedAt` integer, required — Epoch milliseconds.
      - `livemode` boolean, required
      - `pricingModelId` string, required
      - `status` 'open' | 'pending' | 'succeeded' | 'failed' | 'expired', required
      - `billingAddress` BillingAddress
        - `name` string, nullable
        - `firstName` string, nullable
        - `lastName` string, nullable
        - `email` string, email, nullable
        - `address` object, required
          - `name` string, nullable
          - `line1` string, nullable
          - `line2` string, nullable
          - `city` string, nullable
          - `state` string, nullable
          - `postal_code` string, nullable
          - `country` string, required
        - `phone` string, nullable
      - `priceId` string, nullable, required
      - `purchaseId` string, nullable, required
      - `invoiceId` string, nullable, required
      - `quantity` integer, required
      - `organizationId` string, required
      - `customerName` string, nullable, required
      - `customerEmail` string, nullable, required
      - `customerId` string, required — The customer that the payment method will be added to as the default payment method.
      - `paymentMethodType` 'card' | 'link' | 'us_bank_account' | 'sepa_debit', nullable
      - `discountId` string, nullable, required
      - `successUrl` string, uri, nullable
      - `cancelUrl` string, uri, nullable
      - `type` 'add_payment_method', required
      - `preserveBillingCycleAnchor` boolean, required
      - `outputMetadata` Metadata — JSON object
      - `outputName` string, nullable, required
      - `targetSubscriptionId` string, nullable — The subscription that the payment method will be added to as the default payment method.
      - `automaticallyUpdateSubscriptions` boolean, nullable — Whether to automatically update all current subscriptions to the new payment method. Defaults to false.
      - `expires` integer, required — Epoch milliseconds.
    - ActivateSubscriptionCheckoutSessionRecord
      - `id` string, required
      - `createdAt` integer, required — Epoch milliseconds.
      - `updatedAt` integer, required — Epoch milliseconds.
      - `livemode` boolean, required
      - `pricingModelId` string, required
      - `status` 'open' | 'pending' | 'succeeded' | 'failed' | 'expired', required
      - `billingAddress` BillingAddress
        - `name` string, nullable
        - `firstName` string, nullable
        - `lastName` string, nullable
        - `email` string, email, nullable
        - `address` object, required
          - `name` string, nullable
          - `line1` string, nullable
          - `line2` string, nullable
          - `city` string, nullable
          - `state` string, nullable
          - `postal_code` string, nullable
          - `country` string, required
        - `phone` string, nullable
      - `priceId` string, nullable, required
      - `purchaseId` unknown
      - `invoiceId` unknown
      - `quantity` integer, required
      - `organizationId` string, required
      - `customerName` string, nullable, required
      - `customerEmail` string, nullable, required
      - `customerId` string, nullable, required
      - `paymentMethodType` 'card' | 'link' | 'us_bank_account' | 'sepa_debit', nullable
      - `discountId` string, nullable, required
      - `successUrl` string, uri, nullable
      - `cancelUrl` string, uri, nullable
      - `type` 'activate_subscription', required
      - `preserveBillingCycleAnchor` boolean — Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.
      - `outputMetadata` Metadata — JSON object
      - `outputName` string, nullable, required
      - `targetSubscriptionId` string, required
      - `automaticallyUpdateSubscriptions` boolean, nullable, required
      - `expires` integer, required — Epoch milliseconds.
  - `url` string, required — The URL to redirect to complete the purchase

## Other responses

- `400` — Invalid input data
- `401` — Authorization not provided
- `403` — Insufficient access
- `500` — Internal server error

---

[API](https://skmtc.net/flowglad/apis/flowglad-api-2.md) · [All operations](https://skmtc.net/flowglad/apis/flowglad-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/flowglad/flowglad-api-2/versions/c838c92c3606/schema)
