---
title: "Creates a new hosted checkout session"
method: POST
path: "/v2/checkout/sessions"
tags: ["Hosted Checkout"]
---

# Creates a new hosted checkout session

`POST /v2/checkout/sessions`

## Request

- Base URL: `https://docs.teya.com` (the document declares no server; this is the origin it was published from)
- URL: `https://docs.teya.com/v2/checkout/sessions`
- Auth: one of:
  - OAuth 2
    - Authorization code: `https://id.teya.xyz/oauth/v2/oauth-authorize`
    - Client credentials
    - Token URL: `https://id.teya.xyz/oauth/v2/oauth-token`
  - OAuth 2
    - Authorization code: `https://id.teya.com/oauth/v2/oauth-authorize`
    - Client credentials
    - Token URL: `https://id.teya.com/oauth/v2/oauth-token`
- TypeScript: <https://skmtc.dev/teya/apis/teya-apis-for-external-plugins/docs/v2/checkout/sessions/post.ts> (a function with typed inputs; its response is checked against the schema)

API to create a hosted checkout session.
<br><strong>Access Token Required scope:</strong> checkout/sessions/create

## Headers

- `Idempotency-Key` string, required: A unique key to identify the request. If the request is repeated with the same key, the same response will be returned. If the request is repeated with a different key or without a key, a new session will be created.
- `User-Agent` string, required

## Request body

- CheckoutCreateSessionRequest: Creates a Hosted Checkout session that will be used to process an Ecommerce transaction
  - `amount` CheckoutAmount, required: The transaction amount in the smallest currency unit according to ISO 4217 format. For example: - 100 ISK (Icelandic króna): the amount is 100 (since 1 ISK = 1 subunit). - 100 EUR (Euro): the amount is 10000 (since 1 EUR = 100 cents). - 100 USD (US Dollar): the amount is 10000 (since 1 USD = 100 cents). - 100 KWD (Kuwaiti Dinar): the amount is 100000 (since 1 KWD = 1000 fils).
    - `currency` 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BYR' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRO' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STD' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UZS' | 'VED' | 'VEF' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XCD' | 'XCG' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL', enum, required: Currency code (e.g. `USD`, `GBP`, `EUR`) following ISO-4217 format.
    - `value` integer, required: The transaction amount in the smallest currency unit according to ISO 4217 format.
  - `billing_address` CheckoutBillingAddress: Customer's Billing Address
    - `city` string: The city where the business is located
    - `country` string, required: The country where the business is located (ISO-3166-1 alpha2)
    - `state` string: The state where the business is located
    - `street_address_line1` string: The street address of a business
    - `street_address_line2` string: The street address of a business
    - `street_address_line3` string: The street address of a business
    - `zipcode` string: The zipcode where the business is located
  - `cancel_url` string: URL to bring back the customer to the cart. If included in the call we will render the “Back” button in the HostedCheckout UI
  - `customer` CheckoutCustomer
    - `email` string: Customer email address
    - `name` string: Customer name, used to prefill the hosted checkout form
    - `phone_number` string: Customer phone number An international phone number including the country code, formatted according to the E.164 standard.
  - `customer_success_email` string: If present, an e-mail is sent to the merchant customer upon successful payment with the receipt.
  - `failure_url` string: URL to redirect the customer once the transaction has finished with error
  - `language` string: The language to be used in the Hosted Checkout session in case the Accept-Language from the Customer browser does not exist or doesn’t match any of the allowed languages. It follows IETF BCP 47 and: - If provided, it should match any of the supported languages: en-GB, hu-HU, is-IS, cs-CZ, hr-HR, sk-SK, pt-PT, pt-BR, de-DE, es-ES, fr-FR, it-IT, pl-PL If it's different, the request will be rejected with BAD_REQUEST - If not provided, en-GB will be used when the Accept-Language from the Customer browser doesn't match
  - `line_items` CheckoutSessionLineItem[]: Basket information to be shown in payment page
    - `description` string, required: This a description for a item in the basket
    - `quantity` integer, required: The number of items, Must to be a positive value
    - `unit_price` integer, required: The price of a single item including VAT, Can be negative for discounts
  - `merchant_reference` string: An identifier that can be used to reference the transaction on the merchant's side. Overrides 'source_reference_id
  - `merchant_success_email` string: If present, an e-mail is sent to the merchant upon successful payment with the receipt.
  - `metadata` object: Metadata key-value pairs for the session. Maximum 10 keys allowed. Keys must not exceed 40 characters and values must not exceed 500 characters.
  - `post_success_payment` 'SHOW_SUCCESS_PAGE' | 'REDIRECT', enum: Where the customer browser will be sent after a successful transaction. Possible values: SHOW_SUCCESS_PAGE (Display the HostedCheckout payment completed page with a button to redirect to the success_url), REDIRECT (Redirect the customer browser directly to the success_url). Note: For transactions with Dynamic currency conversion (DCC), we will not redirect and will show success page if no customer_success_email is sent. Because we are required to show the rates to the customer.
  - `required_customer_fields` string[]: Customer fields that must be collected during checkout
  - `save_payment_method` boolean: When set to true, the customer's payment method is tokenized during the session and a token_id is returned in the payment.succeeded.v1 webhook and on the resulting transaction, for use in future payments. Combine with type ACCOUNT_VERIFICATION and a zero amount to save a card without charging the customer, or with type SALE to save it alongside a real payment. Requires tokenization to be enabled for the store.
  - `store_id` string, uuid: Store ID for the session. If not provided, it will be attempted to retrieve the store_id from the association with the client_id.
  - `success_url` string: URL to redirect the customer once the transaction has successfully finished
  - `type` 'ACCOUNT_VERIFICATION' | 'PRE_AUTHORISATION' | 'SALE', enum, required: Indicates the transaction type. Use SALE for standard payments, PRE_AUTHORISATION to reserve funds for later capture, or ACCOUNT_VERIFICATION to verify a card without charging it. ACCOUNT_VERIFICATION requires an amount value of 0 and must be enabled for the store; combine it with save_payment_method to save the card for future payments.

## Response `201`

Session has been created

- CheckoutCreateSessionResponse: Result of the creation of a Hosted Checkout session that will be used to process an Ecommerce transaction
  - `session_id` string, uuid, required: This is the id of the session that has been created and will be used to interact across different systems
  - `session_url` string, url, required: The hosted checkout session url that the merchant can use to redirect the customer once the session has been created

## Other responses

- `400`: Bad request
- `401`: Lacks valid authentication credentials for the requested resource
- `403`: The server understands the request but refuses to authorise it
- `409`: Request already processed
- `429`: Too many requests in a given amount of time
- `500`: Internal Server Error

---

[API](https://skmtc.dev/teya/apis/teya-apis-for-external-plugins.md) - [All operations](https://skmtc.dev/teya/apis/teya-apis-for-external-plugins/llms.txt) - [OpenAPI document](https://skmtc.dev/teya/apis/teya-apis-for-external-plugins/revisions/e26c4d895fa7?raw)
