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

# Create swap

> Creates a Solana EURC↔USDC swap and returns a deposit address.
RemitFlex does not custody funds. Deposit the `from` token to `depositAddress` before expiry.
`refundTo` is always required. Tied to `customerId` (defaults to org primary customer).
Requires `api:write` scope and an `Idempotency-Key` header.




## OpenAPI

````yaml /openapi.yaml post /swaps
openapi: 3.1.0
info:
  title: Remitflex API
  version: 1.0.0
  description: >
    Programmatic access to Remitflex payment routes, fiat rates, customers, and
    transactions.


    **Dashboard:** Create API keys at https://dashboard.remitflex.io


    **Authentication:** Send your API key as `Authorization: Bearer
    rmf_live_...` or `rmf_test_...`.


    **Idempotency:** Mutating requests (`POST`, `PUT`, `PATCH`, `DELETE`)
    require an `Idempotency-Key` header when authenticated with an API key.
servers:
  - url: http://localhost:4000/v1
    description: Local development
  - url: https://api.remitflex.io/v1
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /swaps:
    post:
      tags:
        - Swaps
      summary: Create swap
      description: >
        Creates a Solana EURC↔USDC swap and returns a deposit address.

        RemitFlex does not custody funds. Deposit the `from` token to
        `depositAddress` before expiry.

        `refundTo` is always required. Tied to `customerId` (defaults to org
        primary customer).

        Requires `api:write` scope and an `Idempotency-Key` header.
      operationId: createSwap
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSwapRequest'
      responses:
        '201':
          description: Swap created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Swap'
              examples:
                success:
                  $ref: cf1db60d-99b1-4942-b7fd-b61210f5589e
        '400':
          description: Missing Idempotency-Key
          content:
            application/json:
              examples:
                error:
                  value:
                    status: error
                    message: Idempotency-Key header is required for API key requests
        '422':
          description: Validation error or unsupported pair
          content:
            application/json:
              examples:
                error:
                  value:
                    status: error
                    message: Unsupported currency pair
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: bash
          label: curl
          source: |
            curl -X POST https://api.remitflex.io/v1/swaps \
              -H "Authorization: Bearer $REMITFLEX_API_KEY" \
              -H "Idempotency-Key: $(uuidgen)" \
              -H "Content-Type: application/json" \
              -d '{"from":"USDC","to":"EURC","amount":100,"tradeType":"exact_input","destinationAddress":"2dudFU32c5wsRpfRZDXBAJFirHC4hindqpKSCwwtDaAB","refundTo":"2dudFU32c5wsRpfRZDXBAJFirHC4hindqpKSCwwtDaAB"}'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        Unique key for safe retries on mutating API-key requests. Cached for 24
        hours per org, method, and path.
      schema:
        type: string
        maxLength: 255
        example: 7f3c2a1b-4e5d-6c7b-8a9f-0e1d2c3b4a5f
  schemas:
    CreateSwapRequest:
      type: object
      required:
        - from
        - to
        - amount
        - destinationAddress
        - refundTo
      properties:
        from:
          type: string
          enum:
            - USDC
            - EURC
          example: USDC
          description: Source currency on Solana.
        to:
          type: string
          enum:
            - USDC
            - EURC
          example: EURC
          description: Destination currency on Solana.
        amount:
          type: number
          exclusiveMinimum: 0
          maximum: 1000000000
          example: 100
          description: >
            Human-readable amount. For `exact_input`, amount to send. For
            `exact_output`, amount to receive.
        tradeType:
          type: string
          enum:
            - exact_input
            - exact_output
          default: exact_input
          description: Whether `amount` is the send side or receive side.
        destinationAddress:
          type: string
          minLength: 32
          maxLength: 64
          example: 2dudFU32c5wsRpfRZDXBAJFirHC4hindqpKSCwwtDaAB
          description: Solana address to receive swapped tokens.
        refundTo:
          type: string
          minLength: 32
          maxLength: 64
          example: 2dudFU32c5wsRpfRZDXBAJFirHC4hindqpKSCwwtDaAB
          description: Solana address for Relay refunds (always required).
        customerId:
          type: string
          minLength: 1
          maxLength: 128
          description: Customer under your org. Defaults to the org primary customer.
    SuccessEnvelope:
      type: object
      properties:
        status:
          type: string
          example: success
        message:
          type: string
        data:
          nullable: true
    Swap:
      type: object
      properties:
        id:
          type: string
          format: uuid
        customerId:
          type: string
          format: uuid
        customerName:
          type: string
        status:
          type: string
          enum:
            - awaiting_deposit
            - deposit_received
            - swapping
            - completed
            - failed
            - expired
            - cancelled
            - refunded
        from:
          type: string
        to:
          type: string
        tradeType:
          type: string
          enum:
            - exact_input
            - exact_output
        amount:
          type: number
        expectedAmount:
          type: string
          description: Atomic units for the request amount (send or receive per tradeType).
        sendAmount:
          type: string
          nullable: true
          description: Atomic units the payer should send (from Relay quote).
        sendAmountHuman:
          type: number
          nullable: true
        receivedAmount:
          type: string
          nullable: true
        outputAmount:
          type: string
          nullable: true
        rate:
          type: number
          nullable: true
        feeBps:
          type: integer
        depositAddress:
          type: string
          description: Relay Solana deposit address for the origin token.
        relayRequestId:
          type: string
          nullable: true
        relayStatus:
          type: string
          nullable: true
        refundTo:
          type: string
          nullable: true
        originChainId:
          type: integer
          example: 792703809
        destinationAddress:
          type: string
        depositTxHash:
          type: string
          nullable: true
        inTxHashes:
          type: array
          items:
            type: string
        outTxHashes:
          type: array
          items:
            type: string
        errorMessage:
          type: string
          nullable: true
          description: Human-readable failure/refund reason when terminal.
        expiresAt:
          type: string
          format: date-time
        completedAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        expectedOutput:
          type: number
          nullable: true
        receivedOutput:
          type: number
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: >
        API key created in the Remitflex Dashboard at dashboard.remitflex.io
        (`rmf_live_...` or `rmf_test_...`).

        Key management endpoints require a dashboard JWT and are not part of
        this reference.

````