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

# Create a payment link for a sub-merchant

> Aggregator accounts only. Makes a link that pays a sub-merchant linked to your account. The body is the same as [Create a payment link](/api-reference/payment-links/create-a-payment-link), and the agreed fee always applies.

Guide: [payment link errors](/api-reference/payment-links-overview#payment-link-errors).




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/sub-merchants/{subMerchantCode}/payment-links
openapi: 3.1.0
info:
  title: PrimePay API
  version: '1.0'
  description: >-
    Collect mobile money payments, send transfers and make payouts with the
    PrimePay API.
servers:
  - url: https://api.primepay.mw
    description: Live API (live keys, `sk_live_…`)
  - url: https://sandbox-api.primepay.mw
    description: Sandbox API (test keys, `sk_test_…`)
security:
  - bearerAuth: []
tags:
  - name: Operators
  - name: Payments
  - name: Refunds
  - name: Transfers
  - name: Payouts
  - name: Payment links
  - name: Checkout sessions
paths:
  /v1/sub-merchants/{subMerchantCode}/payment-links:
    post:
      tags:
        - Payment links
      summary: Create a payment link for a sub-merchant
      description: >
        Aggregator accounts only. Makes a link that pays a sub-merchant linked
        to your account. The body is the same as [Create a payment
        link](/api-reference/payment-links/create-a-payment-link), and the
        agreed fee always applies.


        Guide: [payment link
        errors](/api-reference/payment-links-overview#payment-link-errors).
      operationId: createSubMerchantPaymentLink
      parameters:
        - $ref: '#/components/parameters/SubMerchantCode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentLinkRequest'
      responses:
        '201':
          description: The link.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentLink'
        '400':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
components:
  parameters:
    SubMerchantCode:
      name: subMerchantCode
      in: path
      required: true
      schema:
        type: string
        pattern: ^[0-9]{8}$
        example: '12345678'
      description: The sub-merchant's 8-digit account code.
  schemas:
    PaymentLinkRequest:
      type: object
      properties:
        amount:
          type: number
          description: >-
            Required with `description`. Greater than zero, at most 2 decimal
            places, at most MWK 10,000,000. Don't send it with `items`.
          example: 15000
        description:
          type: string
          maxLength: 255
          description: >-
            Required with `amount`. What the customer is paying for. Shown to
            the customer.
          example: Chitenje dress, size M
        items:
          type: array
          minItems: 1
          maxItems: 50
          description: Instead of `amount`. The amount is their total.
          items:
            $ref: '#/components/schemas/PaymentLinkItem'
        name:
          type: string
          maxLength: 100
          description: A label for you only. Customers never see it.
          example: Instagram orders
        usage:
          type: string
          enum:
            - many
            - once
          default: many
          description: >-
            `many`: the link can be paid any number of times. `once`: it closes
            after the first payment.
        expiresIn:
          type: string
          enum:
            - never
            - 24h
            - 7d
            - 30d
          default: never
        collectName:
          type: boolean
          default: true
          description: Ask the customer for their name.
        collectEmail:
          type: boolean
          default: false
          description: Ask the customer for their email.
        redirectUrl:
          type: string
          description: >-
            Where the customer goes after paying. Must be a public `https://`
            address (sandbox also allows `http://localhost`). Without it, the
            customer sees PrimePay's receipt page.
    PaymentLink:
      type: object
      properties:
        id:
          type: string
        url:
          type: string
          description: The checkout address to send to your customer.
        code:
          type: string
        status:
          type: string
          enum:
            - active
            - inactive
            - completed
            - expired
          description: >-
            `active`: can be paid. `inactive`: deactivated by you, can be
            reactivated. `completed`: a `once` link that has been paid (final).
            `expired`: its `expiresAt` has passed (final).
        liveMode:
          type: boolean
        name:
          type: string
        description:
          type: string
        amount:
          type: number
        currency:
          type: string
          example: MWK
        items:
          type: array
          items:
            $ref: '#/components/schemas/PaymentLinkItem'
        usage:
          type: string
          enum:
            - many
            - once
        timesPaid:
          type: integer
          description: The number of completed payments.
        collectName:
          type: boolean
        collectEmail:
          type: boolean
        redirectUrl:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
        subMerchantAccountCode:
          type:
            - string
            - 'null'
        subMerchantName:
          type:
            - string
            - 'null'
    PaymentLinkItem:
      type: object
      required:
        - name
        - unitAmount
      properties:
        name:
          type: string
          maxLength: 200
        quantity:
          type: integer
          minimum: 1
          maximum: 9999
          default: 1
        unitAmount:
          type: number
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: insufficient_funds
            message:
              type: string
              example: Not enough available balance for MWK 25,000.00.
            field:
              type: string
              description: >-
                Payment links only. The field that is missing or wrong, for
                example `items[1].unitAmount`.
  responses:
    Error:
      description: An error. Use `code` in your code; show `message` to people.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Your API key: `sk_live_…` / `sk_test_…` (secret), `pk_live_…` /
        `pk_test_…` (publishable, read-only reference data) or `rk_live_…` /
        `rk_test_…` (payments only).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.