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

# 取消多筆訂單

> 按 ID 批次取消訂單

按 ID 批次取消訂單。結果與輸入的 `sessionIDs` 陣列按位置對應，可能同時包含成功取消和單筆失敗。

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

`POST /session/cancelMultiple`

<ParamField body="sessionIDs" type="array" required>
  要取消的訂單 ID 陣列。每個 ID 必須是有效的 `ObjectID` — 若其中任何一個格式錯誤，整個請求會以 `400` 失敗。
</ParamField>

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

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

<ResponseField name="data" type="array">
  按單取消結果。形態與 [取消一筆訂單](/zh-Hant/pages/rest/orders/cancel-order#response) 相同。失敗時，條目包含 `{ success: false, reason: "..." }`（因無效 ID / 未找到 / 非本人而被拒絕時沒有 `sessionID` 欄位）。
</ResponseField>

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

<CodeGroup>
  ```json JSON theme={null}
  {
    "data": [
      {
        "success": true,
        "sessionID": "65b036dfb31407c2b6bc1cfe",
        "odds": 125,
        "filled": 0,
        "offered": 0,
        "remaining": 100,
        "gameID": "65f0c3c24ef07d0008abc123"
      },
      { "success": false, "reason": "Not your order" }
    ]
  }
  ```
</CodeGroup>

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

| 狀態 | 含義 |
| - | - |
| `400` | `sessionIDs` 缺失或不是陣列，或任一 ID 格式錯誤。 |


## OpenAPI

````yaml POST /session/cancelMultiple
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/cancelMultiple:
    post:
      tags:
        - Orders
      summary: Cancel multiple orders
      description: >-
        Cancel a batch of orders by id. The `data` array is positional with the
        input `sessionIDs` and may contain a mix of successful cancels and
        failures.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sessionIDs
              properties:
                sessionIDs:
                  type: array
                  items:
                    type: string
            example:
              sessionIDs:
                - 65b036dfb31407c2b6bc1cfe
                - 65b036e0b31407c2b6bc1d08
      responses:
        '200':
          description: Per-order cancel results
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/CancelResult'
        '400':
          description: '`sessionIDs` missing or not an array'
        '401':
          $ref: '#/components/responses/Unauthorized'
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.