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

# Create Swap Order

> Create a new swap order with on-chain or Lightning settlement

## Settlement Types

* **LIGHTNING**: Instant settlement via Lightning Network
* **ONCHAIN**: Settlement via on-chain Bitcoin transaction

<Tip>Lightning settlement is recommended for faster finality and lower fees.</Tip>


## OpenAPI

````yaml /openapi.json post /api/v1/swaps/orders
openapi: 3.1.0
info:
  title: Kaleidoswap RGB-LSP API
  description: API for managing swaps and channels
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/swaps/orders:
    post:
      tags:
        - swap-orders
      summary: Create Swap Order
      operationId: create_swap_order_api_v1_swaps_orders_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSwapOrderRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSwapOrderResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK - Create Order
          source: >-
            import { KaleidoClient } from 'kaleido-sdk';


            const client = new KaleidoClient({
              baseUrl: 'https://api.staging.kaleidoswap.com/api/v1'
            });


            // First get a quote

            const quote = await client.quoteRequest('BTC',
            'rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak', 1000000);


            // Create order

            const order = await client.createOrder({
              rfq_id: quote.rfq_id,
              from_type: 'ONCHAIN',
              to_type: 'LIGHTNING',
              from_asset: 'BTC',
              to_asset: 'rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak',
              from_amount: 1000000,
              to_amount: quote.to_amount
            });

            console.log(`Order created: ${order.id}`);
        - lang: python
          label: Python SDK - Create Order
          source: |-
            import asyncio
            from kaleido_sdk import KaleidoClient, CreateOrderRequest

            async def main():
                async with KaleidoClient(
                    api_url="https://api.staging.kaleidoswap.com/api/v1"
                ) as client:
                    # First get a quote
                    quote = await client.get_quote(
                        from_asset="BTC",
                        to_asset="rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak",
                        amount=1000000
                    )
                    
                    # Create order
                    order = await client.create_order(
                        CreateOrderRequest(
                            rfq_id=quote.rfq_id,
                            from_type="ONCHAIN",
                            to_type="LIGHTNING",
                            from_asset="BTC",
                            to_asset="rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak",
                            from_amount=1000000,
                            to_amount=quote.to_amount
                        )
                    )
                    print(f"Order created: {order.id}")

            asyncio.run(main())
components:
  schemas:
    CreateSwapOrderRequest:
      properties:
        rfq_id:
          type: string
          minLength: 1
          title: Rfq Id
          description: RFQ ID cannot be empty
        from_type:
          $ref: '#/components/schemas/SwapSettlement'
          description: 'Input type: ONCHAIN or LIGHTNING'
        to_type:
          $ref: '#/components/schemas/SwapSettlement'
          description: 'Output type: ONCHAIN or LIGHTNING'
        min_onchain_conf:
          anyOf:
            - type: integer
            - type: 'null'
          title: Min Onchain Conf
          default: 1
        dest_bolt11:
          anyOf:
            - type: string
            - type: 'null'
          title: Dest Bolt11
        dest_onchain_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Dest Onchain Address
        dest_rgb_invoice:
          anyOf:
            - type: string
            - type: 'null'
          title: Dest Rgb Invoice
        refund_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Refund Address
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          description: Optional email for notifications
      type: object
      required:
        - rfq_id
        - from_type
        - to_type
      title: CreateSwapOrderRequest
    CreateSwapOrderResponse:
      properties:
        id:
          type: string
          title: Id
        rfq_id:
          type: string
          title: Rfq Id
        pay_in:
          $ref: '#/components/schemas/SwapSettlement'
        ln_invoice:
          anyOf:
            - type: string
            - type: 'null'
          title: Ln Invoice
        onchain_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Onchain Address
        rgb_recipient_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Rgb Recipient Id
        rgb_invoice:
          anyOf:
            - type: string
            - type: 'null'
          title: Rgb Invoice
        status:
          $ref: '#/components/schemas/SwapOrderStatus'
      type: object
      required:
        - id
        - rfq_id
        - pay_in
        - status
      title: CreateSwapOrderResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SwapSettlement:
      type: string
      enum:
        - LIGHTNING
        - ONCHAIN
      title: SwapSettlement
    SwapOrderStatus:
      type: string
      enum:
        - OPEN
        - PENDING_PAYMENT
        - PAID
        - EXECUTING
        - FILLED
        - CANCELLED
        - EXPIRED
        - FAILED
        - PENDING_RATE_DECISION
      title: SwapOrderStatus
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````