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

# Create a magic link

> Creates a new magic link that can be sent to an end user to initiate a money transfer. Optionally pre-fill user data (name, ID, payment method) and configure the link's expiration, flow, theme, and language. Returns the full widget URL and authentication token.



## OpenAPI

````yaml /m2m/openapi.json post /partner/links
openapi: 3.0.0
info:
  title: M2M Partner API
  description: >
    REST API for M2M partner integrations. Create magic links to enable
    cross-border money transfers, manage end users, track transfer operations,
    handle CIP verification, and configure webhooks for real-time event
    notifications.


    ## Authentication


    All endpoints require an API key passed in the `X-API-Key` header. Use
    `m2m_test_*` keys for the sandbox environment.


    ## Environments


    | Environment | Base URL |

    |---|---|

    | Sandbox | `https://m2m-backend-qa.up.railway.app` |
  version: 0.5.3
  contact: {}
servers:
  - url: https://m2m-backend-qa.up.railway.app
    description: Sandbox
security: []
tags:
  - name: Partner - Magic Links
    description: Create, list, and manage magic links for money transfers
  - name: Partner - Users
    description: View and manage end users associated with your partner account
  - name: Partner - Operations
    description: Track money transfer operations and their statuses
  - name: Partner - CIP
    description: Customer Identification Program (CIP) verification management
  - name: Partner - Data Requests
    description: Fulfill data requests for additional user information
  - name: Partner - Settings
    description: Configure partner-level settings (redirect URLs, etc.)
  - name: Partner - Webhooks
    description: Configure webhook endpoints and inspect delivery history
paths:
  /partner/links:
    post:
      tags:
        - Partner - Magic Links
      summary: Create a magic link
      description: >-
        Creates a new magic link that can be sent to an end user to initiate a
        money transfer. Optionally pre-fill user data (name, ID, payment method)
        and configure the link's expiration, flow, theme, and language. Returns
        the full widget URL and authentication token.
      operationId: LinksController_createLink
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLinkDto'
      responses:
        '201':
          description: Magic link created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateLinkResponseDto'
        '401':
          description: Unauthorized — invalid or missing API key / bearer token
        '403':
          description: Forbidden — user is blocked and cannot receive new links
      security:
        - bearer: []
        - api-key: []
