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

# Get a combined platform + exchange fee quote for a prospective trade

> Prices a trade you are considering WITHOUT submitting it: for a market order (`order_type=market`, `price` omitted) the live orderbook is walked for `quantity` to compute a size-weighted executable price; for a limit order (`order_type=limit`) `price` is required and used as the resting quote. Shares the exact computation used by the WebSocket RFQ stream (`subscribe_fee_quote`), so the two surfaces can never price a trade differently.
Quotes are display-only, degrade-open estimates (`is_estimate: true`) — the authoritative fee is computed at fill time. If no fresh orderbook is available, every numeric field is a `"0"` placeholder and `pricing_unavailable: true`; callers MUST check that flag rather than rendering the zeros as a real quote.
Supported `exchange_id` values: `polymarket`, `kalshi`, `predictfun`.
**Auth & scope.** Requires `trade:read`.



## OpenAPI

````yaml /openapi/execution.yaml get /orders/fee-quote
openapi: 3.1.0
info:
  title: Kairos Order Execution API
  version: 1.0.0
  summary: >-
    Order entry, cancellation, fee quotes, and live position exposure across
    venues.
  description: >
    The Order Execution API at `execution.kairos.trade` places and manages

    orders across every venue Kairos integrates. Two lanes:


    - **Custodial** (`POST /orders`) — Kairos signs and routes on your behalf
      (custodial signing). Async ack: a 200 means validated + enqueued; track via
      `GET /orders/{order_id}` or the WebSocket order/fill stream.
    - **Self-custody / external signing** (`POST /v2/orders/intent` +
      `POST /v2/orders/submit`) — for allow-listed institutional accounts on
      Polymarket and Predict.fun: Kairos builds the EIP-712 payload, you sign
      with your own key, submission is synchronous with the venue's verbatim
      result. `POST /v2/onchain/intent` + `POST /v2/onchain/submit` are the
      same pattern for on-chain operations (approvals, redeem, split/merge,
      unwrap) on Polygon, where you also pay the gas.

    ## Authentication


    All endpoints require a Kairos API key (`X-Client-Id` + `X-Api-Key` +

    `X-Api-Secret`) or a first-party session JWT, plus the per-operation

    scope (`trade:execute`, `trade:read`, `position:read`) where the operation

    documents one. Synthetic Books accepts any otherwise-valid account

    credential without an extra scope or allowlist. There is

    no anonymous tier. Scope checks apply to API-key credentials only; a

    session JWT carries no scope list and is treated as holding every scope.


    The custodial mutation endpoints (`POST /orders`, the three cancel

    endpoints) and Synthetic Books create/refresh/release carry an additional

    `RequireServiceToken` gate satisfied by **any** of: the full API-key triple,

    an internal `X-Service-Token`, or a valid `X-Csrf-Token`. API-key consumers

    need no extra header — but a bare `Authorization: Bearer <jwt>` alone is NOT

    sufficient on those routes. The `/v2/orders/*` and `/v2/onchain/*`

    external-signing routes have no such gate: a session JWT alone works there.


    ## Rate limits


    Order submission is capped per user (default 5 orders per **second**,

    sliding window, `ORDER_RATE_LIMIT_PER_SEC`); some credentials carry an

    `orders` override, which is enforced on its own per-credential window of

    the same duration *in addition to* the per-user window — either one

    denying is a `429`. Idempotent replays (same `client_order_id`) return the

    existing order before the limiter runs and never consume a slot. The

    limiter is Redis-backed and **fails closed**: if Redis is unreachable the

    submission is denied with `429`.


    Separately, repeated *authentication failures* from one client IP are

    throttled at 10 failures per 60 s (also fail-closed). That limiter returns

    the minimal `{"error": "Too many authentication attempts"}` body.


    **No rate-limit headers.** This service does not emit `Retry-After`,

    `X-RateLimit-*`, or any other backoff hint on a `429` — back off on your

    own schedule.


    ## Error responses


    **Six different error body shapes are in use across this service and they

    are not interchangeable.** Check the shape documented on the specific

    operation before writing a parser; a client that assumes one shape will

    read `undefined` for the reason on the others.


    1. `OrderErrorResponse` — the structured envelope (`error`, `code`,
       `error_details{code,message,details?,metadata?,actions}`) returned by
       every handler that surfaces an `ExecutionError`/`ApiError`: order
       submission, cancel-all, the CTF endpoints, the Polymarket/Opinion
       onboarding endpoints, Hyperliquid withdraw/transfer, and most of the
       deposit-wallet family. Note the two `code` fields differ in case:
       top-level `code` is PascalCase (`"AuthInsufficientScope"`), while
       `error_details.code` is the SCREAMING_SNAKE_CASE wire code
       (`"AUTH_INSUFFICIENT_SCOPE"`). Match on `error_details.code`.
    2. `OrderSimpleErrorResponse` — the minimal `{"error": "..."}` (sometimes
       with `code`) used by the auth middleware (any endpoint's
       `401`/`403`/`429`), the whole `/v2/*` external-signing and on-chain
       lane, the Kalshi and Predict.fun endpoints.
    3. `OrderMarketLinkErrorResponse` — `{"message": "..."}`, with no `error`
       and no `code`. Used by `POST /orders/market-links` **only**.
    4. **Empty or plain-text, not JSON at all.** Several deposit-wallet
       endpoints — most importantly
       the RPC signed-batch submission and
       `POST /exchanges/polymarket/imported/relay-info` — return most 4xx/5xx
       responses with a **completely empty body** and `content-type:
       text/plain`. A handful of cases carry a bare plain-text sentence
       (`batch is not an allowed withdrawal or collateral conversion`,
       `relayer rejected batch: …`). Do not attempt to JSON-parse these.
    5. Handlers whose Rust signature returns a bare `StatusCode` likewise send
       **no body at all**; those responses are marked "empty body (status code
       only)".
    6. `SyntheticBookErrorResponse` — `{"error": "stable_snake_case_code",
       "message": "...", "details"?: {...}}` on `/v1/synthetics*`. Match the
       top-level `error`; upstream definition validation may be nested under
       `details`.

    A further wrinkle inside shape 1: some provider-access checks discard the

    specific reason and return a generic `"Request failed with status 403"` /

    `AUTH_CREDENTIALS_INVALID` body, while others preserve

    `AUTH_INSUFFICIENT_SCOPE` and the real message. Do not rely on the message

    text of an access denial being stable.


    The central `ExecutionError` → HTTP mapping (`ApiError::from`) is:


    | `ExecutionError` | Status | `error_details.code` |

    |---|---|---|

    | `InsufficientBalance` | 400 | `FUNDS_INSUFFICIENT_USDC` |

    | `CollateralLocation` | 400 | `FUNDS_COLLATERAL_LOCATION` |

    | `InvalidOrder` | 400 | `VALIDATION_INVALID_ORDER` |

    | `PositionShortfall` | 400 | `FUNDS_INSUFFICIENT_BALANCE` |

    | `MarketClosed` | 400 | `EXCHANGE_POLYMARKET_MARKET_CLOSED` |

    | `OrderAlreadyCancelled` | 400 | `VALIDATION_INVALID_ORDER` |

    | `UnsupportedExchange` | 400 | `EXCHANGE_UNSUPPORTED` |

    | `SlippageExceeded` | 400 | `MARKET_FOK_NOT_FILLED` |

    | `FokNotFilled` | 400 | `MARKET_FOK_NOT_FILLED` |

    | `AuthenticationError` | 401 | `AUTH_CREDENTIALS_INVALID` |

    | `CredentialError` | 401 | `AUTH_CREDENTIALS_NOT_FOUND` |

    | `MarketNotFound` | 404 | `VALIDATION_MARKET_NOT_FOUND` |

    | `OrderNotFound` | 404 | `VALIDATION_INVALID_ORDER` |

    | `MarketNotSettledOnChain` | 409 | `VALIDATION_MARKET_NOT_SETTLED_ON_CHAIN`
    |

    | `OrderbookUnavailable` | 422 | `ORDERBOOK_UNAVAILABLE` |

    | `ExchangeError` (code `429`/`RATE_LIMITED`) | 429 |
    `EXCHANGE_POLYMARKET_RATE_LIMITED` |

    | `ExchangeError` (code `401`/`UNAUTHORIZED`) | 401 |
    `AUTH_POLYMARKET_API_KEY_INVALID` |

    | `SigningError` | 500 | `SIGNATURE_ERROR` |

    | `DatabaseError` | 500 | `DATABASE_ERROR` |

    | `InternalError` / `LedgerReconciliationRequired` /
    `SponsoredRequestWedged` / `PreTradeError` | 500 | `INTERNAL_ERROR` |

    | `NetworkError`, `ExchangeError` (any other code) | 502 | `NETWORK_ERROR` /
    venue-classified |

    | `LockError` | 503 | `INTERNAL_ERROR` |

    | `Timeout` | 504 | `NETWORK_TIMEOUT` |


    A venue `ExchangeError` is further classified from the venue's own message

    text before it is mapped, so an "allowance is not enough" rejection becomes

    `ALLOWANCE_CTF_NOT_SET`, a "not enough balance" rejection becomes

    `FUNDS_INSUFFICIENT_BALANCE`, "post-only mode" becomes `MARKET_NOT_READY`,

    a "no liquidity" rejection becomes `MARKET_INSUFFICIENT_LIQUIDITY`, and so

    on. Match on `error_details.code`, never on `error`.


    ## Server-level guards


    Every request is subject to a 120 s timeout (`OE_REQUEST_TIMEOUT_SECS`), a

    2 MiB request-body cap (`OE_MAX_BODY_BYTES`, over-size bodies get `413`),

    and a 1024-request global concurrency ceiling

    (`OE_MAX_CONCURRENT_REQUESTS`). Every response carries
    `X-Content-Type-Options:

    nosniff`, `X-Frame-Options: DENY`, HSTS, and a `default-src 'none'` CSP.


    ## Conventions


    - Prices are decimal strings on the 0–1 scale; `*_bps` fields are the
      same value in basis points (× 10000).
    - Quantities/sizes are decimal strings.

    - Structured errors carry `error_details.code`
      (SCREAMING_SNAKE_CASE) plus actionable recovery `actions`.

    ## Changelog


    **2026-09-14 — collateral routing fields on `POST /orders`.** Four optional

    request fields and one optional response field. `collateral`

    (`skip` | `check` | `fund`) **defaults to** `skip`, which is exactly today's

    path: no affordability check, no hold, no funding, zero added latency — so

    no existing caller changes behaviour without opting in. `shard_funding`

    **defaults to** `true`, which is also exactly today's behaviour: the Kalshi

    shard move is same-venue, zero-fee and already runs for every account; send

    `false` to opt out. `collateral=fund` requires both `max_bridge_fee_usdc`

    and `max_funding_wait_ms` and is rejected `400` naming the missing cap;

    either cap without `fund` is likewise a `400`. The response gains

    `funding`, `null` whenever no funding work ran. FIX sessions carry the same

    fields on `NewOrderSingle(D)` as optional tags `5701`–`5704`; a session that

    sends none of them is unchanged.
  contact:
    name: Kairos
    url: https://app.kairos.trade/docs/api-reference
  termsOfService: https://kairos.trade/terms
