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

# Collect a payment

> Collect mobile money or request approval from a Sarafa account.

## Mobile collections

Collect KES or UGX into your USD wallet. Use `MPESA` for KES, or `MTN`/`AIRTEL` for UGX. UGX requires the payer's `name`. Supply the payer's phone number with country prefix and 12 digits; an optional leading `+` is accepted.

```json theme={null}
{
  "amount": "1300",
  "currency": "KES",
  "channel": "mobile",
  "account_number": "254712345678",
  "network": "MPESA",
  "reference": "collection-100",
  "callback_url": "https://merchant.example/payments",
  "quote": true
}
```

Illustrative quote; actual pricing is returned by the API:

```json theme={null}
{
  "status": "success",
  "quote": {
    "source_currency": "KES",
    "destination_currency": "USD",
    "amount": "1300",
    "exchange_rate": "130",
    "amount_received": "10",
    "total_fees": "0",
    "total_debit": "1300",
    "pricing": "payswitch_estimate",
    "quote_token": "<token>"
  }
}
```

Submit again with `"quote": false` to collect. You may include the returned `quote_token`; a changed estimate then returns HTTP `409`. Provider acceptance remains pending until settlement. HTTP `202` means the payment is pending or awaiting reconciliation.

## Sarafa approval requests

Request payment in USD or SSP from an eligible Sarafa customer or merchant account:

```json theme={null}
{
  "amount": "10",
  "currency": "USD",
  "channel": "sarafa",
  "account_number": "602600000002",
  "reference": "collection-101",
  "callback_url": "https://merchant.example/payments",
  "quote": false
}
```

The payer must approve within 15 minutes. Creating the request moves no funds. Rejection or expiry fails the payment, with `reason` set to `rejected` or `expired`. Sarafa charges have no additional fee.

