> ## Documentation Index
> Fetch the complete documentation index at: https://docs.foresight.now/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel orders

> Cancel orders by hash, by filter, or all. **L2, permission `trade`.**



## OpenAPI

````yaml /api-reference/openapi-clob-v1.yaml post /v1/orders/cancel
openapi: 3.1.0
info:
  title: Foresight CLOB Trading API v1
  version: 1.0.0
  description: >
    Public-facing CLOB (central-limit order book) REST API for the Foresight

    prediction-market platform.


    This is a **different API from the legacy AMM Trade API** (`/trade/*`). The

    CLOB API trades signed limit/market orders against an order book instead of

    swapping against an automated market maker.


    ## Base URL


    ```

    https://api.foresight.now

    ```


    All routes below are prefixed with `/v1`.


    ## Auth tiers


    - **L0** — public, no credentials (all market-data routes).

    - **L1** — Privy JWT (`Authorization: Bearer <jwt>`); used for API-key
    management.

    - **L2** — Privy JWT **or** API-key headers (`fs-api-key` +
    `fs-api-secret`); used for trading and private reads.


    ## Market identity


    A market is identified by the pair **`condition_id`** (on-chain
    ConditionalTokens

    condition hash) + **`chain_id`** (blockchain network id). Internal database

    identifiers are never exposed.


    The CLOB currently runs on **BNB Smart Chain (BSC) mainnet — `chain_id:
    56`**.

    The collateral token on BSC has **18 decimals**. Always read the
    authoritative

    `decimals` from `GET /v1/markets/{condition_id}/tokens` rather than
    hard-coding

    it — amount math signed at the wrong scale is rejected at ingest.


    ## Async matching


    `POST /v1/orders` always returns `status: OPEN`. Matching runs in a
    background

    worker; matched / partial / failed transitions arrive on the private `user`

    WebSocket channel (`wss://api.foresight.now/v1/ws`).


    ## Error envelope


    Every non-2xx response is shaped as (all field names snake_case):


    ```json

    {
      "correlation_id": "abc-123",
      "code": "NOT_FOUND",
      "message": "Market not found",
      "status_code": 404,
      "timestamp": "2026-06-03T10:15:30.000Z",
      "path": "/v1/markets/0x.../book"
    }

    ```
servers:
  - url: https://api.foresight.now
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags:
  - name: Auth
    description: API-key lifecycle and WebSocket token issuance.
  - name: Market Data
    description: Public markets, orderbook, ticker, trades, tokens. L0 — no auth.
  - name: Orders
    description: Place, list, and cancel signed EIP-712 orders. L2.
  - name: Fills
    description: Authenticated wallet's fill history. L2.
  - name: Positions
    description: Authenticated wallet's CLOB positions. L2.
paths:
  /v1/orders/cancel:
    post:
      tags:
        - Orders
      summary: Cancel orders
      description: Cancel orders by hash, by filter, or all. **L2, permission `trade`.**
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelOrdersRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelOrdersResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
      security:
        - PrivyJWT: []
        - ApiKey: []
          ApiSecret: []
components:
  schemas:
    CancelOrdersRequest:
      type: object
      description: |
        Three modes, resolved by body shape:
          1. **By hash** — `order_hashes`, up to 100 hashes per request.
          2. **By filter** — any subset of `condition_id` + `chain_id` + `outcome` + `side`. Filtering by market requires both `condition_id` and `chain_id`.
          3. **Cancel all** — empty body. Cancels the caller's OPEN / PARTIALLY_FILLED orders.
      properties:
        order_hashes:
          type: array
          items:
            type: string
          maxItems: 100
        condition_id:
          type: string
        chain_id:
          type: integer
          example: 56
        outcome:
          type: integer
          enum:
            - 0
            - 1
        side:
          type: string
          enum:
            - BUY
            - SELL
    CancelOrdersResponse:
      type: object
      properties:
        cancelled_count:
          type: integer
          example: 3
        order_hashes:
          type: array
          description: >-
            Hashes actually cancelled. Individual non-cancellable orders are
            silently skipped.
          items:
            type: string
    Error:
      type: object
      required:
        - correlation_id
        - code
        - message
        - status_code
        - timestamp
        - path
      properties:
        correlation_id:
          type: string
          description: Request correlation id; falls back to `"unknown"` when none is set.
        code:
          type: string
          example: NOT_FOUND
        message:
          type: string
        status_code:
          type: integer
          example: 404
        timestamp:
          type: string
          format: date-time
        path:
          type: string
          example: /v1/markets/0x.../book
  responses:
    ErrorResponse:
      description: Error envelope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    PrivyJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Privy-issued JWT. Required for L1 routes; accepted on L2 routes.
    ApiKey:
      type: apiKey
      in: header
      name: fs-api-key
      description: >-
        API key id issued by `POST /v1/auth/api-keys`. Pair with
        `fs-api-secret`.
    ApiSecret:
      type: apiKey
      in: header
      name: fs-api-secret
      description: Plaintext secret returned once at API-key creation.

````