servers:
  - url: https://execution.kairos.trade
    description: Production (central primary, us-east-1)
  - url: https://eu-west-1-polymarket.executor.kairos.trade
    description: >-
      Production regional execution node — Ireland, colocated with Polymarket.
      Same API surface; assigned at onboarding.
  - url: https://ap-northeast-1-predictfun.executor.kairos.trade
    description: >-
      Production regional execution node — Tokyo, colocated with Predict.fun.
      Same API surface; assigned at onboarding.
  - url: https://staging-execution.kairos.trade
    description: Staging
security:
  - apiKeyClientId: []
    apiKeyKey: []
    apiKeySecret: []
paths:
  /orders/fee-quote:
    get:
      tags:
        - Orders
      summary: Get a combined platform + exchange fee quote for a prospective trade
      description: >-
        Prices a trade you are considering WITHOUT submitting it: for a market
        order (`order_type=market`, `price` omitted) the live orderbook is
        walked for `quantity` to compute a size-weighted executable price; for a
        limit order (`order_type=limit`) `price` is required and used as the
        resting quote. Shares the exact computation used by the WebSocket RFQ
        stream (`subscribe_fee_quote`), so the two surfaces can never price a
        trade differently.

        Quotes are display-only, degrade-open estimates (`is_estimate: true`) —
        the authoritative fee is computed at fill time. If no fresh orderbook is
        available, every numeric field is a `"0"` placeholder and
        `pricing_unavailable: true`; callers MUST check that flag rather than
        rendering the zeros as a real quote.

        Supported `exchange_id` values: `polymarket`, `kalshi`, `predictfun`.

        **Auth & scope.** Requires `trade:read`.
      operationId: getFeeQuote
      parameters:
        - name: exchange_id
          in: query
          required: true
          description: One of `polymarket`, `kalshi`, `predictfun`.
          schema:
            type: string
            enum:
              - polymarket
              - kalshi
              - predictfun
            example: polymarket
        - name: market_id
          in: query
          required: false
          description: >-
            Condition id (Polymarket). Required for Polymarket if `token_id` is
            omitted.
          schema:
            type: string
        - name: token_id
          in: query
          required: false
          description: >-
            CLOB token id (Polymarket) — preferred over `market_id` for book/fee
            lookup.
          schema:
            type: string
            example: '71360012345678901234567890123456789012345678901234567890123456'
        - name: quantity
          in: query
          required: true
          description: Decimal string. Number of shares/contracts to quote. Must be > 0.
          schema:
            type: string
            example: '100'
        - name: side
          in: query
          required: true
          description: >-
            The quote is side-aware (walks the ask side for buy, the bid side
            for sell).
          schema:
            type: string
            enum:
              - buy
              - sell
            example: buy
        - name: price
          in: query
          required: false
          description: >-
            Decimal string in `(0, 1]`. Required when `order_type=limit` (the
            resting price). Omit for `order_type=market` to have the server
            price off the live book.
          schema:
            type: string
            example: '0.52'
        - name: order_type
          in: query
          required: true
          description: >-
            `market` (taker, priced from the book) or `limit` (maker, priced at
            `price`).
          schema:
            type: string
            enum:
              - market
              - limit
            example: market
      responses:
        '200':
          description: Combined platform + exchange fee quote.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderFeeQuoteResponse'
        '400':
          description: >-
            Unsupported `exchange_id`, invalid `order_type`/`side`, non-positive
            `quantity`, `price` out of `(0, 1]`, a limit order missing `price`,
            or a Polymarket quote missing both `token_id` and `market_id`. Empty
            body (status code only) — the specific validation failure is logged
            server-side but never returned.
        '401':
          $ref: '#/components/responses/ExecUnauthorized'
        '403':
          description: >-
            Missing `trade:read` scope, or API-key access to this provider is
            disabled. Empty body (status code only).
        '503':
          description: >-
            API-key access to this provider could not be checked (fails closed).
            Empty body (status code only).