components:
  schemas:
    CreateLinkDto:
      type: object
      properties:
        referenceId:
          type: string
          description: >-
            Your unique identifier for the end user in your system. Used to
            correlate M2M users with your records and to detect returning users.
          example: user-12345
        expiresInMinutes:
          type: number
          description: >-
            Link time-to-live in minutes. The link becomes inaccessible after
            expiration. Minimum: 5 minutes. Maximum: 10,080 minutes (7 days).
            Defaults to the partner-level configuration (usually 60 minutes).
          default: 60
          minimum: 5
          maximum: 10080
          example: 120
        userData:
          description: >-
            Pre-filled user data. Any fields provided here will be pre-populated
            in the widget, allowing the user to skip those steps.
          allOf:
            - $ref: '#/components/schemas/UserDataDto'
        metadata:
          type: object
          description: >-
            Arbitrary key-value metadata to attach to the link. Useful for
            storing internal references, campaign IDs, etc. Returned in link
            detail and webhook payloads.
          example:
            orderId: ORD-2026-001
            campaign: february-promo
        flow:
          type: string
          description: >-
            Widget flow type that determines the user experience. Defaults to
            "m2m-basic" if not specified.
          example: m2m-basic
          default: m2m-basic
        theme:
          type: string
          description: >-
            Theme identifier to customize the widget appearance. Overrides the
            partner-level theme configuration for this link.
          example: dark
        language:
          type: string
          description: >-
            Language code for the widget UI (ISO 639-1). Overrides browser
            detection.
          example: es
          enum:
            - en
            - es
        callbackUrl:
          type: string
          description: >-
            URL to receive callback notifications for this specific link.
            Overrides the partner-level webhook URL for link-specific events.
          example: https://api.example.com/callbacks/m2m
      required:
        - referenceId
    CreateLinkResponseDto:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/CreateLinkDataDto'
      required:
        - success
        - data
    UserDataDto:
      type: object
      properties:
        name:
          description: User full name. firstName and lastName are required.
          allOf:
            - $ref: '#/components/schemas/NameDto'
        idNumber:
          type: string
          description: >-
            Government-issued ID number (e.g., CURP, INE, SSN). Stored securely
            and masked in responses.
          example: GAPA900515HDFRRL09
        idType:
          type: string
          description: Type of ID document provided
          example: CURP
          enum:
            - CURP
            - INE
            - PASSPORT
            - SSN
            - OTHER
        dob:
          type: string
          description: Date of birth in ISO 8601 format (YYYY-MM-DD)
          example: '1990-05-15'
        paymentMethod:
          description: >-
            Payment method where the recipient will receive funds. Supports
            bank_account, card, and cash payout methods.
          allOf:
            - $ref: '#/components/schemas/PaymentMethodDto'
        idImage:
          type: string
          description: >-
            ID document image encoded in base64 (data URI or raw base64).
            Supported formats: JPEG, PNG, GIF, WebP. Max size: ~7MB (base64
            encoded). Stored securely and served via temporary signed URLs.
          example: data:image/jpeg;base64,/9j/4AAQSkZJRg...
      required:
        - name
        - paymentMethod
    CreateLinkDataDto:
      type: object
      properties:
        linkId:
          type: string
          description: Unique link identifier
          example: link_acme_a1b2c3d4e5f6
        referenceId:
          type: string
          description: Reference ID of the user in your system
          example: user-12345
        status:
          type: string
          description: Current link status
          example: created
          enum:
            - created
        url:
          type: string
          description: Full widget URL to send to the end user
          example: >-
            https://widget.m2m.leapfinancial.com/link_acme_a1b2c3d4e5f6/m2m-basic
        token:
          type: string
          description: Authentication token for the link (include in link delivery to user)
          example: 550e8400-e29b-41d4-a716-446655440000
        expiresAt:
          type: string
          description: Link expiration timestamp (ISO 8601)
          example: '2026-02-11T12:00:00.000Z'
        createdAt:
          type: string
          description: Link creation timestamp (ISO 8601)
          example: '2026-02-10T12:00:00.000Z'
      required:
        - linkId
        - referenceId
        - status
        - url
        - token
        - expiresAt
        - createdAt
    NameDto:
      type: object
      properties:
        firstName:
          type: string
          description: First name (required)
          example: Juan
        secondName:
          type: string
          description: Second / middle name
          example: Carlos
        lastName:
          type: string
          description: Last name / paternal surname (required)
          example: Pérez
        secondLastName:
          type: string
          description: Second last name / maternal surname
          example: García
      required:
        - firstName
        - lastName
    PaymentMethodDto:
      type: object
      properties:
        type:
          type: string
          enum:
            - bank_account
            - card
            - cash
          description: Type of payment method
          example: bank_account
        bankAccount:
          description: Bank account details (required when type is bank_account)
          allOf:
            - $ref: '#/components/schemas/BankAccountDto'
        card:
          description: Card details (required when type is card)
          allOf:
            - $ref: '#/components/schemas/CardDto'
        cash:
          description: Cash payment details (required when type is cash)
          allOf:
            - $ref: '#/components/schemas/CashDto'
      required:
        - type
    BankAccountDto:
      type: object
      properties:
        country:
          type: string
          description: Country code (ISO 3166-1 alpha-2)
          example: MX
        accountNumber:
          type: string
          description: Bank account number or identifier (CLABE, CBU, IBAN, etc.)
          example: '012345678901234567'
        accountType:
          type: string
          description: Account type (e.g., savings, checking)
        bankCode:
          type: string
          description: Bank code or routing number
        bankName:
          type: string
          description: Bank name
      required:
        - country
        - accountNumber
    CardDto:
      type: object
      properties:
        number:
          type: string
          description: >-
            Card number - Partners send raw PAN through VGS proxy, backend
            receives tokenized value (tok_xxx)
          example: tok_sandbox_4fKq8H2xLmNpRtYw
        expiryMonth:
          type: string
          description: Card expiry month (01-12)
          example: '12'
        expiryYear:
          type: string
          description: Card expiry year (YYYY)
          example: '2028'
        cardholderName:
          type: string
          description: Cardholder name as it appears on the card
          example: Juan Pérez
        last4:
          type: string
          description: >-
            Last 4 digits of the card (can be extracted by VGS or sent by
            partner)
          example: '4242'
        brand:
          type: string
          description: Card brand (can be detected by VGS from BIN or sent by partner)
          example: visa
          enum:
            - visa
            - mastercard
            - amex
            - discover
            - diners
            - jcb
            - unionpay
            - other
      required:
        - number
        - expiryMonth
        - expiryYear
    CashDto:
      type: object
      properties:
        provider:
          type: string
          description: Cash provider (oxxo, walmart, etc.)
        reference:
          type: string
          description: Payment reference number
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your partner API key. Use `m2m_test_*` keys for the sandbox environment.

````