> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simplepay.mx/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a hosted Checkout Session

> Referencia detallada para POST /v1/hosted-checkout/sessions.

## Uso

Usalo para crear o consultar checkouts hospedados. La confirmacion operativa debe venir de webhooks o de una lectura de API, no del redirect.

## Antes de llamar

| Tema             | Detalle                                                                                |
| ---------------- | -------------------------------------------------------------------------------------- |
| Metodo           | `POST`                                                                                 |
| Ruta             | `/v1/hosted-checkout/sessions`                                                         |
| Auth             | Bearer API key del ambiente correcto.                                                  |
| Scope            | No hay scope explicito en la spec publica; aplica el acceso del tenant y ambiente.     |
| Idempotencia     | Recomendada para cualquier retry. Usa una key deterministica por operacion de negocio. |
| Guia relacionada | [Hosted Checkout](/payments/checkout-sessions)                                         |

## Patron recomendado

* Ejecuta este endpoint desde backend o job seguro, nunca desde frontend con API keys.
* Manda `Idempotency-Key` cuando el endpoint cree, convierta, reprograme, cancele, capture o reembolse estado.
* Persiste IDs SimplePay (`spcs_...`, `sppi_...`, `splink_...`, refund IDs o booking IDs) para reconciliacion.
* Consulta el bloque OpenAPI de esta pagina para el shape exacto de parametros, body y respuestas.

## Ejemplo minimo

```bash terminal theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -sS -X POST "https://api.simplepay.mx/v1/hosted-checkout/sessions" \
  -H "Authorization: Bearer $SIMPLEPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: create-checkout-session_v1" \
  -d '{ ... }'
```

## Errores a manejar

* `400` indica payload, parametros o estado invalido.
* `401` o `403` indican API key, ambiente o scopes incorrectos.
* `409` suele indicar conflicto de estado, duplicado o idempotencia incompatible.
* `429` y `5xx` se pueden reintentar con backoff; en writes conserva la misma idempotency key.

## Contrato OpenAPI

El playground, parametros, body y respuestas de abajo salen de `/openapi.json`. Si el contrato cambia, actualiza la spec y regenera esta pagina.


## OpenAPI

````yaml openapi.json POST /v1/hosted-checkout/sessions
openapi: 3.1.0
info:
  title: SimplePay API
  version: '2026-06-13'
servers:
  - url: https://api.simplepay.mx
security:
  - SimplePayApiKey: []
paths:
  /v1/hosted-checkout/sessions:
    post:
      summary: Create a hosted Checkout Session
      operationId: createCheckoutSession
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutSessionCreate'
      responses:
        '200':
          description: Checkout Session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSession'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 8
        maxLength: 255
  schemas:
    CheckoutSessionCreate:
      type: object
      required:
        - currency
        - line_items
        - success_url
      properties:
        appearance:
          type: object
          additionalProperties: true
        cancel_url:
          type: string
          format: uri
        client_reference_id:
          type: string
          maxLength: 255
        currency:
          type: string
          pattern: ^[a-z]{3}$
        customer:
          $ref: '#/components/schemas/PaymentCustomer'
        customer_email:
          type: string
          format: email
        installments:
          $ref: '#/components/schemas/InstallmentOptions'
        line_items:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - name
              - amount
            properties:
              amount:
                type: integer
                minimum: 1
              name:
                type: string
                minLength: 1
              quantity:
                type: integer
                minimum: 1
                default: 1
        metadata:
          type: object
          additionalProperties: true
        payment_method_types:
          $ref: '#/components/schemas/PaymentMethodTypes'
        pricing:
          $ref: '#/components/schemas/PricingOptions'
        success_url:
          type: string
          format: uri
    CheckoutSession:
      type: object
      properties:
        amount_total:
          type: integer
        id:
          type: string
          pattern: ^spcs_[a-z0-9]{32}$
        object:
          const: checkout.session
        pricing_snapshot:
          $ref: '#/components/schemas/PricingSnapshot'
        status:
          type: string
        url:
          type: string
          format: uri
          examples:
            - >-
              https://checkout.simplepay.mx/checkout/spcs_0123456789abcdef0123456789abcdef
    PaymentCustomer:
      type: object
      properties:
        email:
          type: string
          format: email
        name:
          type: string
    InstallmentOptions:
      type: object
      properties:
        enabled:
          type: boolean
        merchant_financing_markup_bps:
          type: integer
          minimum: 0
        months:
          enum:
            - 3
            - 6
            - 9
            - 12
            - 18
        pricing_strategy:
          type: string
          enum:
            - merchant_absorbed
            - payer_transparent
            - blended_price
            - pass_through_plus_margin
    PaymentMethodTypes:
      type: array
      minItems: 1
      items:
        enum:
          - card
          - oxxo
          - spei
      default:
        - card
    PricingOptions:
      type: object
      properties:
        merchant_financing_markup_bps:
          type: integer
          minimum: 0
    PricingSnapshot:
      type: object
      additionalProperties: true
      required:
        - base_amount_minor
        - gross_amount_minor
        - simplepay_fee_minor
        - application_fee_amount_minor
        - processor_cost_estimate_minor
        - platform_margin_estimate_minor
  securitySchemes:
    SimplePayApiKey:
      type: http
      scheme: bearer

````