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

# Create a crypto swap

> Swap crypto to crypto, crypto to fiat, or fiat to crypto. Both wallets must belong to your business. The request needs approved KYB and an `Idempotency-Key`. Required scope: `crypto-swap:create`.



## OpenAPI

````yaml /api-reference/crypto/create-swap-openapi.json post /api/external/crypto/swaps
openapi: 3.1.0
info:
  title: Blaaiz Platform API - Create Crypto Swap
  version: 1.0.0
  description: Swap value between business crypto and fiat wallets.
servers:
  - url: https://api-prod.blaaiz.com
  - url: https://api-dev.blaaiz.com
security: []
tags:
  - name: Crypto
paths:
  /api/external/crypto/swaps:
    post:
      tags:
        - Crypto
      summary: Create a crypto swap
      description: >-
        Swap crypto to crypto, crypto to fiat, or fiat to crypto. Both wallets
        must belong to your business. The request needs approved KYB and an
        `Idempotency-Key`. Required scope: `crypto-swap:create`.
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            maxLength: 255
          description: A unique key for this swap request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CryptoSwapRequest'
            example:
              from_wallet: btc-wallet-id
              to_wallet: eth-wallet-id
              amount: '0.50000000'
      responses:
        '200':
          description: Crypto swap processed successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    $ref: '#/components/schemas/CryptoSwapResponseData'
              example:
                message: Crypto swap processed successfully.
                data:
                  type: swap
                  from_wallet_id: btc-wallet-id
                  to_wallet_id: eth-wallet-id
                  from_amount: '0.500000000000000000'
                  fee: '0.000000000000000000'
                  rate: '15'
                  to_amount: '7.500000000000000000'
                  fiat_transaction_id: null
                  fiat_transaction: null
                  from_transaction_id: swap-out-id
                  from_transaction:
                    id: swap-out-id
                    wallet_id: btc-wallet-id
                    type: swap
                    direction: out
                    status: successful
                    currency: BTC
                    amount: '0.500000000000000000'
                  to_transaction_id: swap-in-id
                  to_transaction:
                    id: swap-in-id
                    wallet_id: eth-wallet-id
                    type: swap
                    direction: in
                    status: successful
                    currency: ETH
                    amount: '7.500000000000000000'
        '409':
          description: A request with the same idempotency key is active.
        '422':
          description: >-
            The idempotency key is missing, the amount is not a string, or the
            key was used with different request data.
      security:
        - oauth2ClientCredentials:
            - crypto-swap:create
components:
  schemas:
    CryptoSwapRequest:
      type: object
      required:
        - from_wallet
        - to_wallet
        - amount
      properties:
        from_wallet:
          type: string
          description: The source crypto or fiat wallet ID.
        to_wallet:
          type: string
          description: The destination crypto or fiat wallet ID.
        amount:
          type: string
          pattern: ^[0-9]+(\.[0-9]{1,18})?$
          description: >-
            The source amount. The minimum is 0.00000001. Send a string with up
            to 18 decimal places.
    CryptoSwapResponseData:
      type: object
      required:
        - type
        - from_wallet_id
        - to_wallet_id
        - from_amount
        - fee
        - rate
        - to_amount
        - fiat_transaction_id
        - fiat_transaction
        - from_transaction_id
        - from_transaction
        - to_transaction_id
        - to_transaction
      properties:
        type:
          type: string
          enum:
            - swap
        from_wallet_id:
          type: string
        to_wallet_id:
          type: string
        from_amount:
          type: string
        fee:
          type: string
        rate:
          type: string
        to_amount:
          type: string
        fiat_transaction_id:
          type:
            - string
            - 'null'
        fiat_transaction:
          oneOf:
            - $ref: '#/components/schemas/FiatTransaction'
            - type: 'null'
        from_transaction_id:
          type:
            - string
            - 'null'
        from_transaction:
          oneOf:
            - $ref: '#/components/schemas/CryptoSwapTransaction'
            - type: 'null'
        to_transaction_id:
          type:
            - string
            - 'null'
        to_transaction:
          oneOf:
            - $ref: '#/components/schemas/CryptoSwapTransaction'
            - type: 'null'
    FiatTransaction:
      type: object
      required:
        - id
        - wallet_id
        - reference
        - status
        - currency
        - amount
        - fee
        - net_amount
        - created_at
      properties:
        id:
          type: string
        wallet_id:
          type: string
        reference:
          type: string
        status:
          type: string
        currency:
          type: string
        amount:
          type: string
        fee:
          type: string
        net_amount:
          type: string
        created_at:
          type: string
          format: date-time
    CryptoSwapTransaction:
      type: object
      required:
        - id
        - wallet_id
        - type
        - direction
        - status
        - currency
        - amount
      properties:
        id:
          type: string
        wallet_id:
          type: string
        type:
          type: string
          enum:
            - swap
        direction:
          type: string
          enum:
            - in
            - out
        status:
          type: string
          enum:
            - successful
        currency:
          type: string
        amount:
          type: string
  securitySchemes:
    oauth2ClientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          scopes:
            crypto-swap:create: Swap fiat and crypto wallet balances.

````