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

# 取消某聯賽的全部訂單

> 非同步取消某聯賽中的每一筆未成交訂單

安排取消某聯賽中的每一筆未成交訂單。此端點**非同步處理** — 立即以 `{ ordersReceived: true }` 確認，取消在後台進行。

若需要知道哪些訂單被取消，請隨後呼叫 [獲取未撮合訂單](/zh-Hant/pages/rest/user/get-unmatched-orders)，或訂閱 [WebSocket 推送 API](/zh-Hant/pages/streaming/user-feed) 上的使用者推送。

<h2 id="request">
  請求
</h2>

`POST /session/cancelAllForLeague`

<ParamField body="league" type="string" required>
  聯賽代碼。列表可從 `GET /exchange/getLeagues` 獲取。不區分大小寫。
</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>

<h2 id="response">
  回應
</h2>

<ResponseField name="data.ordersReceived" type="boolean">
  成功時始終為 `true`。取消操作非同步處理。
</ResponseField>

<h3 id="example">
  示例
</h3>

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

<h2 id="errors">
  錯誤
</h2>

| 狀態 | 含義 |
| - | - |
| `400` | `league` 缺失、不是字串，或未知。 |


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

````

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