> ## Documentation Index
> Fetch the complete documentation index at: https://pmxt-sync-hosted-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Order

> Place a buy or sell order on Polymarket, Opinion, or Limitless. Returns the resulting order with id, fill status, average price, fees, and the on-chain tx hash once it settles.

Most callers pass an outcome straight from `client.fetch_markets()`:

```python
market = client.fetch_markets({"query": "trump 2028"})[0]
order = client.create_order(outcome=market.yes, side="buy", amount=10, order_type="limit", price=0.55)
```

Need to show the order to a user before they sign it (custom approval UX)? Use `buildOrderHosted` + `submitOrderHosted` instead — together they do the same thing.

<Info>
  **Available on:** Polymarket, Opinion, Limitless. Other venues raise `NotSupported` in hosted mode — for those, run a [local PMXT service](/guides/self-hosted).
</Info>

<Note>
  **Before your first call:** deposit USDC on Polygon at [pmxt.dev/dashboard/wallet](https://pmxt.dev/dashboard/wallet) (one-time setup). For the programmatic flow, see [escrow lifecycle](/guides/escrow-lifecycle).
</Note>

<Tip>
  Use any EVM private key. Your USDC sits in a non-custodial PreFundedEscrow on Polygon — for Polymarket, Opinion, and Limitless. PMXT cannot move funds without your EIP-712 signature.
</Tip>


## OpenAPI

````yaml /api-reference/openapi-hosted-trading.json post /v0/trade/create-order
openapi: 3.0.0
info:
  title: PMXT Hosted Router API
  description: Hosted-only endpoints for cross-venue search, matching, arbitrage, and SQL.
  version: 49fbcd4
servers:
  - url: https://trade.pmxt.dev
    description: Hosted trading (v0)
security:
  - bearerAuth: []
tags:
  - name: Trading (Hosted)
    description: >-
      Hosted trading endpoints. Build / submit / cancel orders via
      `trade.pmxt.dev/v0/*`. Hosted-mode is the default when `pmxt_api_key` is
      set.
  - name: Orders & Positions (Hosted)
    description: >-
      Hosted account reads. Open orders, fills, balances, and positions via
      `trade.pmxt.dev/v0/*`. Requires `pmxt_api_key` + `wallet_address`.
  - name: MatchedMarkets
    description: Cross-venue matched market and event clusters.
  - name: SQL
    description: Direct read-only SQL access to the catalog (Enterprise).
paths:
  /v0/trade/create-order:
    post:
      tags:
        - Trading
      summary: Create Order
      description: >-
        Place a buy or sell order on Polymarket, Opinion, or Limitless. Returns
        the resulting order with id, fill status, average price, fees, and the
        on-chain tx hash once it settles.


        Most callers pass an outcome straight from `client.fetch_markets()`:


        ```python

        market = client.fetch_markets({"query": "trump 2028"})[0]

        order = client.create_order(outcome=market.yes, side="buy", amount=10,
        order_type="limit", price=0.55)

        ```


        Need to show the order to a user before they sign it (custom approval
        UX)? Use `buildOrderHosted` + `submitOrderHosted` instead — together
        they do the same thing.
      operationId: createOrderHosted
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuildOrderHostedRequest'
      responses:
        '200':
          description: Order accepted by the hosted backend.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderV0'
        '401':
          description: Invalid or missing PMXT API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HostedErrorResponse'
        '403':
          description: Insufficient escrow balance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HostedErrorResponse'
        '404':
          description: Outcome not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HostedErrorResponse'
        '422':
          description: Invalid order parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HostedErrorResponse'
        '503':
          description: Catalog unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HostedErrorResponse'
      x-codeSamples:
        - lang: python
          label: Polymarket
          source: >
            # Current hosted venues are funded once on Polygon — see
            /guides/escrow-lifecycle.

            # Hosted writes need: pmxt_api_key + wallet_address + private_key
            (signs EIP-712 locally).

            # Pass an outcome straight from client.fetch_markets() — no UUID
            lookup needed.

            import pmxt


            client = pmxt.Polymarket(
                pmxt_api_key="YOUR_PMXT_API_KEY",
                wallet_address="0xYourWallet",    # EVM address — its Polygon USDC funds the escrow
                private_key="0x...",    # any EVM key controlling that address
            )

            market = client.fetch_markets({"query": "trump 2028"})[0]

            yes = next(o for o in market.outcomes if o.label.lower() == "yes")

            order = client.create_order(
                outcome=yes,
                side="buy",
                type="limit",
                amount=10,
                price=0.55,
            )

            print(order.id, order.status)
        - lang: javascript
          label: Polymarket
          source: >
            // Current hosted venues are funded once on Polygon — see
            /guides/escrow-lifecycle.

            // Hosted writes need: pmxtApiKey + walletAddress + privateKey
            (signs EIP-712 locally).

            // Pass an outcome straight from client.fetchMarkets() — no UUID
            lookup needed.

            import { Polymarket } from "pmxtjs";


            const client = new Polymarket({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
              walletAddress: "0xYourWallet",  // EVM address — its Polygon USDC funds the escrow
              privateKey: "0x...",  // any EVM key controlling that address
            });


            const markets = await client.fetchMarkets({ query: "trump 2028" });

            const market = markets[0];

            const yes = market.outcomes.find((o) => o.label.toLowerCase() ===
            "yes")!;

            const order = await client.createOrder({
              outcome: yes,
              side: "buy",
              type: "limit",
              amount: 10,
              price: 0.55,
            });

            console.log(order.id, order.status);
        - lang: python
          label: Opinion
          source: >
            # Current hosted venues are funded once on Polygon — see
            /guides/escrow-lifecycle.

            # Hosted writes need: pmxt_api_key + wallet_address + private_key
            (signs EIP-712 locally).

            # Pass an outcome straight from client.fetch_markets() — no UUID
            lookup needed.

            import pmxt


            client = pmxt.Opinion(
                pmxt_api_key="YOUR_PMXT_API_KEY",
                wallet_address="0xYourWallet",    # EVM address — its Polygon USDC funds the escrow
                private_key="0x...",    # any EVM key controlling that address
            )

            market = client.fetch_markets({"query": "trump 2028"})[0]

            yes = next(o for o in market.outcomes if o.label.lower() == "yes")

            order = client.create_order(
                outcome=yes,
                side="buy",
                type="limit",
                amount=10,
                price=0.55,
            )

            print(order.id, order.status)
        - lang: javascript
          label: Opinion
          source: >
            // Current hosted venues are funded once on Polygon — see
            /guides/escrow-lifecycle.

            // Hosted writes need: pmxtApiKey + walletAddress + privateKey
            (signs EIP-712 locally).

            // Pass an outcome straight from client.fetchMarkets() — no UUID
            lookup needed.

            import { Opinion } from "pmxtjs";


            const client = new Opinion({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
              walletAddress: "0xYourWallet",  // EVM address — its Polygon USDC funds the escrow
              privateKey: "0x...",  // any EVM key controlling that address
            });


            const markets = await client.fetchMarkets({ query: "trump 2028" });

            const market = markets[0];

            const yes = market.outcomes.find((o) => o.label.toLowerCase() ===
            "yes")!;

            const order = await client.createOrder({
              outcome: yes,
              side: "buy",
              type: "limit",
              amount: 10,
              price: 0.55,
            });

            console.log(order.id, order.status);
components:
  schemas:
    BuildOrderHostedRequest:
      type: object
      description: >-
        Hosted build-order request. Identify the target outcome by passing
        `venue` + `venue_outcome_id` from `client.fetch_markets()` (the SDK does
        this automatically when you pass `outcome=` to `create_order` or
        `build_order`).
      required:
        - side
        - amount
        - user_address
      properties:
        venue:
          type: string
          enum:
            - polymarket
            - opinion
            - limitless
          description: >-
            Venue the outcome trades on. Inferred automatically from your client
            class in the SDKs.
        venue_outcome_id:
          type: string
          description: >-
            The outcome's identifier (e.g. Polymarket `tokenId`, Opinion outcome
            hash, or Limitless token address). Returned by
            `client.fetch_markets()`.
        side:
          type: string
          enum:
            - buy
            - sell
          description: >-
            Direction of the order. `buy` opens or adds to a long position on
            the outcome; `sell` closes or reduces it.
        order_type:
          type: string
          enum:
            - market
            - limit
          default: market
          description: >-
            `market` fills immediately at the best available price (subject to
            `slippage_pct`); `limit` rests on the venue's order book at `price`
            until matched or cancelled.
        amount:
          type: number
          minimum: 0
          description: >-
            Order size. For `market` buys, in USDC dollars (the budget you want
            to spend). For `market` sells and all `limit` orders, in outcome
            shares.
        denom:
          type: string
          enum:
            - shares
            - usdc
          default: shares
          description: >-
            Unit `amount` is denominated in. `shares` = outcome shares; `usdc` =
            USDC dollars. Market buys require `usdc`; market sells and limit
            orders require `shares` (the server validates this combination).
        price:
          type: number
          minimum: 0
          maximum: 1
          nullable: true
          description: >-
            Required for `limit` orders. Probability in [0, 1] -- e.g. `0.55`
            means buying / selling shares at 55 cents each. Ignored for `market`
            orders.
        slippage_pct:
          type: number
          minimum: 0
          maximum: 100
          nullable: true
          description: >-
            Maximum acceptable slippage as a percent. Use aggressive defaults
            (`30` for buys, `99.9` for sells) until the upstream economic
            validator tightens -- lower values frequently trip precision checks.
            Ignored for market orders, which pin worst-price to the domain
            extreme; the server defaults to `20` when omitted.
        user_address:
          type: string
          description: >-
            EVM wallet address that will sign the resulting typed data. Must
            match the wallet whose USDC funded the PMXT PreFundedEscrow on
            Polygon.
    OrderV0:
      type: object
      description: >-
        Hosted-mode `Order` shape. Mirrors `pmxt.Order` so the SDK can return it
        directly. `tx_hash`, `chain`, and `block_number` populate once execution
        settles on-chain.
      required:
        - id
        - status
      properties:
        id:
          type: string
          description: >-
            Unified order id. Stable across the order's lifetime; reuse it in
            `fetchOrderHosted` and `cancelOrderHosted`.
        side:
          type: string
          enum:
            - buy
            - sell
          nullable: true
          description: >-
            Order direction. `null` on cancel responses, which only carry id and
            status.
        type:
          type: string
          enum:
            - market
            - limit
          nullable: true
          description: Order type echoed from the build. `null` on cancel responses.
        amount:
          type: number
          nullable: true
          description: >-
            Order size in outcome shares. For market submits, this is the shares
            actually obtained (`tokens_bought` / `tokens_sold`); for resting
            limit orders it is the total shares originally requested. `null` on
            cancel responses.
        price:
          type: number
          nullable: true
          description: >-
            Limit price in probability units [0, 1] for limit orders. `null` for
            market orders and cancel responses.
        filled:
          type: number
          description: >-
            Shares filled so far. For market submits this equals the shares
            obtained on-chain; for resting limit orders it is the running fill
            total.
        remaining:
          type: number
          description: >-
            Shares still outstanding (`amount - filled`, floored at 0). Reaches
            0 when the order is fully filled or cancelled.
        status:
          type: string
          description: >-
            Lifecycle status. Open-order values include `resting` and `partial`;
            submit responses pass through the upstream status string (`failed`
            when an error was raised); cancel responses return the venue's
            cancel-acknowledgement status.
        fee:
          type: number
          nullable: true
          description: >-
            Total fee charged for this order, in USDC dollars. `null` until the
            venue reports fees (typically after settlement).
        timestamp:
          type: string
          nullable: true
          description: >-
            ISO-8601 timestamp the order was created on the venue side. `null`
            on cancel responses.
        tx_hash:
          type: string
          nullable: true
          description: >-
            On-chain settlement transaction hash on Polygon. `null` until the
            order settles on-chain (resting limit orders stay `null` until
            matched).
        chain:
          type: string
          nullable: true
          description: >-
            Chain the order settled on. Always `polygon` for hosted orders today
            (Opinion settles cross-chain via the same Polygon escrow). `null` on
            cancel responses.
        block_number:
          type: integer
          nullable: true
          description: >-
            Polygon block height at which the order settled. `null` until
            settlement.
    HostedErrorResponse:
      type: object
      description: >-
        Error envelope returned by `trade.pmxt.dev/v0/*` endpoints. Mirrors the
        `ErrorDetail` shape used inside `BaseResponse.error` from the sidecar
        spec.
      required:
        - error
      properties:
        error:
          type: object
          description: Structured error envelope. Always present on non-2xx responses.
          properties:
            message:
              type: string
              description: Human-readable explanation safe to surface to end users.
            code:
              type: string
              description: >-
                Stable hosted-mode error code. Use this (not `message`) for
                branching in client code.
              enum:
                - HOSTED_TRADING_ERROR
                - INSUFFICIENT_ESCROW_BALANCE
                - ORDER_SIZE_TOO_SMALL
                - INVALID_API_KEY
                - OUTCOME_NOT_FOUND
                - CATALOG_UNAVAILABLE
                - BUILT_ORDER_EXPIRED
                - INVALID_SIGNATURE
                - NO_LIQUIDITY
                - MISSING_WALLET_ADDRESS
                - ORDER_NOT_FOUND
                - INVALID_ORDER
            retryable:
              type: boolean
              description: >-
                `true` when the same request may succeed if retried (e.g.
                transient catalog outage); `false` when the caller must change
                inputs first.
            exchange:
              type: string
              nullable: true
              description: >-
                Source venue that produced the error (e.g. `polymarket`,
                `opinion`, `limitless`), when the failure originated upstream of
                PMXT. `null` for PMXT-side errors.
            detail:
              type: object
              additionalProperties: {}
              nullable: true
              description: >-
                Free-form structured diagnostics (e.g. required minimum size,
                escrow balance available). Shape varies per `code`.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Required when calling the hosted API directly (curl, requests, fetch).
        SDK users pass credentials via constructor params instead.

````