# Create Checkout Session

This request creates a checkout session using the unique identifier generated when the `customer` resource was created.

<Note>
  If your workflow requires sending the `additional_data` object, it can be sent as part of the checkout session.
</Note>

**POST** `/checkout/sessions`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Create Checkout Session

## Authorization

- public-api-key (apiKey in header)
- private-secret-key (apiKey in header)

## Body

Content type: `application/json`

- `customer_id` (string)
  The unique identifier of the customer, created using the [Create Customer](https://docs.whitelabel.com/reference/create-customer) endpoint (UUID, 36 chars).
- `merchant_order_id` (string, required)
  The unique identifier of the customer's order (MAX 255; MIN 3).
- `payment_description` (string, required)
  The description of the payment (MAX 255; MIN 3).
- `callback_url` (string)
  The URL where we will redirect your customer after making the purchase. Required for alternative payment methods with redirection. (MAX 526; MIN 3)
- `country` (string, required)
  Country where the transaction must be processed (MAX 2; MIN 2; [ISO 3166-1](/reference/country-reference)).
- `account_id` (string, required)
  The unique identifier of the account. You find this information on [the WHITELABEL dashboard](https://dashboard.whitelabel.com/) (UUID, 36 chars).
- `amount` (object)
  Specifies the payment amount object, with the value and currency.
  - `currency` (string, required)
    The currency used to make the payment. For a full list of currency codes, see [Country reference](/reference/country-reference) (MAX 3; MIN 3; ISO 4217).
  - `value` (number<float>, required)
    The payment amount (multiple of 0.0001).
- `alternative_amount` (object)
  Alternative currency representation of the transaction amount.
  - `currency` (string, required)
    The alternative currency code. For a full list of currency codes, see [Country reference](/reference/country-reference) (MAX 3; MIN 3; ISO 4217).
  - `value` (number<float>, required)
    The alternative amount value (multiple of 0.0001).
- `shipping_methods` (any[])
  Delivery options the customer can pick from inside a wallet widget (Fast Checkout). The first method is preselected. The currency of every amount must match the session currency.
  - `id` (string, required)
    Merchant-defined identifier of the delivery method (MAX 255). Echoed back as shipping.method.id on the payment.
  - `label` (string, required)
    Name the wallet displays for the method (MAX 255).
  - `detail` (string)
    Optional secondary text, such as the delivery promise (MAX 255).
  - `amount` (object, required)
    Cost of the delivery method.
    - `currency` (string, required)
      ISO 4217 currency code. Must match the session currency.
    - `value` (number<float>, required)
      Cost value (multiple of 0.0001).
  - `delivery_estimate` (object)
    Optional delivery window (date-only, format YYYY-MM-DD).
    - `from` (string)
      Earliest delivery date.
    - `to` (string)
      Latest delivery date.
  - `summary_items` (any[], required)
    Order breakdown the wallet sheet displays when this method is selected (at least one item; the last entry is the grand total).
    - `id` (string, required)
      Identifier of the line item (MAX 255).
    - `label` (string, required)
      Name the wallet displays for the line item (MAX 255).
    - `amount` (object, required)
      Amount of the line item. Currency must match the session currency.
      - `currency` (string, required)
        ISO 4217 currency code.
      - `value` (number<float>, required)
        Amount value (multiple of 0.0001).
- `metadata` (object[])
  Specifies a list of metadata objects. You can add up to 120 metadata objects.
  - `key` (string, required)
    The metadata key (MAX 48)
  - `value` (string, required)
    The metadata key value (MAX 512)
- `workflow` ("SDK_CHECKOUT" | "CHECKOUT" | "SDK_SEAMLESS")
  Checkout workflow type.
- `installments` (object)
  The object to send the installment plan created in WHITELABEL to show your customers and let them choose from. This optional field is used in case a particular installments plan needs to be used in the session. if not sent, we will display the installment plan created for the account for each scenario, if any.
  - `plan_id` (string)
    Plan Id of the installment plan created in WHITELABEL
  - `plan` (object[])
    Installments to show the customer in with the checkout_session. This optional struct is used in case a particular installments plan needs to be used in the session and does not have an installments plan created for it. if not sent, we will display the installment plan created for the account for each scenario, if any.
    - `installment` (integer<int32>, required)
      The number of monthly installments shoppers can choose
    - `rate` (number<float>, required)
      The rate applied to the final amount of the transaction by the payment provider after using installments. The value should be entered as a multiplier, not a percentage. For example, to apply a 20% rate, enter `1.20` instead of `20`.
- `recurring_payment` (object)
  Optional object to enable and configure recurring payments (subscriptions).
  - `description` (string)
    Description of the subscription plan.
  - `management_url` (string)
    URL where the user can manage their subscription.
  - `billing_agreement` (string)
    Billing agreement identifier.
  - `regular_billing` (object)
    Configuration for the recurring billing cycle.
    - `label` (string, required)
      Descriptive label for the billing cycle (e.g. "Monthly").
    - `amount` (string, required)
      Billing amount (e.g. "9.99").
    - `interval_unit` ("year" | "month" | "day" | "hour" | "minute", required)
      Unit of the billing interval.
    - `interval_count` (integer, required)
      Number of units between each billing cycle.
  - `trial_billing` (object)
    (Optional) Trial period configuration.
    - `label` (string, required)
      Descriptive label for the trial billing cycle (e.g. "Free trial").
    - `amount` (string, required)
      Billing amount for trial (e.g. "0.00").
    - `interval_unit` ("year" | "month" | "day" | "hour" | "minute", required)
      Unit of the trial billing interval.
    - `interval_count` (integer, required)
      Number of units for the trial period.
- `checkout_id` (string)
  The unique identifier (UUID) of the Custom Checkout to use for this session. Optional. When omitted, the session uses the account's default checkout.
- `wallet_card_acceptance` (object)
  Optional. Limits which cards the customer can select in the Apple Pay payment sheet. Cards that do not match are shown greyed out. Every field is optional; a field that is not sent keeps the default behaviour. Values must be uppercase, and an empty list is rejected with 400 INVALID_PARAMETERS. It can only be set when the session is created.
  - `supported_countries` (string[])
    Countries that issued the card, as ISO 3166-1 alpha-2 codes. This is the card's issuing country, not the customer's location.
  - `supported_networks` (string[])
    Card networks the customer can select. Replaces the default list (AMEX, DISCOVER, ELECTRON, ELO, MASTERCARD, VISA, MAESTRO).
  - `supported_funding_types` ("CREDIT" | "DEBIT"[])
    Funding types the customer can select: CREDIT, DEBIT, or both.

Example:

```json
{
  "customer_id": "string",
  "merchant_order_id": "string",
  "payment_description": "string",
  "callback_url": "string",
  "country": "string",
  "account_id": "string",
  "amount": {
    "currency": "string",
    "value": 0
  },
  "alternative_amount": {
    "currency": "string",
    "value": 0
  },
  "shipping_methods": [
    {
      "id": "string",
      "label": "string",
      "detail": "string",
      "amount": {
        "currency": "string",
        "value": 0
      },
      "delivery_estimate": {
        "from": "string",
        "to": "string"
      },
      "summary_items": [
        {
          "id": "string",
          "label": "string",
          "amount": {
            "currency": "string",
            "value": 0
          }
        }
      ]
    }
  ],
  "metadata": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "workflow": "SDK_CHECKOUT",
  "installments": {
    "plan_id": "string",
    "plan": [
      {
        "installment": 0,
        "rate": 0
      }
    ]
  },
  "recurring_payment": {
    "description": "string",
    "management_url": "string",
    "billing_agreement": "string",
    "regular_billing": {
      "label": "string",
      "amount": "string",
      "interval_unit": "year",
      "interval_count": 0
    },
    "trial_billing": {
      "label": "string",
      "amount": "string",
      "interval_unit": "year",
      "interval_count": 0
    }
  },
  "checkout_id": "string",
  "wallet_card_acceptance": {
    "supported_countries": [
      "BR"
    ],
    "supported_networks": [
      "VISA",
      "MASTERCARD"
    ],
    "supported_funding_types": [
      "CREDIT"
    ]
  }
}
```

## Responses

### 200

200

- `merchant_order_id` (string)
- `checkout_session` (string)
- `country` (string)
- `payment_description` (string)
- `customer_id` (string)
- `callback_url` (string)
- `amount` (object)
  - `currency` (string)
  - `value` (integer)
- `created_at` (string)
- `metadata` (any)
- `workflow` (string)
- `installments` (object)
  - `plan_id` (any)
  - `plan` (any)
- `checkout_id` (string)

Example:

```json
{
  "merchant_order_id": "1717681150",
  "checkout_session": "d313047b-4f96-44ef-bbad-caf1d7ba4c2b",
  "country": "US",
  "payment_description": "Test Cards",
  "customer_id": "a577ad8f-08f1-4590-9cf1-e7679b15ee84",
  "callback_url": "https://www.example.com/callback",
  "amount": {
    "currency": "USD",
    "value": 520
  },
  "created_at": "2024-06-06T13:39:10.932297Z",
  "metadata": null,
  "workflow": "SDK_CHECKOUT",
  "installments": {
    "plan_id": null,
    "plan": null
  },
  "checkout_id": "6822f80c-684e-41a3-8628-78963d3d60f7"
}
```

### 400

400

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "INVALID_REQUEST",
  "messages": [
    "Invalid request"
  ]
}
```

### 401

401

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "INVALID_CREDENTIALS",
  "messages": [
    "Invalid credentials"
  ]
}
```

### 403

403

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "AUTHORIZATION_REQUIRED",
  "messages": [
    "The merchant has no authorization to use this API."
  ]
}
```