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

# Replace a signed order

> Cancels an open order, then places a new signed order in its place. These are two steps, not one transaction: once the old order is cancelled it cannot fill, but the new order can still be refused. The body is exactly the body of `POST /account/orders`, with a fresh `signed_order`, and must be for the same market (422 `order.replace_market_mismatch`). The new order is validated in full before the old one is touched, so a rejected replacement leaves the old order resting. An old order that is no longer open (filled or cancelled) answers 409 `order.not_open` and nothing is placed. On success the response is the new order, as `POST /account/orders` returns it, plus `replaced_order_id`. If the old order was cancelled but the new one was then rejected, the error body also carries `replaced_order_id`: the old order is gone and nothing replaced it. Counts as one order against the order-placement rate limit.



## OpenAPI

````yaml /api-reference/openapi/calibri.yaml post /api/v2/atlas/account/orders/{id}/replace
openapi: 3.1.0
info:
  title: Calibri API
  version: 1.0.0
  description: >-
    The Calibri API. Discover markets, read live books, place signed orders, and
    manage positions and account data.

    Routed by path prefix to the service that answers it — which is an
    implementation detail, not something a caller has to reason about.
servers:
  - description: Production
    url: https://calibri.io
security: []
tags:
  - name: Health
    description: Service liveness.
    x-displayName: Health
  - name: Events
    description: Discover events and their metadata.
    x-displayName: Events
  - name: Markets
    description: List markets and load market detail for trading.
    x-displayName: Markets
  - name: Series
    description: Recurring event series.
    x-displayName: Series
  - name: Tags
    description: Editorial shelves used to browse the catalogue.
    x-displayName: Tags
  - name: Market Data
    description: Order book, depth, trade tape, tickers, and candles.
    x-displayName: Market Data
  - name: Assets
    description: Underlying asset price history for price-feed markets.
    x-displayName: Assets
  - name: Community
    description: Leaderboard and platform activity.
    x-displayName: Community
  - name: Currencies
    description: Currency registry.
    x-displayName: Currencies
  - name: Trade
    description: Place, list, and cancel orders.
    x-displayName: Trade
  - name: Positions
    description: Your matched contracts.
    x-displayName: Positions
  - name: Wallet
    description: Self-custody Safe, passkey, session keys, and relay.
    x-displayName: Wallet
  - name: Rewards
    description: Maker rebates and referral earnings.
    x-displayName: Rewards
  - name: Account
    description: Balances, ledger, PnL, limits, preferences, and profile.
    x-displayName: Account
  - name: Categories
    description: Categories
    x-displayName: Categories
  - name: Other
    description: Other
    x-displayName: Other
paths:
  /api/v2/atlas/account/orders/{id}/replace:
    post:
      tags:
        - Trade
      summary: Replace a signed order
      description: >-
        Cancels an open order, then places a new signed order in its place.
        These are two steps, not one transaction: once the old order is
        cancelled it cannot fill, but the new order can still be refused. The
        body is exactly the body of `POST /account/orders`, with a fresh
        `signed_order`, and must be for the same market (422
        `order.replace_market_mismatch`). The new order is validated in full
        before the old one is touched, so a rejected replacement leaves the old
        order resting. An old order that is no longer open (filled or cancelled)
        answers 409 `order.not_open` and nothing is placed. On success the
        response is the new order, as `POST /account/orders` returns it, plus
        `replaced_order_id`. If the old order was cancelled but the new one was
        then rejected, the error body also carries `replaced_order_id`: the old
        order is gone and nothing replaced it. Counts as one order against the
        order-placement rate limit.
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderRequest'
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReplacedOrderEntity'
          description: ''
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEntity'
          description: The old order is not open
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEntity'
          description: Signature or validation failure
      security:
        - apiKey: []
