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

# Create Order

> Create a new market order for trading between prediction market tokens and on-chain tokens. The order will be processed asynchronously through multiple stages: balance validation, placement on the prediction market, fill detection, and on-chain execution.



## OpenAPI

````yaml openapi.json post /v1/order
openapi: 3.0.0
info:
  title: Swaps API
  description: The Swaps API documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://swap-api.flux.fun
    description: Production
  - url: http://localhost:3000
    description: Development
security: []
tags: []
paths:
  /v1/order:
    post:
      tags:
        - Orders
      summary: Create Order
      description: >-
        Create a new market order for trading between prediction market tokens
        and on-chain tokens. The order will be processed asynchronously through
        multiple stages: balance validation, placement on the prediction market,
        fill detection, and on-chain execution.
      operationId: OrdersController_createOrder
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderDto'
      responses:
        '200':
          description: Order created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOrderResponseDto'
        '400':
          description: Invalid order data
        '401':
          description: Unauthorized - JWT token required
      security:
        - api-key: []
          bearer: []
components:
  schemas:
    CreateOrderDto:
      type: object
      properties:
        orderType:
          type: string
          description: Order type
          enum:
            - MarketOrder
          example: MarketOrder
        order:
          description: Market order details
          allOf:
            - $ref: '#/components/schemas/MarketOrderDataDto'
        chainId:
          type: number
          example: 8453
          description: Chain ID
        includeTokenTransfer:
          type: boolean
          description: Include token transfer in the order
          example: false
        clientId:
          type: string
          description: Client-side order ID
          example: order-123
        userAddress:
          type: string
          description: User wallet address
          example: 0x...
        receiverAddress:
          type: string
          description: Receiver address for tokens
          example: 0x...
      required:
        - orderType
        - order
        - chainId
        - clientId
    CreateOrderResponseDto:
      type: object
      properties:
        success:
          type: boolean
          example: true
        intent:
          $ref: '#/components/schemas/IntentBasicResponseDto'
      required:
        - success
        - intent
    MarketOrderDataDto:
      type: object
      properties:
        quoteToken:
          type: object
          properties:
            type:
              type: string
              enum:
                - kalshi
                - chain
              description: Token type
              example: kalshi
            data:
              description: Token data based on type
              oneOf:
                - $ref: '#/components/schemas/TokenKalshiDto'
                - $ref: '#/components/schemas/TokenChainDto'
          required:
            - type
            - data
        baseToken:
          type: object
          properties:
            type:
              type: string
              enum:
                - kalshi
                - chain
              description: Token type
              example: kalshi
            data:
              description: Token data based on type
              oneOf:
                - $ref: '#/components/schemas/TokenKalshiDto'
                - $ref: '#/components/schemas/TokenChainDto'
          required:
            - type
            - data
        orderType:
          type: string
          description: Order type
          enum:
            - BUY
            - SELL
          example: BUY
        baseQuantity:
          type: string
          description: Quantity of base token (as integer string)
          example: '100'
        minQuoteQuantityOut:
          type: string
          description: Minimum quote quantity out (for SELL orders)
          example: '95'
        maxQuoteQuantityIn:
          type: string
          description: Maximum quote quantity in (for BUY orders)
          example: '105'
      required:
        - quoteToken
        - baseToken
        - orderType
        - baseQuantity
    IntentBasicResponseDto:
      type: object
      properties:
        id:
          type: string
          example: intent_abc123xyz
          description: Unique order intent ID
        clientId:
          type: string
          example: client-order-123
          description: Client-provided order ID
          nullable: true
        action:
          type: object
          description: Order action details
          example:
            orderType: MarketOrder
            order:
              quoteToken:
                type: chain
                data:
                  tokenId: USDC
                  chainId: 8453
                  contractAddress: 0x...
              baseToken:
                type: kalshi
                data:
                  marketId: BTC-100K-2024
                  side: 'yes'
              orderType: BUY
              baseQuantity: '100'
              maxQuoteQuantityIn: '50.00'
            chainId: 8453
        createdAt:
          type: string
          example: '2024-01-12T10:00:00.000Z'
          description: When the order was created
      required:
        - id
        - clientId
        - action
        - createdAt
    TokenKalshiDto:
      type: object
      properties:
        marketId:
          type: string
          description: Kalshi market ID
          example: KXBTC-24NOV30-T65000
        side:
          type: string
          description: Market side
          enum:
            - 'yes'
            - 'no'
          example: 'yes'
      required:
        - marketId
        - side
    TokenChainDto:
      type: object
      properties:
        tokenId:
          type: string
          description: Token ID on chain. For ERC-20 tokens, the token ID must be 0
          example: '0'
        chainId:
          type: number
          example: 8453
          description: Chain ID
        contractAddress:
          type: string
          example: 0x...
          description: Token contract address
      required:
        - tokenId
        - chainId
        - contractAddress
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: x-api-key
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````