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

# Initiate a payment (API key)

> API-key-authenticated variant of payment initiation. Supports single-currency flows only — `currency` and `target_currency` must match. `org_id` and `user_id` are injected automatically from the authenticated API key, so you do not need to include them in the request body.




## OpenAPI

````yaml /api-reference/external/openapi.yaml post /payments-init/initiate/public-payin
openapi: 3.0.3
info:
  title: PCX API
  description: >
    The PCX integration API. Every request requires two headers: `Authorization`
    (Bearer JWT for user-facing flows, or the literal string `NONE`) and
    `X-Api-Key` (your API key for server-to-server calls, or the literal string
    `NONE`). Pass `NONE` for whichever header you are not using.
  version: '1.0'
servers:
  - url: https://prod-api.pcxpay.com/v1
    description: Production
  - url: https://devs.pcxpay.com/v1
    description: Development
security: []
tags:
  - name: Payment Initiation
    description: Initiate payments and poll for status
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Webhooks
    description: Register endpoints and receive transaction notifications
  - name: Beneficiaries
    description: Manage payment recipients
  - name: Payments
    description: Initiate and track payments
  - name: Bank Validation
    description: Validate bank accounts before initiating a payment
  - name: Transactions
    description: Query the financial transaction ledger
  - name: Virtual Accounts
    description: Multi-currency virtual account provisioning and fund operations
  - name: Payment Links
    description: Generate shareable payment links for customer checkout
paths:
  /payments-init/initiate/public-payin:
    parameters:
      - $ref: '#/components/parameters/AuthorizationHeader'
      - $ref: '#/components/parameters/XApiKeyHeader'
    post:
      tags:
        - Payment Initiation
      summary: Initiate a payment (API key)
      description: >
        API-key-authenticated variant of payment initiation. Supports
        single-currency flows only — `currency` and `target_currency` must
        match. `org_id` and `user_id` are injected automatically from the
        authenticated API key, so you do not need to include them in the request
        body.
      operationId: initiatePublicPayin
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicPayinRequest'
      responses:
        '200':
          description: Payment initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentInitiationResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    AuthorizationHeader:
      name: Authorization
      in: header
      required: true
      description: >-
        Bearer JWT for user-facing flows (`Bearer eyJraWQ...`), or the literal
        string `NONE` when authenticating via API key.
      schema:
        type: string
        default: NONE
        example: Bearer eyJraWQ...
    XApiKeyHeader:
      name: X-Api-Key
      in: header
      required: true
      description: >-
        API key for server-to-server flows, or the literal string `NONE` when
        authenticating via JWT.
      schema:
        type: string
        default: NONE
        example: pcx_abc123_xxxx
  schemas:
    PublicPayinRequest:
      type: object
      required:
        - amount
        - target_amount
        - currency
        - target_currency
        - country
        - payment_method
      description: >
        Same as `PaymentInitiationRequest` but `org_id` and `user_id` are
        injected from the authenticated API key — do not include them. Only
        same-currency flows are supported on this endpoint.
      properties:
        amount:
          type: number
          format: float
        target_amount:
          type: number
          format: float
          description: Must equal `amount` (same-currency only).
        currency:
          type: string
          example: KES
        target_currency:
          type: string
          description: Must equal `currency`.
          example: KES
        country:
          type: string
          example: KE
        payment_method:
          type: string
          enum:
            - mobile_money
            - bank_transfer
            - card
        direction:
          $ref: '#/components/schemas/PaymentInitDirection'
        client_reference:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        payer_details:
          type: object
          properties:
            name:
              type: string
            email:
              type: string
              format: email
            phone:
              type: string
        mobile_money_details:
          type: object
          nullable: true
          properties:
            provider:
              type: string
            phone_number:
              type: string
        bank_details:
          type: object
          nullable: true
          properties:
            account_name:
              type: string
            account_number:
              type: string
            bank_name:
              type: string
            country:
              type: string
            bank_code:
              type: string
              nullable: true
        bank_account:
          type: object
          nullable: true
          properties:
            account_number:
              type: string
            bank_code:
              type: string
              nullable: true
            bank_name:
              type: string
        beneficiary_id:
          type: string
          nullable: true
        return_url:
          type: string
          format: uri
          nullable: true
        metadata:
          type: object
          nullable: true
    PaymentInitiationResponse:
      type: object
      properties:
        statusCode:
          type: integer
          example: 200
        response:
          type: object
          properties:
            success:
              type: boolean
            provider_payment_id:
              type: string
            payment_id:
              type: string
            status:
              type: string
            next_action:
              type: string
              enum:
                - instructions
                - redirect
                - wait
              description: >
                `instructions` — display `payment_instructions` to the user
                (e.g. M-PESA STK push sent); `redirect` — redirect to
                `redirect_url`; `wait` — payment processing, no user action
                needed.
            redirect_url:
              type: string
              nullable: true
            payment_instructions:
              type: string
              nullable: true
            expires_at:
              type: string
              format: date-time
        transaction_id:
          type: string
    PaymentInitDirection:
      type: string
      enum:
        - payin
        - payout
      default: payin
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
        status:
          type: string
          enum:
            - error
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'

````