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

# Place Order Dispatcher

> Dispatcher: PolySim native single (JSON object) OR PM batch (JSON array).

See module-level comment above for the path-mapping rationale.



## OpenAPI

````yaml /openapi.json post /v1/orders
openapi: 3.1.0
info:
  title: Polysimulator API
  summary: HFT-style paper-trading API for Polymarket simulation.
  description: >-
    PolySimulator HFT API v1 — Virtual trading environment for Polymarket
    prediction markets. Practice trading with real market data using paper
    money, then switch to live trading by changing only your API credentials.
  termsOfService: https://polysimulator.com/legal/terms
  contact:
    name: PolySimulator
    url: https://polysimulator.com
  license:
    name: Proprietary — usage subject to Polysimulator Terms of Service
    url: https://polysimulator.com/legal/terms
  version: 1.0.0-beta
servers:
  - url: https://api.polysimulator.com
    description: Production
  - url: https://staging-api.polysimulator.com
    description: Staging
security:
  - ApiKeyAuth: []
tags:
  - name: API Keys
    description: >-
      Bootstrap, create, list, revoke API keys, mint short-lived WebSocket
      tokens, list rate-limit tiers.
  - name: Account
    description: >-
      Balance, equity curve, portfolio composition, open positions, trade
      history.
  - name: Export
    description: >-
      Pro data export — streamed CSV downloads for offline analysis,
      backtesting, and tax/accounting. v1: GET /v1/export/trades.csv (FILLED
      trades, keyset-paginated). Dual session + API-key auth.
  - name: Profile Analysis
    description: >-
      Trading-profile analytics — Sharpe, win-rate, drawdown, holding-period
      histograms.
  - name: Wallets
    description: >-
      Multi-wallet management (MAIN / SANDBOX / API / COMPETITION). List, switch
      active wallet, per-wallet balance + history.
  - name: Trading
    description: >-
      Place, cancel, batch, and list orders. Cancel-all + cancel-market-orders
      sweep endpoints. PolySimulator-native order surface.
  - name: Market Data
    description: >-
      Polymarket market metadata + live prices (POST /v1/prices/batch,
      /v1/markets, /v1/markets/{condition_id}/candles).
  - name: CLOB Read (Public)
    description: >-
      Polymarket-shape read endpoints (book, midpoint, spread, price,
      last-trade-price, tick-size, neg-risk, time). Wire-compatible with
      py-clob-client.
  - name: CLOB Compat
    description: >-
      Polymarket-shape order surface (POST /v1/order with nested body, POST
      /v1/orders batch, GET /v1/data/orders PM-envelope). Use these for drop-in
      py-clob-client compatibility.
  - name: WebSocket
    description: >-
      WebSocket subscription endpoints — /v1/ws/prices for live market data,
      /v1/ws/executions for order-state updates.
  - name: Billing
    description: >-
      Stripe-backed subscriptions, top-ups, customer portal, refund policy,
      paid-tier resets.
  - name: Status
    description: System-status surface — uptime, component health, recent incident markers.
  - name: Health
    description: >-
      Health, liveness, readiness, and authenticated-identity probes
      (/v1/health, /v1/health/live, /v1/health/ready, /v1/me).
  - name: Football
    description: >-
      Football / World-Cup 2026 enrichment — live score, minute, momentum,
      possession, xG, shotmap, commentary, lineups, group standings, knockout
      bracket, and head-to-head. Public read-only sports facts the UI merges
      with tradable Polymarket prices; degrades to empty shapes on upstream
      failure.
