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

# Edit an order

> Change the price or volume of a resting order

Change the price (`orderOdds`) and/or volume (`orderVolume`) of an existing **limit** order.

For partially-filled orders, 4casters cancels the existing order and submits a new one with the supplied values. The new `orderVolume` does **not** account for previously filled volume — if you originally placed `bet: 10`, $5 was filled, and you edit to `orderVolume: 10`, the previous order is cancelled (refunding $5) and a new order is created for $10 (debiting $10), leaving you net \$5 down.

<Note>
  A newer gRPC variant lives at `POST /session/v4/editOrder`. It accepts the same request body and additionally returns `errorType` on validation failures. Prefer it for new integrations once you've confirmed the shape works for you.
</Note>

## Request

`POST /session/editOrder`

<ParamField body="sessionID" type="string" required>
  Order id to edit. Get it from `data.unmatched.orderID` of `/session/v3/place` or `id` from `/user/getUnmatched`.
</ParamField>

<ParamField body="orderOdds" type="integer">
  New American odds. Pass `null` to leave odds unchanged.
</ParamField>

<ParamField body="orderVolume" type="number">
  New `bet` amount. Pass `null` to leave volume unchanged.
</ParamField>

<ParamField body="orderType" type="string">
  Defaults to `limit`. See [order types](/pages/rest/orders/place-order#order-types).
</ParamField>

<ParamField body="userReference" type="string">
  Optional. Replaces the existing `userReference` on the order.
</ParamField>

<ParamField body="intendedOrderVolume" type="number">
  Optional. The volume you originally intended to place; used by the server when reconciling partial fills.
</ParamField>

<ParamField body="expiryChange" type="string">
  Optional. New expiration in minutes (string).
</ParamField>

<ParamField body="blockIfNoOtherSideOrders" type="boolean">
  v4 only. Reject the edit if there is no resting opposite-side liquidity.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.4casters.io/session/editOrder \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "sessionID": "6549b6df6634097d2704716f",
      "orderOdds": 185,
      "orderVolume": 100
    }'
  ```

  ```json JSON body theme={null}
  {
    "sessionID": "6549b6df6634097d2704716f",
    "orderOdds": 185,
    "orderVolume": 100
  }
  ```
</CodeGroup>

## Response

The result mirrors the [place order](/pages/rest/orders/place-order#response) response shape — a `cancelled` summary plus the new `matched` / `unmatched` outcome:

<ResponseField name="data.cancelled" type="object">
  Summary of the cancelled-and-replaced original order.
</ResponseField>

<ResponseField name="data.matched" type="array">
  Fills produced by re-submitting at the new price/volume. Same shape as a `MatchedFill` in [place order](/pages/rest/orders/place-order#response).
</ResponseField>

<ResponseField name="data.unmatched" type="object">
  Resting offer for the unfilled remainder of the new order.
</ResponseField>

## Errors

| Status | Meaning                                                          |
| ------ | ---------------------------------------------------------------- |
| `400`  | Validation error (`v4/editOrder` returns `errorType` for these). |
| `503`  | Orders service unreachable.                                      |


## OpenAPI

````yaml POST /session/editOrder
openapi: 3.1.0
info:
  title: 4casters REST API
  version: 1.0.0
  description: >-
    Public REST API for the 4casters peer-to-peer betting exchange. Use this API
    to manage your account, query the orderbook and games, and place / edit /
    cancel orders.


    All responses (unless noted otherwise) are JSON envelopes of the form `{
    "data": ... }`.
  contact:
    name: 4casters
    url: https://4casters.io
servers:
  - url: https://api.4casters.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Login and account session management
  - name: User
    description: Read account info, bets, and orders
  - name: Orders
    description: Place, edit, look up, and cancel orders
  - name: Markets
    description: Browse leagues, games, participants, and orderbooks
  - name: Affiliate
    description: Affiliate / referral commission
paths:
  /session/editOrder:
    post:
      tags:
        - Orders
      summary: Edit an order
      description: >-
        Change the price (`orderOdds`) and/or volume (`orderVolume`) of an
        existing **limit** order. For partially filled orders, 4casters cancels
        the existing order and submits a new one with the supplied values; the
        new `orderVolume` does **not** account for previously filled volume.


        The newer gRPC variant `POST /session/v4/editOrder` accepts the same
        body shape and also returns `errorType` on validation failures.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EditOrderRequest'
            example:
              sessionID: 6549b6df6634097d2704716f
              orderOdds: 185
              orderVolume: 100
      responses:
        '200':
          description: >-
            Edit result. Mirrors the place-order response shape: a `cancelled`
            summary plus the new `matched` / `unmatched` outcome.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EditOrderResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          description: Orders service unreachable
components:
  schemas:
    EditOrderRequest:
      type: object
      required:
        - sessionID
      properties:
        sessionID:
          type: string
          description: Order id to edit.
        orderOdds:
          type: integer
          nullable: true
          description: New American odds. Pass `null` to leave odds unchanged.
        orderVolume:
          type: number
          nullable: true
          description: >-
            New `bet` amount. Pass `null` to leave volume unchanged. **Does
            not** account for previously-filled volume.
        orderType:
          $ref: '#/components/schemas/OrderType'
        userReference:
          type: string
        intendedOrderVolume:
          type: number
          description: >-
            Optional. The volume you originally intended to place; used by the
            server when reconciling partial fills.
        expiryChange:
          type: string
          description: Optional. New expiration in minutes (string).
        blockIfNoOtherSideOrders:
          type: boolean
          description: >-
            v4 only. Reject the edit if there is no resting opposite-side
            liquidity.
    EditOrderResult:
      type: object
      properties:
        cancelled:
          type: object
          description: Summary of the cancelled-and-replaced original order.
        matched:
          type: array
          items:
            $ref: '#/components/schemas/MatchedFill'
        unmatched:
          $ref: '#/components/schemas/UnmatchedOffer'
    OrderType:
      type: string
      enum:
        - limit
        - post
        - postArb
        - fillAndKill
      description: >-
        Order placement strategy.


        - `limit` — default. Match against any liquidity at your price or better
        as a taker, rest the remainder as a maker.

        - `post`  — guarantee maker. Reject if the order would match resting
        liquidity.

        - `postArb` — like `post`, but allowed to match if the matched odds are
        within 1% of yours, avoiding taker fees.

        - `fillAndKill` — guarantee taker. Match immediately or reject.
    MatchedFill:
      type: object
      description: A portion of an order that matched against existing liquidity.
      properties:
        amount:
          type: number
          description: Stake on the matched portion.
        odds:
          type: integer
          description: American odds of the fill.
        number:
          type: number
          nullable: true
          description: Spread or total of the fill (`null` for moneylines).
        type:
          $ref: '#/components/schemas/MarketType'
        side:
          $ref: '#/components/schemas/MarketSide'
        market:
          type: string
          description: Present for `moneyline1x2`.
        orderID:
          type: string
          description: Order id of the matched offer on the other side.
        txID:
          type: string
          description: Transaction id of the fill.
        wagerRequestID:
          type: string
          description: >-
            Server-generated id grouping every fill / offer derived from the
            input order.
        userReference:
          type: string
        risk:
          type: number
        win:
          type: number
          description: Win amount, net of taker commission.
        winWithoutCommission:
          type: number
          description: Win amount before commission.
    UnmatchedOffer:
      type: object
      description: >-
        Resting offer created from the unfilled remainder of a place request.
        May be empty (`{}`) when the order matched fully.
      properties:
        orderID:
          type: string
          description: Id of the new resting order.
        wagerRequestID:
          type: string
        offered:
          type: number
        odds:
          type: integer
        type:
          $ref: '#/components/schemas/MarketType'
        side:
          $ref: '#/components/schemas/MarketSide'
        market:
          type: string
          description: Present for `moneyline1x2`.
        number:
          type: number
          nullable: true
        userReference:
          type: string
    HttpError:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
    MarketType:
      type: string
      enum:
        - moneyline
        - spread
        - total
        - moneyline1x2
      description: >-
        Market type. `moneyline1x2` is **soccer-only** (three-way money line:
        home / away / draw).
    MarketSide:
      type: string
      description: |-
        Order side. Meaning depends on `type`:

        - `moneyline`, `spread` — the participant id you are backing.
        - `total` — `"over"` or `"under"`.
        - `moneyline1x2` — `"yes"` or `"no"` on the outcome named by `market`.
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HttpError'
    Unauthorized:
      description: Missing or invalid auth token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass your auth token in the `Authorization` header. The `Bearer` prefix
        is optional; the server also accepts a signed `auth` cookie or a `token`
        field in the request body.

````