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

# Create Payment Link

> Creates a new payment link that can be shared with a customer to collect payment.

Creates a new payment link that can be shared with a customer to collect payment. Returns a hosted checkout URL — no frontend required on your end.

<Note>
  `pricing.type` drives which of `amount`, `minAmount`/`maxAmount`, or `packages` you need to set: `fixed` needs `amount`, `variable` needs `minAmount`/`maxAmount` (or neither, for `customer_choice`), `package` needs `packages`.
</Note>

<Note>
  `usageType: "limited_use"` requires `maxUses`. `single_use` and `multi_use` ignore it.
</Note>


## OpenAPI

````yaml POST /api/v3/payment-links
openapi: 3.0.0
info:
  title: KOTANI PAY API PLATFORM
  description: ''
  version: '3.0'
  contact: {}
servers:
  - url: https://sandbox-api.kotanipay.io
    description: Sandbox
security: []
tags: []
paths:
  /api/v3/payment-links:
    post:
      tags:
        - PAYMENT-LINKS
      summary: Create a payment link
      description: >-
        Creates a new payment link that can be shared with a customer to collect
        payment.
      operationId: PaymentLinksController_create_api/v3
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentLinkDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Payment link created successfully
                  data:
                    $ref: '#/components/schemas/PaymentLinkResponseDto'
                    type: object
        '401':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Invalid API Key
                  data:
                    type: object
                    example: {}
      security:
        - JWT: []
components:
  schemas:
    CreatePaymentLinkDto:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - standard
            - invoice
            - donation
        pricing:
          $ref: '#/components/schemas/PricingConfigDto'
        enabledPaymentMethods:
          type: array
          items:
            type: string
            enum:
              - mobile_money
              - bank
              - card
              - crypto
        paymentMethodConfig:
          $ref: '#/components/schemas/PaymentMethodConfigDto'
        usageType:
          type: string
          enum:
            - single_use
            - multi_use
            - limited_use
        maxUses:
          type: number
          description: Used when usageType is limited_use.
        expiresAt:
          type: string
          format: date-time
        collectCustomerInfo:
          $ref: '#/components/schemas/CollectCustomerInfoDto'
        afterPayment:
          $ref: '#/components/schemas/AfterPaymentConfigDto'
        callbackUrl:
          type: string
          example: https://yourdomain.com/webhook
        branding:
          $ref: '#/components/schemas/BrandingConfigDto'
        metadata:
          type: object
      required:
        - name
        - type
        - pricing
        - enabledPaymentMethods
        - usageType
        - collectCustomerInfo
    PaymentLinkResponseDto:
      type: object
      properties:
        id:
          type: string
        shortCode:
          type: string
          description: Used to build the hosted checkout URL.
        url:
          type: string
          description: Full hosted checkout URL to share with customers.
          example: https://pay.kotanipay.com/abc123
        name:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - standard
            - invoice
            - donation
        pricing:
          $ref: '#/components/schemas/PricingConfigDto'
        enabledPaymentMethods:
          type: array
          items:
            type: string
            enum:
              - mobile_money
              - bank
              - card
              - crypto
        paymentMethodConfig:
          $ref: '#/components/schemas/PaymentMethodConfigDto'
        usageType:
          type: string
          enum:
            - single_use
            - multi_use
            - limited_use
        maxUses:
          type: number
        currentUses:
          type: number
        expiresAt:
          type: string
          format: date-time
        isActive:
          type: boolean
        collectCustomerInfo:
          $ref: '#/components/schemas/CollectCustomerInfoDto'
        afterPayment:
          $ref: '#/components/schemas/AfterPaymentConfigDto'
        branding:
          $ref: '#/components/schemas/BrandingConfigDto'
        qrCodeUrl:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        lastUsedAt:
          type: string
          format: date-time
      required:
        - id
        - shortCode
        - url
        - name
        - type
        - pricing
        - enabledPaymentMethods
        - usageType
        - currentUses
        - isActive
        - collectCustomerInfo
        - createdAt
        - updatedAt
    PricingConfigDto:
      type: object
      properties:
        type:
          type: string
          enum:
            - fixed
            - variable
            - package
            - customer_choice
        currency:
          type: string
          description: >-
            Single currency for pricing. If omitted, uses supportedCurrencies
            from paymentMethodConfig.
          example: KES
        referenceCurrency:
          type: string
          description: Reference currency the fixed, min and max amounts are specified in.
          example: KES
        amount:
          type: number
          description: Required when type is fixed.
        minAmount:
          type: number
          description: Used when type is variable.
        maxAmount:
          type: number
          description: Used when type is variable.
        packages:
          type: array
          items:
            $ref: '#/components/schemas/PricingPackageDto'
          description: Used when type is package.
      required:
        - type
    PaymentMethodConfigDto:
      type: object
      description: >-
        Restricts which providers/currencies/networks/countries are offered per
        payment method. All fields optional — omit to allow everything enabled
        on your account.
      properties:
        mobileMoneyProviders:
          type: array
          items:
            type: string
        mobileMoneyCurrencies:
          type: array
          items:
            type: string
          example:
            - KES
            - GHS
        mobileMoneyCountries:
          type: array
          items:
            type: string
        supportedCurrencies:
          type: array
          items:
            type: string
        cryptoNetworks:
          type: array
          items:
            type: string
        cryptoCurrencies:
          type: array
          items:
            type: string
          example:
            - USDT
            - USDC
        cardCurrencies:
          type: array
          items:
            type: string
        cardCountries:
          type: array
          items:
            type: string
        bankCurrencies:
          type: array
          items:
            type: string
        bankCountries:
          type: array
          items:
            type: string
    CollectCustomerInfoDto:
      type: object
      description: >-
        Whether email, phone, name, and address are required, optional, or not
        collected at checkout.
      properties:
        email:
          type: string
          enum:
            - required
            - optional
            - none
        phone:
          type: string
          enum:
            - required
            - optional
            - none
        name:
          type: string
          enum:
            - required
            - optional
            - none
        address:
          type: string
          enum:
            - required
            - optional
            - none
      required:
        - email
        - phone
        - name
    AfterPaymentConfigDto:
      type: object
      properties:
        type:
          type: string
          enum:
            - message
            - redirect
        message:
          type: string
          description: Shown when type is message.
        redirectUrl:
          type: string
          description: Used when type is redirect.
          example: https://yourdomain.com/thank-you
      required:
        - type
    BrandingConfigDto:
      type: object
      properties:
        logoUrl:
          type: string
          example: https://yourdomain.com/logo.png
        primaryColor:
          type: string
          example: '#0084FF'
        backgroundColor:
          type: string
          example: '#FFFFFF'
    PricingPackageDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        amount:
          type: number
        currency:
          type: string
          example: KES
      required:
        - id
        - name
        - amount
        - currency
  securitySchemes:
    JWT:
      scheme: bearer
      bearerFormat: JWT
      type: http

````