paths:
  /v1/orders:
    post:
      tags:
        - Trading
        - Trading
      summary: Place Order Dispatcher
      description: >-
        Dispatcher: PolySim native single (JSON object) OR PM batch (JSON
        array).


        See module-level comment above for the path-mapping rationale.
      operationId: placeOrder
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Idempotency-Key
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Your PolySimulator API key
            title: X-Api-Key
          description: Your PolySimulator API key
        - name: POLY_API_KEY
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Polymarket-CLOB-compat alias for ``X-API-Key`` (underscore form).
              SDK clients ported from Polymarket can authenticate without
              changing header names. ``X-API-Key`` takes precedence when both
              are provided.
            title: Poly Api Key
          description: >-
            Polymarket-CLOB-compat alias for ``X-API-Key`` (underscore form).
            SDK clients ported from Polymarket can authenticate without changing
            header names. ``X-API-Key`` takes precedence when both are provided.
        - name: Poly-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Poly-Api-Key
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              PM-CLOB-compat: ``Authorization: Bearer ps_live_...`` (or
              ``ps_test_...``) is accepted as an alias for ``X-API-Key`` so
              py-clob-client and other ported SDKs authenticate without header
              name changes. Bearer JWTs are NOT accepted here — use the
              dashboard-auth endpoints for those.
            title: Authorization
          description: >-
            PM-CLOB-compat: ``Authorization: Bearer ps_live_...`` (or
            ``ps_test_...``) is accepted as an alias for ``X-API-Key`` so
            py-clob-client and other ported SDKs authenticate without header
            name changes. Bearer JWTs are NOT accepted here — use the
            dashboard-auth endpoints for those.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/PlaceOrderRequest'
                - type: array
                  items:
                    $ref: '#/components/schemas/PmSendOrderRequest'
                  description: >-
                    Polymarket-compatible batch: an array of PM send-order
                    objects (max 15), the same shape POST /v1/order accepts per
                    entry. Each entry is validated and executed independently —
                    a single bad entry does not abort the rest.
            examples:
              single_market_order:
                summary: Single market order (PolySim native object)
                value:
                  market_id: 0xabc123...
                  side: BUY
                  outcome: 'Yes'
                  quantity: '10'
                  order_type: market
                  price: '0.68'
              single_limit_order:
                summary: Single GTC limit order (PolySim native object)
                value:
                  market_id: 0xabc123...
                  side: BUY
                  outcome: 'Yes'
                  quantity: '10'
                  order_type: limit
                  price: '0.55'
                  time_in_force: GTC
                  client_order_id: gtc-001
              pm_batch_array:
                summary: PM batch (array of PM send-order objects)
                value:
                  - order:
                      tokenId: 71321045679252...
                      makerAmount: '6500000'
                      takerAmount: '10000000'
                      side: BUY
                    owner: ps_live_kJ9mNx2p...
                    orderType: GTC
      responses:
        '200':
          description: >-
            Object body → OrderResponse (PolySim single-order) OR OrderAck when
            the user routes through Order Pipeline V2 (per-user allowlist or
            global flag — ack-then-reconcile, no fill data in the body; clients
            poll GET /v1/orders/{order_id} for the post-reconcile fill fields).
            Array body → List[PmSendOrderResponse] (PM batch, max 15). The
            OrderAck schema is registered under /v1/orders/{order_id} (DELETE)'s
            202 response.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/OrderResponse'
                  - $ref: '#/components/schemas/OrderAck'
                  - type: array
                    items:
                      $ref: '#/components/schemas/PmSendOrderResponse'
          headers:
            X-RateLimit-Limit:
              description: >-
                Requests permitted in the current minute window for this key's
                tier.
              schema:
                type: string
            X-RateLimit-Remaining:
              description: Requests remaining in the current minute window.
              schema:
                type: string
            X-RateLimit-Reset:
              description: Unix-seconds timestamp when the current minute window resets.
              schema:
                type: string
            X-RateLimit-Limit-Per-Second:
              description: Requests permitted per second for this key's tier.
              schema:
                type: string
            X-RateLimit-Remaining-Per-Second:
              description: Requests remaining in the current one-second window.
              schema:
                type: string
            X-RateLimit-Tier:
              description: Rate-limit tier name applied to this request (free, pro, ...).
              schema:
                type: string
            X-Polysim-RateLimit-Limit:
              description: Alias of X-RateLimit-Limit (requests per minute for this tier).
              schema:
                type: string
            X-Polysim-RateLimit-Remaining:
              description: Alias of X-RateLimit-Remaining (requests remaining this minute).
              schema:
                type: string
            X-Polysim-RateLimit-Reset:
              description: Alias of X-RateLimit-Reset (minute-window reset, unix seconds).
              schema:
                type: string
            X-Polysim-RateLimit-Limit-Per-Second:
              description: Alias of X-RateLimit-Limit-Per-Second.
              schema:
                type: string
            X-Polysim-RateLimit-Remaining-Per-Second:
              description: Alias of X-RateLimit-Remaining-Per-Second.
              schema:
                type: string
            X-Polysim-RateLimit-Tier:
              description: Alias of X-RateLimit-Tier (tier name applied to this request).
              schema:
                type: string
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '401':
          description: Invalid or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '403':
          description: Missing required permission
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '404':
          description: Resource not found (market / order / token).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '422':
          description: Body validation failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            X-Polysim-Code:
              description: >-
                Stable short code identifying the error class. SDK consumers
                should branch on this header rather than the body text. Domain
                codes (INVALID_KEY, MARKET_NOT_FOUND, RATE_LIMIT_EXCEEDED, …)
                are preferred; HTTP_<status> fallbacks ship when no domain code
                applies. The full list is mirrored in /llms.txt under ‘Error
                Format’.
              schema:
                type: string
                enum:
                  - INVALID_KEY
                  - MISSING_API_KEY
                  - INSUFFICIENT_PERMISSION
                  - INSUFFICIENT_BALANCE
                  - MARKET_CLOSED
                  - INVALID_ORDER_MIN_TICK_SIZE
                  - MARKET_NOT_FOUND
                  - ORDER_NOT_FOUND
                  - RATE_LIMIT_EXCEEDED
                  - BOOK_UNAVAILABLE
                  - VALIDATION_FAILED
                  - UPGRADE_REQUIRED
                  - ACCESS_RESTRICTED
                  - COHORT_FULL
                  - AUTH_STATE_INCOMPLETE
                  - INTERNAL_ERROR
                  - TOKEN_NOT_FOUND
                  - INVALID_CURSOR
                  - UPSTREAM_UNAVAILABLE
                  - UNSUPPORTED_ORDER_TYPE
                  - DUPLICATE_CLIENT_ORDER_ID
                  - ORDER_EXECUTION_FAILED
                  - DEADLINE_OVERSHOT_BUT_PERSISTED
                  - PERSISTENCE_UNKNOWN
                  - INVALID_BODY
                  - INVALID_SOURCE
                  - CLOSED_BETA
                  - API_PRO_COMING_SOON
                  - TIER_KEY_LIMIT_EXCEEDED
                  - HTTP_400
                  - HTTP_401
                  - HTTP_403
                  - HTTP_404
                  - HTTP_409
                  - HTTP_422
                  - HTTP_429
                  - HTTP_500
                  - HTTP_502
                  - HTTP_503
            X-Request-Id:
              description: >-
                Request id for log correlation. Echoes the caller's
                ``X-Request-Id`` when supplied, otherwise a server-minted UUID.
                Stamped on every response (success and error).
              schema:
                type: string
