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

# Create a payment link

> Creates a reusable, revocable link for this product. Use the `url` in the response; the link has no payer, and the customer and invoice (or subscription) are created when someone pays.

Requires a published version. Publishing a version already creates the first link; use this route for additional links, for links with `successUrl` / `cancelUrl`, or to sell an offer with `productVersionId`.




## OpenAPI

````yaml /api-reference/openapi.en.json post /products/{productID}/payment-links
openapi: 3.1.0
info:
  title: Infi API
  version: 0.0.1
  description: >
    The Infi REST API: catalog, customers, usage metering, subscriptions,

    invoices, payments and checkout.


    **Authentication.** Send your secret key as `Authorization: Bearer
    sk_test_…`

    (sandbox) or `sk_live_…` (production). The key prefix selects the
    environment.

    Checkout routes (`/pay/*`) and `/public/*` take no key: they run in the

    payer's browser.


    **Idempotency.** Every request that changes data requires an

    `Idempotency-Key` header. A retry with the same key returns the original

    response instead of running again.


    **Amounts.** Money and quantities travel as decimal strings (`"150.00"`,

    `"0.0001"`), never as floating-point numbers.


    **Errors.** The body carries `error_code` (stable, branch on it), `message`

    (for humans) and `tracer_id` (send it to support). Rate-limit and
    idempotency

    errors are nested under `error`, with `code` and `request_id`.
servers:
  - url: https://api-sandbox.beinfi.com
    description: Sandbox
  - url: https://api.beinfi.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Catalog
  - name: Customers
  - name: Metering
  - name: Subscriptions
  - name: Invoices
  - name: Payments
  - name: Checkout
  - name: Coupons
  - name: Billing
  - name: Account
  - name: Webhooks
  - name: Test account
  - name: Rail
  - name: Storefronts
paths:
  /products/{productID}/payment-links:
    parameters:
      - $ref: '#/components/parameters/ProductID'
    post:
      tags:
        - Catalog
      summary: Create a payment link
      description: >
        Creates a reusable, revocable link for this product. Use the `url` in
        the response; the link has no payer, and the customer and invoice (or
        subscription) are created when someone pays.


        Requires a published version. Publishing a version already creates the
        first link; use this route for additional links, for links with
        `successUrl` / `cancelUrl`, or to sell an offer with `productVersionId`.
      operationId: createPaymentLink
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentLinkRequest'
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentLink'
          description: Link created.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: >-
            The product has no published version (`errors[0].field` is
            `productId`): publish one first. Or `successUrl` / `cancelUrl` is
            not an absolute `http(s)` URL.
components:
  parameters:
    ProductID:
      name: productID
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Product ID.
  schemas:
    CreatePaymentLinkRequest:
      type: object
      properties:
        successUrl:
          type:
            - string
            - 'null'
          maxLength: 2048
          description: >-
            Where the payer goes after paying, with `?status=success&invoice=…`
            appended.
        cancelUrl:
          type:
            - string
            - 'null'
          maxLength: 2048
          description: >-
            Offered to the payer as "back to the store" while the checkout is
            open.
        productVersionId:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Sells a specific published version instead of the default. This is
            how a promotional price reaches a buyer: the version is published
            with `default: false`, and only a link that names it can sell it.
            Omit it to sell the default version. Refused if the version is not a
            published version of this product.
      description: >-
        Optional. A link needs no configuration; send a body only to set where
        the payer goes afterwards, or to sell an offer. URLs must be absolute
        `http(s)`.
    PaymentLink:
      type: object
      properties:
        id:
          type: string
          format: uuid
        productId:
          type: string
          format: uuid
        token:
          type: string
          description: The link's public token, part of the `url`.
        url:
          type: string
          description: >-
            The address to send the payer. Use this value instead of building
            the URL yourself.
        productVersionId:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The product version this link sells, fixed at creation. Publishing a
            new version does not reprice a link already issued. When `null`, the
            link sells the latest published version at payment time.
        active:
          type: boolean
          description: '`false` once revoked.'
        revokedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When the link was revoked.
        createdAt:
          type: string
          format: date-time
        successUrl:
          type:
            - string
            - 'null'
          description: >-
            Where the payer goes after paying, with `?status=success&invoice=…`
            appended.
        cancelUrl:
          type:
            - string
            - 'null'
          description: >-
            Offered to the payer as "back to the store" while the checkout is
            open; also the `?status=error` destination when the charge expires
            in the embedded checkout.
      description: >-
        A reusable, revocable payment link bound to a product. Anyone holding it
        can open the checkout; it is meant to be copied and shared.
    ValidationError:
      type: object
      required:
        - message
        - error_code
        - tracer_id
        - errors
      properties:
        message:
          type: string
        error_code:
          $ref: '#/components/schemas/ErrorCode'
        tracer_id:
          type: string
        errors:
          type: array
          items:
            type: object
            required:
              - field
              - value
              - constraint
              - description
            properties:
              field:
                type: string
              value:
                type: string
              constraint:
                type: string
              description:
                type: string
          description: >-
            Per-field detail (`field`, `description`). Always present on a
            `422`; may be empty.
      description: >-
        Body of a `422`. Same shape as `Error`, plus `errors[]` with per-field
        detail. That is where the sentence telling you what to fix lives (for
        example, "product has no published version").
    Error:
      type: object
      required:
        - message
        - error_code
        - tracer_id
      properties:
        message:
          type: string
          description: Human-readable sentence.
        error_code:
          $ref: '#/components/schemas/ErrorCode'
          description: Stable error code. Branch on it.
        tracer_id:
          type: string
          description: Request id. Include it when contacting support.
      description: >-
        The standard error body. It is flat (no `error` wrapper) and the trace
        id is `tracer_id`.
    NotFoundError:
      type: object
      required:
        - message
        - error_code
        - tracer_id
        - resource
      properties:
        message:
          type: string
        error_code:
          $ref: '#/components/schemas/ErrorCode'
        tracer_id:
          type: string
        resource:
          type: string
    ErrorCode:
      type: string
      examples:
        - internal_error
        - validation_failed
        - bad_request
        - unauthorized
        - forbidden
        - not_found
        - conflict
        - rate_limited
      description: >-
        Stable error code. The list is open: besides the generic codes, each
        area defines its own (`coupon_expired`, `insufficient_balance`,
        `version_not_draft`, `idempotency_key_reused`…). Handle a code you do
        not recognize by its HTTP status and show `message`; do not fail parsing
        the response.
  responses:
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      description: Missing or invalid API key.
    NotFound:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFoundError'
      description: Resource not found.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your account's secret key: `Authorization: Bearer sk_test_…` or
        `sk_live_…`. Server-side only.

````