> ## 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.

# Editar una orden

> Cambia el precio o el volumen de una orden en espera

Cambia el precio (`orderOdds`) y/o el volumen (`orderVolume`) de una orden **limit** existente.

En órdenes parcialmente cruzadas, 4casters cancela la orden existente y envía una nueva con los valores indicados. El nuevo `orderVolume` **no** descuenta el volumen ya cruzado: si originalmente colocaste `bet: 10`, se cruzaron $5 y editas a `orderVolume: 10`, la orden anterior se cancela (reembolsando $5) y se crea una nueva por $10 (debitando $10), dejándote \$5 netos menos.

<Note>
  Existe una variante gRPC más reciente en `POST /session/v4/editOrder`. Acepta el mismo cuerpo de solicitud y además devuelve `errorType` en fallos de validación. Prefiérela en integraciones nuevas cuando hayas confirmado que la forma te funciona.
</Note>

<h2 id="request">
  Solicitud
</h2>

`POST /session/editOrder`

<ParamField body="sessionID" type="string" required>
  Id de la orden a editar. Obténlo de `data.unmatched.orderID` de `/session/v3/place` o de `id` de `/user/getUnmatched`.
</ParamField>

<ParamField body="orderOdds" type="integer">
  Nuevas cuotas americanas. Pasa `null` para dejar las cuotas sin cambios.
</ParamField>

<ParamField body="orderVolume" type="number">
  Nuevo importe de `bet`. Pasa `null` para dejar el volumen sin cambios.
</ParamField>

<ParamField body="orderType" type="string">
  El valor por defecto es `limit`. Consulta [tipos de orden](/es/pages/rest/orders/place-order#order-types).
</ParamField>

<ParamField body="userReference" type="string">
  Opcional. Reemplaza el `userReference` existente de la orden.
</ParamField>

<ParamField body="intendedOrderVolume" type="number">
  Opcional. El volumen que originalmente pretendías colocar; el servidor lo usa al conciliar cruces parciales.
</ParamField>

<ParamField body="expiryChange" type="string">
  Opcional. Nueva expiración en minutos (cadena).
</ParamField>

<ParamField body="blockIfNoOtherSideOrders" type="boolean">
  Solo v4. Rechaza la edición si no hay liquidez en espera del lado contrario.
</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>

<h2 id="response">
  Respuesta
</h2>

El resultado refleja la forma de respuesta de [colocar orden](/es/pages/rest/orders/place-order#response): un resumen `cancelled` más el resultado nuevo `matched` / `unmatched`:

<ResponseField name="data.cancelled" type="object">
  Resumen de la orden original cancelada y reemplazada.
</ResponseField>

<ResponseField name="data.matched" type="array">
  Cruces producidos al reenviar al nuevo precio/volumen. Misma forma que un `MatchedFill` en [colocar orden](/es/pages/rest/orders/place-order#response).
</ResponseField>

<ResponseField name="data.unmatched" type="object">
  Oferta en espera del resto no cruzado de la nueva orden.
</ResponseField>

<h2 id="errors">
  Errores
</h2>

| Estado | Significado |
| - | - |
| `400` | Error de validación (`v4/editOrder` devuelve `errorType` en estos casos). |
| `503` | El servicio de órdenes no está disponible. |


## 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
        - fillOrKill
      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 whatever size is available at
        your price or better and cancel the remainder; never rests. A partial
        fill is a success; rejected only when there is no matchable liquidity at
        all.

        - `fillOrKill` — all-or-nothing taker. Match the entire `bet`
        immediately or the whole order is rejected and any partial fills are
        rolled back; never rests.
    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.

````

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