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

# Cancel all orders for a league

> Asynchronously cancel every open order in a league

Schedule cancellation of every open order in a league. This endpoint **dispatches asynchronously** — it acknowledges with `{ ordersReceived: true }` immediately and the cancels happen in the background.

If you need to know which orders were cancelled, follow up with [Get unmatched orders](/pages/rest/user/get-unmatched-orders) or subscribe to the user feed on the [WebSocket Streaming API](/pages/streaming/user-feed).

## Request

`POST /session/cancelAllForLeague`

<ParamField body="league" type="string" required>
  League code. Get the list from `GET /exchange/getLeagues`. Case-insensitive.
</ParamField>

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

## Response

<ResponseField name="data.ordersReceived" type="boolean">
  Always `true` on success. The cancellations are processed asynchronously.
</ResponseField>

### Example

<CodeGroup>
  ```json JSON theme={null}
  { "data": { "ordersReceived": true } }
  ```
</CodeGroup>

## Errors

| Status | Meaning                                     |
| ------ | ------------------------------------------- |
| `400`  | `league` missing, not a string, or unknown. |


## OpenAPI

````yaml POST /session/cancelAllForLeague
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/cancelAllForLeague:
    post:
      tags:
        - Orders
      summary: Cancel all orders for a league
      description: >-
        Schedule cancellation of every open order in a league. This endpoint
        **dispatches asynchronously** — it acknowledges with `{ ordersReceived:
        true }` immediately and the cancels happen in the background.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - league
              properties:
                league:
                  type: string
                  description: >-
                    League code from `GET /exchange/getLeagues`.
                    Case-insensitive.
            example:
              league: NBA
      responses:
        '200':
          description: Cancellation request accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      ordersReceived:
                        type: boolean
                        example: true
        '400':
          description: League missing or invalid
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  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.

````