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

# Convert between wallets

> Executes a conversion from your `from` wallet to your `to` wallet at the current rate. Both wallets must exist.

Send an `Idempotency-Key`: retrying with the same key returns the original conversion (`200`) instead of converting twice.

**API key scope:** `fx:write`



## OpenAPI

````yaml POST /v1/fx/convert
openapi: 3.1.0
info:
  title: KryptaPay API
  version: 1.0.0
  description: >-
    Collect and pay out across Africa — Mobile Money, bank transfers and
    stablecoins — through one REST API.


    Authenticate every request with your secret API key: `Authorization: Bearer
    kp_<env>_…`.

    All responses use the envelope `{ "ok": boolean, "data"?: …, "error"?: {
    "code", "message", "details"? } }`.
  contact:
    name: KryptaPay Support
    email: support@krypta-pay.com
    url: https://krypta-pay.com
servers:
  - url: https://staging.api.krypta-pay.com
    description: Sandbox
  - url: https://api.krypta-pay.com
    description: Production
security:
  - apiKey: []
tags:
  - name: Payins
    description: Collect money from your customers' Mobile Money wallets.
  - name: Payouts
    description: Send money to Mobile Money wallets, bank accounts and crypto addresses.
  - name: Fees
    description: Know the exact fee before you move money.
  - name: FX
    description: Exchange rates, quotes and conversions between your wallets.
  - name: Wallets
    description: Balances of your multi-currency wallets.
  - name: Transactions
    description: Unified history of every movement on your account.
  - name: Networks
    description: Which payment networks are currently available.
  - name: Status
    description: Public platform status.
paths:
  /v1/fx/convert:
    post:
      tags:
        - FX
      summary: Convert between wallets
      description: >-
        Executes a conversion from your `from` wallet to your `to` wallet at the
        current rate. Both wallets must exist.


        Send an `Idempotency-Key`: retrying with the same key returns the
        original conversion (`200`) instead of converting twice.


        **API key scope:** `fx:write`
      operationId: convertFx
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                from:
                  $ref: '#/components/schemas/Currency'
                to:
                  $ref: '#/components/schemas/Currency'
                amount:
                  type: string
                  pattern: ^\d+(\.\d{1,8})?$
                  description: >-
                    Decimal amount with up to 8 fractional digits, e.g. "1500"
                    or "1500.75"
                reference:
                  type: string
                  maxLength: 64
                  description: >-
                    Your own reference for this conversion. Generated (`tx_…`)
                    when omitted.
              required:
                - from
                - to
                - amount
              additionalProperties: false
            example:
              from: EUR
              to: XOF
              amount: '1000'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      reference:
                        type: string
                      status:
                        type: string
                      fromCurrency:
                        $ref: '#/components/schemas/Currency'
                      toCurrency:
                        $ref: '#/components/schemas/Currency'
                      fromAmount:
                        type: string
                        pattern: ^\d+(\.\d{1,8})?$
                        description: >-
                          Decimal amount with up to 8 fractional digits, e.g.
                          "1500" or "1500.75"
                      toAmount:
                        type: string
                        pattern: ^\d+(\.\d{1,8})?$
                        description: >-
                          Decimal amount with up to 8 fractional digits, e.g.
                          "1500" or "1500.75"
                      midRate:
                        type: string
                      appliedRate:
                        type: string
                      spreadBps:
                        type: number
                      settledAt:
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - reference
                      - status
                      - fromCurrency
                      - toCurrency
                      - fromAmount
                      - toAmount
                      - midRate
                      - appliedRate
                      - spreadBps
                      - settledAt
                    additionalProperties: false
                required:
                  - ok
                  - data
                additionalProperties: false
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      reference:
                        type: string
                      status:
                        type: string
                      fromCurrency:
                        $ref: '#/components/schemas/Currency'
                      toCurrency:
                        $ref: '#/components/schemas/Currency'
                      fromAmount:
                        type: string
                        pattern: ^\d+(\.\d{1,8})?$
                        description: >-
                          Decimal amount with up to 8 fractional digits, e.g.
                          "1500" or "1500.75"
                      toAmount:
                        type: string
                        pattern: ^\d+(\.\d{1,8})?$
                        description: >-
                          Decimal amount with up to 8 fractional digits, e.g.
                          "1500" or "1500.75"
                      midRate:
                        type: string
                      appliedRate:
                        type: string
                      spreadBps:
                        type: number
                      settledAt:
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - reference
                      - status
                      - fromCurrency
                      - toCurrency
                      - fromAmount
                      - toAmount
                      - midRate
                      - appliedRate
                      - spreadBps
                      - settledAt
                    additionalProperties: false
                required:
                  - ok
                  - data
                additionalProperties: false
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Unique key (a UUID is ideal) for this operation. Retrying with the same
        key returns the original result instead of creating a duplicate.
      schema:
        type: string
        maxLength: 128
  schemas:
    Currency:
      type: string
      enum:
        - XOF
        - XAF
        - NGN
        - GHS
        - CDF
        - EUR
        - USD
        - USDC
        - USDT
      description: ISO currency code (fiat) or stablecoin ticker.
    Error:
      type: object
      properties:
        ok:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable, machine-readable code. Branch on this, not on `message`.
            message:
              type: string
              description: Human-readable explanation. May change; do not parse.
            details:
              description: >-
                Extra context. For `validation_error`: `{ formErrors,
                fieldErrors }`.
          required:
            - code
            - message
      required:
        - ok
        - error
  responses:
    Unauthorized:
      description: Missing, invalid or expired API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            ok: false
            error:
              code: unauthorized
              message: Invalid or expired API key
    Forbidden:
      description: >-
        The key lacks the required scope (`insufficient_scope`), or the account
        is not KYB-approved (`kyb_required`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            ok: false
            error:
              code: kyb_required
              message: Your organization must complete KYB verification.
    ValidationError:
      description: >-
        The request failed validation or a business rule. See `error.code` and,
        for `validation_error`, `error.details.fieldErrors`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            ok: false
            error:
              code: validation_error
              message: 'amount: Invalid amount'
    RateLimited:
      description: >-
        Too many requests. Wait for the number of seconds in the `retry-after`
        header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            ok: false
            error:
              code: rate_limited
              message: Rate limit exceeded, retry in 1 minute
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        Secret API key from **Dashboard → Developers**: `kp_sandbox_…` for
        Sandbox, `kp_live_…` for Production. Server-side only.

````

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