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

# Cancel all orders

> Cancel all of your resting orders, or only those in one market. The body is empty, {} or {"instrumentId": "…"}. Cancels only orders that existed when it ran. If more is true, call again. Allowed while trading is disabled or your account is suspended.

Guide: [Cancel all orders](/market-makers/orders#cancel-all-orders).



## OpenAPI

````yaml /api-reference/openapi.json post /mm/v1/orders/cancel-all
openapi: 3.1.0
info:
  title: D1 Market Maker API
  version: mm/v1
  description: >-
    API for authorized market makers: market data, account state, order
    placement and cancellation, fills and sequenced executions. Read endpoints
    require the mm:read scope; trading endpoints require mm:trade.
servers:
  - url: '{D1_API_URL}'
    description: Base URL provided by D1 during onboarding.
    variables:
      D1_API_URL:
        default: $D1_API_URL
        description: Provided by D1 during onboarding.
security:
  - bearerAuth:
      - mm:read
tags:
  - name: Status
  - name: Market data
  - name: Account
  - name: Orders
  - name: Trading
  - name: Executions
paths:
  /mm/v1/orders/cancel-all:
    post:
      tags:
        - Trading
      summary: Cancel all orders
      description: >-
        Cancel all of your resting orders, or only those in one market. The body
        is empty, {} or {"instrumentId": "…"}. Cancels only orders that existed
        when it ran. If more is true, call again. Allowed while trading is
        disabled or your account is suspended.


        Guide: [Cancel all orders](/market-makers/orders#cancel-all-orders).
      operationId: cancelAllOrders
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                instrumentId:
                  type: string
                  description: Only cancel orders in this market.
            example:
              instrumentId: <instrument-id>
      responses:
        '200':
          description: Cancelled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  cancelledOrderIds:
                    type: array
                    items:
                      type: string
                  cancelled:
                    type: integer
                  more:
                    type: boolean
                    description: true if resting orders remain; call again.
                  serverTimeMs:
                    type: string
                    description: D1 server time, Unix milliseconds, as a decimal string.
                    example: '1800000000510'
                required:
                  - cancelledOrderIds
                  - cancelled
                  - more
                  - serverTimeMs
              example:
                cancelledOrderIds:
                  - <order-id>
                  - <order-id>
                cancelled: 2
                more: false
                serverTimeMs: '1800000060000'
        '400':
          $ref: '#/components/responses/BadRequestWrite'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/CancelForbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/Internal'
      security:
        - bearerAuth:
            - mm:trade
components:
  responses:
    BadRequestWrite:
      description: MALFORMED_REQUEST.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: MALFORMED_REQUEST
            message: …
    Unauthorized:
      description: AUTH_REQUIRED, INVALID_API_KEY or API_KEY_REVOKED.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: INVALID_API_KEY
            message: …
    CancelForbidden:
      description: >-
        INSUFFICIENT_SCOPE (the key lacks mm:trade). A suspended account can
        still cancel.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: INSUFFICIENT_SCOPE
            message: …
    RateLimited:
      description: >-
        RATE_LIMITED: not admitted. Wait Retry-After seconds, then retry the
        same request.
      headers:
        Retry-After:
          description: Seconds until the rate-limit window ends (at least 1).
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: RATE_LIMITED
            message: Too many requests. Retry after the indicated delay.
    Internal:
      description: INTERNAL. Retry with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: INTERNAL
            message: …
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Stable error code.
          enum:
            - AUTH_REQUIRED
            - INVALID_API_KEY
            - API_KEY_REVOKED
            - DEALER_SUSPENDED
            - INSUFFICIENT_SCOPE
            - MALFORMED_REQUEST
            - INVALID_CURSOR
            - NOT_FOUND
            - RATE_LIMITED
            - INTERNAL
            - TRADING_DISABLED
            - UNKNOWN_INSTRUMENT
            - MARKET_NOT_TRADING
            - MARKET_PAUSED
            - INVALID_PRICE
            - INVALID_QUANTITY
            - IDEMPOTENCY_CONFLICT
            - INSUFFICIENT_FUNDS
            - INSUFFICIENT_POSITION
            - RISK_LIMIT
            - ORDER_NOT_FOUND
            - ORDER_NOT_CANCELLABLE
        message:
          type: string
          description: Human-readable message. Do not parse.
        limit:
          type: string
          enum:
            - MAX_OPEN_EXPOSURE
            - MAX_RESTING_ORDERS
            - MAX_RESTING_ORDERS_PER_INSTRUMENT
          description: >-
            Present only when error is RISK_LIMIT: the limit the order would
            exceed.
      required:
        - error
        - message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authorization: Bearer <your-api-key>. Scopes: mm:read (GET endpoints),
        mm:trade (POST endpoints).

````

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