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

# Cancelar una orden

> Cancela una sola orden abierta

Cancela una sola orden abierta por id. Devuelve los importes no cruzados y cruzados en el momento de la cancelación.

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

`POST /session/cancel`

<ParamField body="sessionID" type="string" required>
  Id de la orden a cancelar.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.4casters.io/session/cancel \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"sessionID": "65b036dfb31407c2b6bc1cfe"}'
  ```
</CodeGroup>

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

<ResponseField name="data" type="object">
  <Expandable title="CancelResult">
    <ResponseField name="success" type="boolean" />

    <ResponseField name="sessionID" type="string">Id de la orden que se canceló.</ResponseField>
    <ResponseField name="description" type="string">Descripción legible de la orden (p. ej. `Lakers -3.5 -110`).</ResponseField>
    <ResponseField name="odds" type="integer">Cuotas americanas de la orden cancelada.</ResponseField>
    <ResponseField name="filled" type="number">Riesgo que ya se había cruzado en el momento de la cancelación.</ResponseField>

    <ResponseField name="offered" type="number" />

    <ResponseField name="remaining" type="number">Riesgo que aún no estaba cruzado y ahora se reembolsa.</ResponseField>

    <ResponseField name="gameID" type="string" />

    <ResponseField name="userReference" type="string" />
  </Expandable>
</ResponseField>

<h3 id="example">
  Ejemplo
</h3>

<CodeGroup>
  ```json JSON theme={null}
  {
    "data": {
      "success": true,
      "sessionID": "65b036dfb31407c2b6bc1cfe",
      "description": "Lakers ML +125",
      "odds": 125,
      "filled": 0,
      "offered": 0,
      "remaining": 100,
      "gameID": "65f0c3c24ef07d0008abc123",
      "userReference": "my-order-1"
    }
  }
  ```
</CodeGroup>

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

| Estado | Significado |
| - | - |
| `400` | Id de orden inválido. |
| `403` | No es tu orden. |
| `409` | No se pudo cancelar la orden (p. ej. ya estaba totalmente cruzada). |


## OpenAPI

````yaml POST /session/cancel
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/cancel:
    post:
      tags:
        - Orders
      summary: Cancel a single order
      description: >-
        Cancel a single open order by id. Returns the unfilled and filled
        amounts at cancellation time.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sessionID
              properties:
                sessionID:
                  type: string
                  description: Order id to cancel.
            example:
              sessionID: 65b036dfb31407c2b6bc1cfe
      responses:
        '200':
          description: Cancel result
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CancelResult'
        '400':
          description: Invalid Order ID
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: Order could not be cancelled (e.g. already fully filled)
components:
  schemas:
    CancelResult:
      type: object
      properties:
        success:
          type: boolean
        reason:
          type: string
          description: Failure reason. Present only when `success` is `false`.
        sessionID:
          type: string
          description: Order id.
        description:
          type: string
          description: Human-readable order description (e.g. `Lakers -3.5 -110`).
        odds:
          type: integer
          description: American odds of the cancelled order.
        filled:
          type: number
        offered:
          type: number
        remaining:
          type: number
        gameID:
          type: string
        userReference:
          type: string
  responses:
    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.