components:
  schemas:
    CreateOrderRequest:
      properties:
        client_order_id:
          description: >-
            Your own id for this order, 1–64 characters of `A-Z a-z 0-9 _ -`.
            Echoed on the order and its websocket frames, and filterable on the
            order list. A second order with an id you used in the last 7 days is
            rejected with 409 `order.duplicate_client_order_id`, so a retried
            placement can never create two orders.
          example: bot-7f3a-0001
          type: string
        direction:
          description: >-
            Whether you are opening or closing. `buy` posts collateral and
            acquires the outcome; `sell` offers outcome tokens you already hold,
            so it locks INVENTORY rather than cash and its `locked` is zero.
            Defaults to `buy`, which is how every order behaved before position
            exit. See /account/positions for how much of a holding is sellable.
          enum:
            - buy
            - sell
          example: buy
          type: string
        ioc:
          description: >-
            Immediate-or-cancel. Set it on a marketable order — the "market"
            order a signed wallet has to send as a limit at a price ceiling:
            whatever the book cannot fill on arrival is refunded instead of
            resting at that ceiling. Ignored together with `post_only`. Recorded
            on the order as `ioc`.
          example: false
          type: boolean
        market_id:
          description: >-
            The market. A JSON number; a numeric string (`"12"`) is accepted
            too. Anything else is a 422.
          example: 12
          type: number
        ord_type:
          enum:
            - limit
          example: limit
          type: string
        post_only:
          description: >-
            Reject the order if it would take liquidity. A post-only order
            reserves no taker fee, because it can only ever rest as a maker.
          example: false
          type: boolean
        price:
          description: >-
            Limit price, `0.01`–`0.99`, in whole cents (e.g. 0.27, not 0.275) —
            an order finer than the market precision is rejected, not rounded.
            Required for a limit order.
          example: '0.6'
          type: string
        side:
          description: >-
            The OUTCOME this order is about — never buy/sell. Pair it with
            `direction`: a sell of `yes` and a buy of `no` are different orders
            that happen to sit on the same side of the book.
          enum:
            - 'yes'
            - 'no'
          example: 'yes'
          type: string
        signed_order:
          $ref: '#/components/schemas/SignedOrderEntity'
          description: >-
            The EIP-712-signed order. Validated before anything is placed — a
            signature the server cannot verify is rejected, never rested.
        volume:
          description: >-
            Number of contracts, with at most the market's `amount_precision`
            decimals (2): `8.47` is valid, `8.475` is rejected, not rounded.
          example: '100'
          type: string
      required:
        - market_id
        - side
        - ord_type
        - volume
        - signed_order
      type: object
    ReplacedOrderEntity:
      properties:
        avg_price:
          description: >-
            Average price of the filled part, in the order's own outcome price
            space. Null while nothing has filled.
          example: '0.61'
          type:
            - string
            - 'null'
        client_order_id:
          description: The `client_order_id` you sent; null when none was.
          example: bot-7f3a-0001
          type:
            - string
            - 'null'
        contracts_count:
          description: Contracts formed from this order.
          example: 1
          type: number
        created_at:
          description: RFC 3339, UTC.
          example: '2026-08-07T10:00:00Z'
          type: string
        direction:
          enum:
            - buy
            - sell
          example: buy
          type: string
        event_slug:
          description: The parent event's slug, for linking. Null when unknown.
          example: btc-above-70k-december-2026
          type:
            - string
            - 'null'
        expires_at:
          description: >-
            When the order's signature lapses (RFC 3339, UTC); null when it has
            none. The engine never matches an order within 30 seconds of it.
          example: '2026-08-07T11:00:00Z'
          type:
            - string
            - 'null'
        fee:
          description: >-
            Taker fee charged to this order so far, in `quote_currency`. `"0"`
            for a maker.
          example: '0.17'
          type: string
        filled_cost:
          description: >-
            Cash for the filled part at the fill prices: paid on a buy, received
            before fees on a sell. Excludes `fee`. `"0"` while nothing has
            filled.
          example: '36.6'
          type:
            - string
            - 'null'
        filled_volume:
          example: '60'
          type: string
        id:
          example: 90311
          type: number
        ioc:
          description: >-
            Immediate-or-cancel: the unfilled remainder is refunded, never
            rested.
          example: false
          type: boolean
        locked:
          description: >-
            Collateral still locked. A separate taker-fee reserve is held
            alongside it and released when unused. Zero on a sell, which locks
            inventory instead.
          example: '24.68'
          type: string
        market_id:
          description: The market.
          example: 12
          type: number
        market_title:
          description: >-
            The market's title. Null when the engine does not know the market's
            metadata.
          example: Will BTC close above $70,000 on 31 Dec 2026?
          type:
            - string
            - 'null'
        ord_type:
          enum:
            - limit
          example: limit
          type: string
        origin_locked:
          description: Collateral locked when the order was placed.
          example: '61.68'
          type: string
        origin_volume:
          example: '100'
          type: string
        post_only:
          description: Rejected rather than allowed to take liquidity.
          example: false
          type: boolean
        price:
          description: Limit price, `0.01`–`0.99`.
          example: '0.6'
          type: string
        quote_currency:
          example: usdc
          type: string
        remaining_volume:
          description: Unmatched remainder.
          example: '40'
          type: string
        replaced_order_id:
          description: The order that was cancelled to make way for this one.
          example: 90310
          type: number
        side:
          description: The outcome traded.
          enum:
            - 'yes'
            - 'no'
          example: 'yes'
          type: string
        state:
          enum:
            - wait
            - done
            - cancel
            - reject
          example: wait
          type: string
        token_id:
          description: >-
            The on-chain ERC-1155 token for `side`, as a decimal string (a
            uint256 — do not parse as a number). Null when the market has no
            on-chain token.
          example: >-
            52114319501245915516055106046884209969926127482827954674443846427813813222426
          type:
            - string
            - 'null'
        updated_at:
          description: RFC 3339, UTC.
          example: '2026-08-07T10:05:00Z'
          type: string
        volume:
          description: Unmatched remainder (same as `remaining_volume`).
          example: '40'
          type: string
      required:
        - id
        - market_id
        - market_title
        - event_slug
        - side
        - direction
        - token_id
        - client_order_id
        - ord_type
        - price
        - state
        - volume
        - origin_volume
        - remaining_volume
        - filled_volume
        - avg_price
        - filled_cost
        - fee
        - locked
        - origin_locked
        - quote_currency
        - contracts_count
        - ioc
        - post_only
        - expires_at
        - created_at
        - updated_at
        - replaced_order_id
      type: object
    ErrorEntity:
      properties:
        errors:
          description: Match on the code, not the HTTP status or the human text.
          example:
            - market.order.insufficient_balance
          items:
            type: string
          type: array
      required:
        - errors
      type: object
    SignedOrderEntity:
      properties:
        expiration:
          description: Unix seconds. Must be non-zero, unexpired, and within 365 days.
          example: '1797600000'
          type: string
        fee_rate_bps:
          description: >-
            Must be `"0"`. The taker fee is collected separately on-chain from
            your Safe, not through this field.
          example: '0'
          type: string
        maker:
          description: >-
            Your Safe — the address the collateral comes from. For signature
            type 3 this equals `signer`.
          example: '0x0DECE7d83f8D47CD8dD8278c0F22c361C58577BD'
          type: string
        maker_amount:
          description: >-
            What you give, 6-decimal base units: on a buy, USDC `round(price ×
            volume × 1e6)`; on a sell, outcome tokens `round(volume × 1e6)`.
          example: '60000000'
          type: string
        nonce:
          description: Exchange nonce.
          example: '0'
          type: string
        salt:
          description: >-
            Random per-order value. Two orders with identical terms must not
            share one.
          example: '5821094412'
          type: string
        side:
          description: >-
            `0` (BUY) for a `direction: "buy"` order, `1` (SELL) for a
            `direction: "sell"` order; a mismatch is rejected. YES or NO is
            carried by `token_id` alone.
          enum:
            - 0
            - 1
          example: 0
          type: number
        signature:
          description: >-
            The EIP-712 signature. For a session-signed order this is
            `abi.encode(keyId, r, s)` — exactly 96 bytes — which is how the
            server tells a session key from a passkey.
          example: 0x4f2a…
          type: string
        signature_type:
          description: >-
            `2` POLY_GNOSIS_SAFE (your Safe, owned by your wallet) or `3`
            POLY_1271 (your Safe, owned by a passkey). Read it from
            `signature_type` on the wallet config rather than choosing one — an
            order signed the way the other type requires is rejected.
          enum:
            - 2
            - 3
          example: 2
          type: number
        signer:
          description: >-
            Whoever signed. Your wallet EOA for type 2; the Safe itself for type
            3, where a passkey or session key produced the signature.
          example: '0xE1188438C85C98aADFf1a88f97764E607B4978C3'
          type: string
        taker:
          description: The zero address — the order is public and anyone may match it.
          example: '0x0000000000000000000000000000000000000000'
          type: string
        taker_amount:
          description: >-
            What you get, 6-decimal base units: on a buy, outcome tokens
            `round(volume × 1e6)`; on a sell, USDC `round(price × volume ×
            1e6)`.
          example: '100000000'
          type: string
        token_id:
          description: >-
            The ERC-1155 position id for YOUR side. This is what says which
            market and which outcome — a signed order carries no market field.
          example: 7138104...
          type: string
      required:
        - salt
        - maker
        - signer
        - taker
        - token_id
        - maker_amount
        - taker_amount
        - expiration
        - nonce
        - fee_rate_bps
        - side
        - signature_type
        - signature
      type: object
  securitySchemes:
    apiKey:
      description: >-
        HMAC-signed API key. Send X-Auth-Apikey, X-Auth-Nonce and
        X-Auth-Signature.
      in: header
      name: X-Auth-Apikey
      type: apiKey

````

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