Read [payment details](https://docs.sarafa.ss/api-reference/endpoint/getTransaction.md) or process [signed callbacks](https://docs.sarafa.ss/services/api.md) to confirm the outcome. Preserve the reference and original execution payload when retrying.


## OpenAPI

````yaml api-reference/openapi.json POST /charge
openapi: 3.0.3
info:
  title: Sarafa Business API
  version: 3.0.0
  description: >-
    Server-side access to your verified organization's account. Use Bearer API
    keys, decimal-string amounts, and unique merchant references. Charge,
    transfer, and swap default to quotes. Only transaction.status = completed
    confirms payment.
servers:
  - url: https://api.sarafa.site/v3
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Accounts
  - name: Transactions
  - name: Payments
  - name: Checkout
paths:
  /charge:
    post:
      tags:
        - Payments
      summary: Collect a payment
      description: >-
        Collect KES/UGX mobile money into USD, or request USD/SSP approval from
        an eligible Sarafa customer or merchant. Sarafa requests expire after 15
        minutes; creation moves no funds. Quote defaults to true.
      operationId: charge
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChargeRequest'
            examples:
              mobile:
                summary: Quote a KES mobile collection
                value:
                  amount: '1300'
                  currency: KES
                  channel: mobile
                  account_number: '254712345678'
                  network: MPESA
                  reference: collection-100
                  callback_url: https://merchant.example/payments
                  quote: true
              sarafa:
                summary: Request Sarafa payer approval
                value:
                  amount: '10'
                  currency: USD
                  channel: sarafa
                  account_number: '602600000002'
                  reference: collection-101
                  callback_url: https://merchant.example/payments
                  quote: false
      responses:
        '200':
          description: >-
            Quote, or resolved execution. Only transaction.status = completed
            confirms payment.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/QuoteResponse'
                  - $ref: '#/components/schemas/PaymentResponse'
              examples:
                mobileQuote:
                  summary: >-
                    Illustrative mobile estimate; actual pricing is returned by
                    the API.
                  value:
                    status: success
                    quote:
                      source_currency: KES
                      destination_currency: USD
                      amount: '1300'
                      exchange_rate: '130'
                      amount_received: '10'
                      total_fees: '0'
                      total_debit: '1300'
                      pricing: payswitch_estimate
                      quote_token: <token>
        '202':
          description: >-
            Payment pending or awaiting reconciliation. Example: Sarafa approval
            request.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentResponse'
              example:
                status: success
                transaction:
                  tx_reference: TX7A2B9C4D1E0
                  reference: collection-101
                  transaction_type: credit
                  product: sarafa_charge
                  description: Payment approval request
                  amount: '10'
                  total_amount: '10'
                  total_fees: '0'
                  currency: USD
                  channel: Sarafa
                  status: pending
                  created_at: '2026-10-30T10:00:00.000Z'
                  updated_at: '2026-10-30T10:00:00.000Z'
                  exchange_details: null
                  expires_at: '2026-10-30T10:15:00.000Z'
                  reason: null
                quote:
                  source_currency: USD
                  destination_currency: USD
                  amount: '10'
                  exchange_rate: '1'
                  amount_received: '10'
                  total_fees: '0'
                  total_debit: '10'
                  pricing: temporary_fixed
        '400':
          $ref: '#/components/responses/Error400'
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          $ref: '#/components/responses/Error404'
        '409':
          $ref: '#/components/responses/Error409'
        '500':
          $ref: '#/components/responses/Error500'
        '503':
          $ref: '#/components/responses/Error503'
components:
  schemas:
    ChargeRequest:
      oneOf:
        - $ref: '#/components/schemas/SarafaChargeRequest'
        - $ref: '#/components/schemas/MobileKESChargeRequest'
        - $ref: '#/components/schemas/MobileUGXChargeRequest'
    QuoteResponse:
      type: object
      required:
        - status
        - quote
      properties:
        status:
          type: string
          enum:
            - success
        quote:
          $ref: '#/components/schemas/Quote'
    PaymentResponse:
      type: object
      required:
        - status
        - transaction
        - quote
      properties:
        status:
          type: string
          enum:
            - success
        transaction:
          $ref: '#/components/schemas/PaymentTransaction'
        quote:
          $ref: '#/components/schemas/NullableQuote'
    SarafaChargeRequest:
      type: object
      required:
        - amount
        - reference
        - callback_url
        - channel
        - currency
        - account_number
      properties:
        amount:
          type: string
          pattern: ^[0-9]+([.][0-9]{1,18})?$
          description: >-
            Positive decimal string, not a JSON number. Zero is invalid.
            Currency-specific precision and payment limits also apply.
          example: '100.00'
        reference:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Your idempotency reference, unique across charge, transfer, swap,
            and checkout creation within your organization. Reuse it with
            unchanged details for execution retries.
        callback_url:
          type: string
          format: uri
          pattern: ^https://
          description: >-
            HTTPS URL without embedded credentials. Required even for quotes.
            Receives signed payment callbacks.
          example: https://merchant.example/payments
        quote:
          type: boolean
          default: true
          description: >-
            True returns a quote without moving funds or creating a transaction.
            Set false to execute.
        channel:
          type: string
          enum:
            - sarafa
        currency:
          type: string
          enum:
            - USD
            - SSP
        account_number:
          type: string
          pattern: ^\d{12,13}$
          description: Eligible payer customer or merchant account.
          example: '602600000002'
      additionalProperties: false
    MobileKESChargeRequest:
      type: object
      required:
        - amount
        - reference
        - callback_url
        - channel
        - currency
        - account_number
        - network
      properties:
        amount:
          type: string
          pattern: ^[0-9]+([.][0-9]{1,18})?$
          description: KES amount with up to two decimal places.
          example: '100.00'
        reference:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Your idempotency reference, unique across charge, transfer, swap,
            and checkout creation within your organization. Reuse it with
            unchanged details for execution retries.
        callback_url:
          type: string
          format: uri
          pattern: ^https://
          description: >-
            HTTPS URL without embedded credentials. Required even for quotes.
            Receives signed payment callbacks.
          example: https://merchant.example/payments
        quote:
          type: boolean
          default: true
          description: >-
            True returns a quote without moving funds or creating a transaction.
            Set false to execute.
        channel:
          type: string
          enum:
            - mobile
        currency:
          type: string
          enum:
            - KES
        account_number:
          type: string
          pattern: ^\+?254\d{9}$
          description: Phone number with country prefix and 12 digits; optional leading +.
          example: '254712345678'
        network:
          type: string
          enum:
            - MPESA
        name:
          type: string
          minLength: 1
          maxLength: 160
          description: Payer name. Required for UGX.
        quote_token:
          type: string
          description: >-
            Optional mobile estimate token. A changed estimate returns 409.
            Preserve this value on execution retries.
      additionalProperties: false
    MobileUGXChargeRequest:
      type: object
      required:
        - amount
        - reference
        - callback_url
        - channel
        - currency
        - account_number
        - network
        - name
      properties:
        amount:
          type: string
          pattern: ^[0-9]+([.][0-9]{1,18})?$
          description: Whole UGX amount.
          example: '100.00'
        reference:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Your idempotency reference, unique across charge, transfer, swap,
            and checkout creation within your organization. Reuse it with
            unchanged details for execution retries.
        callback_url:
          type: string
          format: uri
          pattern: ^https://
          description: >-
            HTTPS URL without embedded credentials. Required even for quotes.
            Receives signed payment callbacks.
          example: https://merchant.example/payments
        quote:
          type: boolean
          default: true
          description: >-
            True returns a quote without moving funds or creating a transaction.
            Set false to execute.
        channel:
          type: string
          enum:
            - mobile
        currency:
          type: string
          enum:
            - UGX
        account_number:
          type: string
          pattern: ^\+?256\d{9}$
          description: Phone number with country prefix and 12 digits; optional leading +.
          example: '256772123456'
        network:
          type: string
          enum:
            - MTN
            - AIRTEL
        name:
          type: string
          minLength: 1
          maxLength: 160
          description: Payer name. Required for UGX.
        quote_token:
          type: string
          description: >-
            Optional mobile estimate token. A changed estimate returns 409.
            Preserve this value on execution retries.
      additionalProperties: false
    Quote:
      type: object
      required:
        - source_currency
        - destination_currency
        - amount
        - exchange_rate
        - amount_received
        - total_fees
        - total_debit
        - pricing
      properties:
        source_currency:
          type: string
        destination_currency:
          type: string
        amount:
          type: string
          description: Decimal string.
        exchange_rate:
          type: string
          description: Decimal string.
        amount_received:
          type: string
          description: Decimal string.
        total_fees:
          type: string
          description: Decimal string.
        total_debit:
          type: string
          description: Decimal string.
        pricing:
          type: string
          enum:
            - temporary_fixed
            - payswitch_estimate
            - payswitch_accepted
        quote_token:
          type: string
          description: >-
            Optional token returned for mobile estimates. Include it on
            execution to detect a changed estimate, and preserve it on execution
            retries.
    PaymentTransaction:
      allOf:
        - $ref: '#/components/schemas/Transaction'
        - type: object
          required:
            - exchange_details
          properties:
            exchange_details:
              type: object
              required:
                - from_currency
                - to_currency
                - rate
                - total
              properties:
                from_currency:
                  type: string
                to_currency:
                  type: string
                rate:
                  type: string
                  description: Decimal string.
                total:
                  type: string
                  description: Decimal string.
              nullable: true
            expires_at:
              type: string
              format: date-time
              description: >-
                Present on approval requests; approval expires 15 minutes after
                creation.
            reason:
              type: string
              nullable: true
              description: >-
                Present on approval requests; rejected or expired when
                applicable.
    NullableQuote:
      type: object
      required:
        - source_currency
        - destination_currency
        - amount
        - exchange_rate
        - amount_received
        - total_fees
        - total_debit
        - pricing
      properties:
        source_currency:
          type: string
        destination_currency:
          type: string
        amount:
          type: string
          description: Decimal string.
        exchange_rate:
          type: string
          description: Decimal string.
        amount_received:
          type: string
          description: Decimal string.
        total_fees:
          type: string
          description: Decimal string.
        total_debit:
          type: string
          description: Decimal string.
        pricing:
          type: string
          enum:
            - temporary_fixed
            - payswitch_estimate
            - payswitch_accepted
        quote_token:
          type: string
          description: >-
            Optional token returned for mobile estimates. Include it on
            execution to detect a changed estimate, and preserve it on execution
            retries.
      nullable: true
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: string
          enum:
            - failed
        error:
          type: string
        request_id:
          type: string
          description: >-
            Present on processing errors. Every response also includes
            X-Request-Id.
        issues:
          type: array
          items:
            type: object
            required:
              - path
              - message
            properties:
              path:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer
              message:
                type: string
    Transaction:
      allOf:
        - $ref: '#/components/schemas/TransactionSummary'
        - type: object
          required:
            - currency
            - reference
          properties:
            currency:
              type: string
            reference:
              type: string
              nullable: true
              description: Merchant reference, or null for records without API identity.
    TransactionSummary:
      type: object
      required:
        - tx_reference
        - transaction_type
        - product
        - description
        - amount
        - total_amount
        - total_fees
        - channel
        - status
        - created_at
        - updated_at
      properties:
        tx_reference:
          type: string
          description: >-
            Sarafa payment reference. Newly generated references are 13
            characters; existing longer references remain valid.
          example: TX7A2B9C4D1E0
        transaction_type:
          type: string
          enum:
            - credit
            - debit
        product:
          type: string
        description:
          type: string
        amount:
          type: string
          description: Decimal string.
        total_amount:
          type: string
          description: Decimal string.
        total_fees:
          type: string
          description: Decimal string.
        channel:
          type: string
        status:
          type: string
          description: >-
            Payment state. Only completed confirms payment; pending and
            needs_review are not final. Failed approvals can include a rejection
            or expiry reason.
          example: pending
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  headers:
    RequestId:
      description: Include this request identifier when contacting support.
      schema:
        type: string
  responses:
    Error400:
      description: >-
        Invalid JSON, fields, amount, precision, or currency/channel
        combination.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error401:
      description: Missing, invalid, inactive, or revoked API key.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error403:
      description: Required verification or authorization missing.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error404:
      description: Resource not found within your organization.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error409:
      description: >-
        Conflicting reference, insufficient balance, changed quote, or
        payment-state conflict.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error500:
      description: >-
        Processing failure. Retry uncertain executions with the same reference
        and unchanged payload.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error503:
      description: >-
        Service failure. Retry uncertain executions with the same reference and
        unchanged payload.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: sfb_live_<public_identifier>.<secret>
      description: >-
        Use the full key from the merchant dashboard API section. Keep it on
        your server.

````

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