components:
  schemas:
    PlaceOrderRequest:
      properties:
        market_id:
          type: string
          maxLength: 256
          title: Market Id
          description: Polymarket condition_id
        side:
          type: string
          enum:
            - BUY
            - SELL
          title: Side
        outcome:
          type: string
          maxLength: 200
          title: Outcome
          description: Outcome label, e.g., Yes or No
        quantity:
          anyOf:
            - type: string
            - type: 'null'
          title: Quantity
          description: >-
            Number of shares as decimal string, e.g. '10.5'. Required UNLESS
            ``amount`` is provided (BUY market orders only — Polymarket
            convention).
        amount:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount
          description: >-
            USD amount to spend, as decimal string (e.g. '10.50'). Polymarket
            convention for BUY market orders: ``amount=5`` means 'spend $5'
            (versus our ``quantity=5`` which means 'buy 5 shares ≈ $5 ×
            current_price'). Only valid when ``side=BUY`` and
            ``order_type=market``; the handler derives ``quantity =
            floor4(amount / price)`` using the caller-supplied **worst-price
            limit** in the ``price`` field (NOT the eventual fill price). This
            is conservative: the trade can't spend more than ``amount`` USD even
            at the worst acceptable price; a better fill means more shares. The
            result is rounded down to 4 decimal places (the matching engine's
            share quantum) and capped at the per-trade share limit. For SELL or
            limit orders, use ``quantity`` (shares). Mutually exclusive with
            ``quantity`` — supplying both is a 400 error.
        order_type:
          type: string
          enum:
            - market
            - limit
          title: Order Type
          description: Order type
          default: market
        price:
          anyOf:
            - type: string
            - type: 'null'
          title: Price
          description: >-
            For limit orders: the limit price (0.01-0.99, required). For market
            orders: the worst acceptable price — Polymarket-style slippage
            protection (required). BUY won't fill above this price; SELL won't
            fill below it. All market orders are effectively marketable limit
            orders, matching Polymarket's execution model.
        time_in_force:
          type: string
          enum:
            - GTC
            - FOK
            - FAK
            - IOC
            - GTD
          title: Time In Force
          description: >-
            GTC = Good-Til-Cancel (default for limit orders, persists until
            filled/cancelled), FOK = Fill-Or-Kill (default for market orders —
            all-or-nothing, matching Polymarket), FAK = Fill-And-Kill
            (Polymarket term for partial fill, cancel remainder — equivalent to
            IOC), IOC = Immediate-Or-Cancel (partial fill, cancel remainder),
            GTD = Good-Til-Date (resting limit auto-expiring at `expiration`;
            rolling out — accepted only while ORDER_SEMANTICS_PM_V2_ENABLED is
            on)
          default: GTC
        client_order_id:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Client Order Id
          description: Idempotency key
        expiration:
          anyOf:
            - type: string
            - type: 'null'
          title: Expiration
          description: >-
            Unix-seconds expiration timestamp — required for time_in_force=GTD
            (PM convention: the order auto-cancels once the timestamp passes),
            ignored for every other TIF. Rolling out behind
            ORDER_SEMANTICS_PM_V2_ENABLED.
        post_only:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Post Only
          description: >-
            Polymarket's postOnly: the order must REST on the book — if it would
            cross the spread (marketable at placement) it is rejected with 400
            INVALID_POST_ONLY_ORDER instead of executing, guaranteeing
            maker-side execution. Only valid for limit orders with GTC/GTD
            time-in-force (FOK/FAK/IOC/market combinations are rejected with
            INVALID_POST_ONLY_ORDER_TYPE, matching PM). Rolling out behind
            ORDER_SEMANTICS_PM_V2_ENABLED; advisory (ignored) until the flag is
            on.
          default: false
        wallet_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Wallet Id
          description: >-
            Multi-wallet (May 8 launch). When set to a SANDBOX wallet the user
            owns, the trade debits/credits Wallet.balance directly and the
            resulting Order is tagged with trade_source='ui_sandbox' (excluded
            from the public leaderboard). When set to a MAIN/API wallet the user
            owns, the cash flow is routed to that explicit wallet (otherwise we
            default to API for /v1/orders). Omit for legacy back-compat
            behaviour: cash flows to the user's API wallet.
      type: object
      required:
        - market_id
        - side
        - outcome
      title: PlaceOrderRequest
    PmSendOrderRequest:
      properties:
        order:
          $ref: '#/components/schemas/PmOrderInner'
        owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner
        orderType:
          type: string
          title: Ordertype
          default: GTC
        deferExec:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Deferexec
          default: false
        postOnly:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Postonly
          default: false
      type: object
      required:
        - order
      title: PmSendOrderRequest
      description: Outer body for ``POST /v1/order`` and entries of ``POST /v1/orders``.
    OrderResponse:
      properties:
        order_id:
          type: integer
          title: Order Id
        status:
          type: string
          title: Status
        order_type:
          type: string
          title: Order Type
        side:
          type: string
          title: Side
        outcome:
          type: string
          title: Outcome
        price:
          type: string
          title: Price
        quantity:
          type: string
          title: Quantity
        notional:
          type: string
          title: Notional
        fee:
          type: string
          title: Fee
        filled_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Filled At
        cancelled_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Cancelled Reason
        price_source:
          anyOf:
            - type: string
            - type: 'null'
          title: Price Source
        slippage_bps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Slippage Bps
        quote_age_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Quote Age Ms
        spread_bps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Spread Bps
        impact_bps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Impact Bps
        book_walk_levels:
          anyOf:
            - type: integer
            - type: 'null'
          title: Book Walk Levels
        account_balance:
          anyOf:
            - type: string
            - type: 'null'
          title: Account Balance
        position:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Position
        client_order_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Client Order Id
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
        amount_interpreted_as:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount Interpreted As
        is_replay:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Replay
        warnings:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Warnings
      type: object
      required:
        - order_id
        - status
        - order_type
        - side
        - outcome
        - price
        - quantity
        - notional
        - fee
      title: OrderResponse
    OrderAck:
      properties:
        order_id:
          type: integer
          title: Order Id
        client_order_id:
          type: string
          title: Client Order Id
        status:
          type: string
          title: Status
          description: Always 'accepted' on success
          default: accepted
        order_type:
          type: string
          title: Order Type
        side:
          type: string
          title: Side
        outcome:
          type: string
          title: Outcome
        market_id:
          type: string
          title: Market Id
        price_requested:
          anyOf:
            - type: string
            - type: 'null'
          title: Price Requested
          description: >-
            Requested worst-price as decimal string; null for market orders
            without a worst-price
        quantity_requested:
          type: string
          title: Quantity Requested
          description: Requested quantity as decimal string
        accepted_at:
          type: string
          title: Accepted At
        is_replay:
          type: boolean
          title: Is Replay
          default: false
      type: object
      required:
        - order_id
        - client_order_id
        - order_type
        - side
        - outcome
        - market_id
        - quantity_requested
        - accepted_at
      title: OrderAck
      description: |-
        Response body for the V2 ack path.

        Intentionally minimal — fill data lives on the eventually
        reconciled order, not in the ack. Clients poll
        ``GET /v1/orders/{order_id}`` for the post-reconcile fields
        (price, fee, position).
    PmSendOrderResponse:
      properties:
        success:
          type: boolean
          title: Success
        orderID:
          type: string
          title: Orderid
          default: ''
        status:
          type: string
          title: Status
          default: unmatched
        makingAmount:
          type: string
          title: Makingamount
          default: '0'
        takingAmount:
          type: string
          title: Takingamount
          default: '0'
        transactionsHashes:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Transactionshashes
        tradeIDs:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tradeids
        errorMsg:
          type: string
          title: Errormsg
          default: ''
      type: object
      required:
        - success
      title: PmSendOrderResponse
      description: |-
        Mirrors PM's ``SendOrderResponse``. ``status`` ∈
        ``live | matched | delayed | unmatched``.
    ApiError:
      properties:
        error:
          type: string
          title: Error
          description: >-
            Human-readable message (PM-shape default body) OR machine-readable
            error code (verbose body). The machine code is always available in
            the X-Polysim-Code response header.
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: >-
            Human-readable error description — populated only on verbose body
            (X-Polysim-Verbose: true).
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: Additional context — populated only on verbose body.
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: >-
            Request id for support reference. Always exposed via X-Request-Id
            response header; only inlined in the verbose body.
      type: object
      required:
        - error
      title: ApiError
      description: |-
        Structured error response for all API v1 endpoints.

        * ``error`` carries the human-readable message in the default body
         and the machine code in the verbose body. The machine code is
         ALWAYS exposed via the ``X-Polysim-Code`` response header so SDK
         consumers can switch on a stable identifier without parsing the
         body.
        * ``request_id`` → exposed as the ``X-Request-Id`` response header
         on every response (success and error).

        All non-required fields are ``Optional`` so generated SDK code can
        deserialize *either* shape (PM-default or polysim-verbose) without
        choking on missing keys. Pre-PR ``message`` was required, which
        broke SDK deserialization of the new PM-shape body.
    PmOrderInner:
      properties:
        tokenId:
          type: string
          title: Tokenid
        makerAmount:
          type: string
          title: Makeramount
        takerAmount:
          type: string
          title: Takeramount
        side:
          type: string
          title: Side
        expiration:
          anyOf:
            - type: string
            - type: 'null'
          title: Expiration
          default: '0'
        salt:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Salt
        maker:
          anyOf:
            - type: string
            - type: 'null'
          title: Maker
        signer:
          anyOf:
            - type: string
            - type: 'null'
          title: Signer
        taker:
          anyOf:
            - type: string
            - type: 'null'
          title: Taker
        nonce:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Nonce
        feeRateBps:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Feeratebps
        signatureType:
          anyOf:
            - type: integer
            - type: 'null'
          title: Signaturetype
        signature:
          anyOf:
            - type: string
            - type: 'null'
          title: Signature
        timestamp:
          anyOf:
            - type: string
            - type: 'null'
          title: Timestamp
        metadata:
          anyOf:
            - type: string
            - type: 'null'
          title: Metadata
        builder:
          anyOf:
            - type: string
            - type: 'null'
          title: Builder
      type: object
      required:
        - tokenId
        - makerAmount
        - takerAmount
        - side
      title: PmOrderInner
      description: Inner ``order`` block — the part PM signs.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Issue from /v1/keys (or admin-issued for enterprise tier).

````