components:
  schemas:
    OrderFeeQuoteResponse:
      type: object
      description: >-
        Response for `GET /orders/fee-quote`. All numeric fields are decimal
        strings in USDC. The WebSocket `subscribe_fee_quote` stream emits a
        near-identical frame, but it omits `venue_reserve_fee_usdc` — do not
        treat the two as interchangeable. See `execution-ws.asyncapi.yaml`.
      required:
        - avg_price_usdc
        - filled_size
        - requested_size
        - sufficient_liquidity
        - notional_usdc
        - platform_fee_usdc
        - exchange_fee_usdc
        - venue_reserve_fee_usdc
        - total_fee_usdc
        - total_cost_usdc
        - pricing_unavailable
        - is_estimate
        - funding_tier
        - bridge_fee_usdc
        - bridge_eta_p50_ms
        - bridge_eta_p95_ms
        - bridge_route_label
        - bridge_min_txs
        - bridge_eta_state
        - bridge_quote_unavailable
        - bridge_beta
      properties:
        avg_price_usdc:
          type: string
          description: >-
            Size-weighted executable price (VWAP for a market order), or the
            limit price for a limit order.
          example: '0.52'
        filled_size:
          type: string
          description: >-
            Size the book can actually fill; equals `requested_size` when
            liquidity suffices.
          example: '100'
        requested_size:
          type: string
          description: The size the caller asked to quote (echoes `quantity`).
          example: '100'
        sufficient_liquidity:
          type: boolean
          description: False when the book cannot fill the full `requested_size`.
        notional_usdc:
          type: string
          description: '`filled_size × avg_price_usdc`.'
        platform_fee_usdc:
          type: string
          description: >-
            Kairos platform fee, based on the caller's fee tier. `"0"` if the
            tier lookup failed (fails open, never a phantom rate).
        exchange_fee_usdc:
          type: string
          description: >-
            Venue-specific fee the caller is expected to pay. `"0"` on venues
            that only charge takers when this quote is a resting maker order.
        venue_reserve_fee_usdc:
          type: string
          description: >-
            Fee the VENUE actually reserves to accept the order — distinct from
            `exchange_fee_usdc`. Some venues (Polymarket CLOB) can't know a
            resting limit will stay maker, so they reserve the taker estimate at
            placement regardless; buy-affordability checks must size off this
            field, not `exchange_fee_usdc`.
        total_fee_usdc:
          type: string
          description: '`platform_fee_usdc + exchange_fee_usdc`.'
        exchange_fee_note:
          type: string
          nullable: true
          description: Human-readable note on the exchange fee, e.g. "1.8% taker fee".
        total_cost_usdc:
          type: string
          description: >-
            All-in cost — for a buy, `notional + fees`; for a sell, `proceeds =
            notional − fees`.
        pricing_unavailable:
          type: boolean
          description: >-
            `true` when no executable price was available (no client price and
            no fresh orderbook) — every other numeric field is a placeholder
            `"0"` and MUST NOT be rendered as a real quote.
        is_estimate:
          type: boolean
          description: >-
            Always `true` — this is a display estimate; the authoritative fee is
            computed at fill time.
        funding_tier:
          type: string
          enum:
            - t0_local
            - t1_prepositioned
            - t2_bridge
            - reject
          description: >-
            Which rails run to fund this order. `t0_local` means no collateral
            moves; only `t2_bridge` carries a bridge fee. It names the movement,
            not whether the balance suffices.
        bridge_fee_usdc:
          type: string
          nullable: true
          description: >-
            Bridge fee in USDC. `"0"` below `t2_bridge`, and `null` exactly when
            `bridge_quote_unavailable` is `true` — an unknown fee is never
            rendered as `$0.00`. This fee is already included in
            `total_cost_usdc`, and buy-affordability checks must include it too.
        bridge_eta_p50_ms:
          type: integer
          nullable: true
          description: >-
            Median bridge fill time from Kairos's own completed intents, never a
            provider estimate. Present only once the route has ≥1,000 samples
            and its p90 ETA error is within ±10s.
        bridge_eta_p95_ms:
          type: integer
          nullable: true
          description: >-
            95th-percentile bridge fill time from Kairos's own completed
            intents. Present under the same gate as `bridge_eta_p50_ms`.
        bridge_route_label:
          type: string
          nullable: true
          description: >-
            The route in the user's words, naming the token the rail DELIVERS,
            e.g. "BNB USDT → Polymarket pUSD via Relay". Absent when nothing
            bridges.
        bridge_min_txs:
          type: integer
          nullable: true
          description: >-
            On-chain transactions the bridge route needs, so a client can price
            the signing path. Absent when nothing bridges.
        bridge_eta_state:
          type: string
          nullable: true
          enum:
            - measured
            - not_yet_measured
          description: >-
            Whether the ETA above is a measurement or an admission that the
            route has not earned one. Absent when nothing bridges.
        bridge_quote_unavailable:
          type: boolean
          description: >-
            `true` when a bridge is needed and no quote landed. Consumers MUST
            render a "routing…" state and disable submit rather than showing any
            fee; `bridge_fee_usdc` is `null` in this state.
        bridge_beta:
          type: boolean
          description: >-
            `true` while tier-2 bridge funding is behind a flag, so the bridge
            row can be labelled beta.
  responses:
    ExecUnauthorized:
      description: >
        No valid credential presented — missing/invalid API-key headers or an
        invalid/expired session token.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                example: Unauthorized
  securitySchemes:
    apiKeyClientId:
      type: apiKey
      in: header
      name: X-Client-Id
      description: >-
        Credential client id (`kairos_ck_...`). Must be sent together with
        X-Api-Key and X-Api-Secret.
    apiKeyKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: 64-char hex API key.
    apiKeySecret:
      type: apiKey
      in: header
      name: X-Api-Secret
      description: 64-char hex API secret.

````

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