> ## 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 Payment Link

> Referencia detallada para POST /v1/payment-links.

## Uso

Usalo para cobros asincronos, invoices, ventas manuales o links reutilizables con limites y expiracion.

## Antes de llamar

| Tema             | Detalle                                                                                |
| ---------------- | -------------------------------------------------------------------------------------- |
| Metodo           | `POST`                                                                                 |
| Ruta             | `/v1/payment-links`                                                                    |
| 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 | [Payment Links](/payments/payment-links)                                               |

## 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/payment-links" \
  -H "Authorization: Bearer $SIMPLEPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: create-payment-link_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/payment-links
openapi: 3.1.0
info:
  title: SimplePay API
  version: '2026-06-13'
servers:
  - url: https://api.simplepay.mx
security:
  - SimplePayApiKey: []
paths:
  /v1/payment-links:
    post:
      summary: Create a Payment Link
      operationId: createPaymentLink
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentLinkCreate'
      responses:
        '200':
          description: Payment Link created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentLink'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 8
        maxLength: 255
  schemas:
    PaymentLinkCreate:
      allOf:
        - $ref: '#/components/schemas/MoneyAmount'
        - type: object
          required:
            - name
          properties:
            appearance:
              type: object
              additionalProperties: true
            cancel_url:
              type: string
              format: uri
            client_reference_id:
              type: string
              maxLength: 255
            collect_automatic_tax:
              type: boolean
              default: false
            collect_business_names:
              type: boolean
              default: false
            collect_customer_addresses:
              type: boolean
              default: false
            collect_customer_names:
              type: boolean
              default: false
            confirmation_message:
              type: string
              maxLength: 500
            customer:
              $ref: '#/components/schemas/PaymentCustomer'
            customer_email:
              type: string
              format: email
            description:
              type: string
            expires_at:
              type: string
              format: date-time
            enable_managed_payments:
              type: boolean
              default: false
            installments:
              $ref: '#/components/schemas/InstallmentOptions'
            max_payments:
              type: integer
              minimum: 1
            metadata:
              type: object
              additionalProperties: true
            name:
              type: string
              minLength: 1
            notification:
              type: object
              additionalProperties: true
            payment_method_types:
              $ref: '#/components/schemas/PaymentMethodTypes'
            pricing:
              $ref: '#/components/schemas/PricingOptions'
            require_phone:
              type: boolean
              default: false
            success_url:
              type: string
              format: uri
            theme:
              enum:
                - light
                - dark
                - system
    PaymentLink:
      type: object
      properties:
        id:
          type: string
          pattern: ^splink_[a-z0-9]{32}$
        object:
          const: payment_link
        checkout_session:
          type: object
          properties:
            id:
              type: string
              pattern: ^spcs_[a-z0-9]{32}$
            url:
              type: string
              format: uri
              examples:
                - >-
                  https://checkout.simplepay.mx/checkout/spcs_0123456789abcdef0123456789abcdef
        pricing_snapshot:
          $ref: '#/components/schemas/PricingSnapshot'
        status:
          type: string
        url:
          type: string
          format: uri
          examples:
            - https://link.simplepay.mx/splink_0123456789abcdef0123456789abcdef
    MoneyAmount:
      type: object
      required:
        - amount
        - currency
      properties:
        amount:
          type: integer
          minimum: 1
        currency:
          type: string
          pattern: ^[a-z]{3}$
    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

````