# Cancel All Orders

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/account/orders:
    delete:
      summary: Cancel All Orders
      deprecated: false
      description: >-
        Submits a cancel request for all open orders of an account.


        Optionally the user can specify a list of `ids` representing order ids
        **or** a list of `client_ids`, and an `instrument_code`, as query
        parameters:

        - `instrument_code` alone cancels every open order on that instrument.

        - `ids` cancels those orders, regardless of the market they belong to.
        With `instrument_code`, only those orders on that instrument are
        cancelled.

        - `client_ids` cancels those orders and requires `instrument_code`: a
        client id is unique per instrument, not per account, so every listed
        client id must be on that instrument. To cancel by client id on several
        instruments, send one request per instrument.


        Calling this endpoint without any of the optional parameters will cancel
        all orders across all markets for the account. Calling it with both
        `ids` and `client_ids` is not supported.



        :::tip[]

        One Trading will always fill orders with best effort. Therefore, when
        attempting to close all orders, these orders may be in the process of
        being filled. In this case, One Trading will attempt to close the orders
        but the order may already be partially/fully filled.

        :::

        Make sure to have a valid API key with the scope TRADE, otherwise this
        operation will be rejected. This endpoint is not rate-limited.


        ### Response

        The response lists the cancellations the exchange confirmed within a
        short window, not every order submitted for cancellation:

        - Without parameters or with only `instrument_code`, it contains the
        order ids confirmed within about 100 ms. A successful request can
        therefore return a partial or empty list; use `GET /v1/account/orders`
        to check what remains open.

        - With `ids`, it contains the order ids confirmed within 2 seconds. IDs
        of orders that do not exist are skipped.

        - With `client_ids`, it contains the **client ids** (not order ids)
        confirmed within 2 seconds.


        `ids` and `client_ids` must be wrapped in square brackets, e.g.
        `[id1,id2]`.
      tags:
        - One Trading Public REST API/Trading
      parameters:
        - name: instrument_code
          in: query
          description: >-
            The instrument to cancel orders on. On its own, cancels every open
            order on the instrument; with `ids`, narrows the cancel to those
            orders on the instrument. Required with `client_ids`.
          required: false
          example: BTC_EUR
          schema:
            type: string
        - name: ids
          in: query
          description: Array of comma separated order ids to cancel orders for
          required: false
          example: >-
            [d1efc79d-f78d-4a9d-a4c0-dbe76c9a4e6f,8ada8f2d-56ea-4b24-bfd4-06723dfbb3be]
          schema:
            type: string
        - name: client_ids
          in: query
          description: >-
            Array of comma separated client ids to cancel orders for, all on
            `instrument_code` (required with this parameter)
          required: false
          example: >-
            [d1efc79d-f78d-4a9d-a4c0-dbe76c9a4e6f,8ada8f2d-56ea-4b24-bfd4-06723dfbb3be]
          schema:
            type: string
      responses:
        '200':
          x-apidog-name: Success
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  format: uuid
                  description: >-
                    Order ids (or client ids when cancelling by `client_ids`)
                    whose cancellation the exchange confirmed within the
                    response window
              examples:
                '1':
                  summary: Success Example
                  value: 7749a0ff-9a5f-41ac-a1a5-dc031a70091c
                '2':
                  summary: Success Example
                  value: 737f07d9-1711-49d0-a834-80b88329c101
          headers: {}
        '400':
          x-apidog-name: Bad Request
          description: >-
            Invalid parameters. `error` is `INVALID_PARAMETERS_NUMBER` (both
            `ids` and `client_ids`), `MISSING_INSTRUMENT_CODE` (`client_ids`
            without `instrument_code`), `INVALID_IDS` or `INVALID_CLIENT_IDS`
            (not a bracketed list of UUIDs).
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                '3':
                  summary: Both ids and client_ids
                  value:
                    error: INVALID_PARAMETERS_NUMBER
                '4':
                  summary: Invalid ids
                  value:
                    error: INVALID_IDS
                '5':
                  summary: Invalid client ids
                  value:
                    error: INVALID_CLIENT_IDS
                '12':
                  summary: Missing instrument code
                  value:
                    error: MISSING_INSTRUMENT_CODE
          headers: {}
        '401':
          x-apidog-name: Unauthorized
          description: >-
            Unauthorized. The token was accepted by the gateway but rejected by
            the endpoint: `UNAUTHORIZED`, or `INVALID_REQUEST_SIGNATURE` when
            the API key requires signed requests and the signature is missing or
            invalid.
          content:
            application/json:
              schema: *ref_0
              examples:
                '6':
                  summary: Unauthorized
                  value:
                    error: UNAUTHORIZED
                    error_message: Unauthorized access
                '7':
                  summary: Invalid signature
                  value:
                    error: INVALID_REQUEST_SIGNATURE
                    error_message: The request signature is missing or invalid
          headers: {}
        '403':
          x-apidog-name: Forbidden
          description: >-
            Forbidden. Either the gateway rejected the token
            (`{"message":"Forbidden"}`), or the endpoint denied the request,
            e.g. `PERMISSION_DENIED` (API key lacks the required scope, or
            account not permitted) or `EXCHANGE_ACCOUNT_NOT_PROVISIONED`.
          content:
            application/json:
              schema:
                oneOf:
                  - *ref_0
                  - $ref: '#/components/schemas/GatewayError'
              examples:
                '8':
                  summary: Gateway
                  value:
                    message: Forbidden
                '9':
                  summary: Permission denied
                  value:
                    error: PERMISSION_DENIED
                    error_message: Permission denied
                '10':
                  summary: Not provisioned
                  value:
                    error: EXCHANGE_ACCOUNT_NOT_PROVISIONED
                    error_message: >-
                      The account is authenticated but has no exchange account
                      yet
          headers: {}
        '500':
          x-apidog-name: Server Error
          description: >-
            The exchange failed to process the cancellation. `error` carries the
            exchange's message.
          content:
            application/json:
              schema: *ref_0
              example:
                error: Failed to cancel orders
          headers: {}
      security: []
      x-apidog-folder: One Trading Public REST API/Trading
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/349694/apis/api-3612095-run
components:
  schemas:
    ErrorResponse:
      type: object
      description: >-
        Error body. `error` is a machine-readable code (e.g.
        `INVALID_INSTRUMENT_CODE`) on most endpoints; a few older endpoints
        return a human-readable message in `error` instead and omit
        `error_message`.
      properties:
        error:
          type: string
          description: Error code (or, on older endpoints, a human-readable message).
        error_message:
          type: string
          description: >-
            Human-readable detail. Present on endpoints that return an error
            code in `error`.
      required:
        - error
      x-apidog-orders:
        - error
        - error_message
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
    GatewayError:
      type: object
      description: >-
        Returned by the API gateway itself when the bearer token is missing,
        invalid, expired or revoked, or the calling IP is not on the API key's
        allowlist.
      properties:
        message:
          type: string
          enum:
            - Forbidden
            - Unauthorized
      required:
        - message
      x-apidog-orders:
        - message
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
  securitySchemes:
    bearerAuth:
      type: bearer
      scheme: bearer
      description: >-
        API key issued to the account holder, sent as `Authorization: Bearer
        <token>`. The key must hold the `SUBACCOUNT_TRANSFER` scope.
    bearer:
      type: bearer
      scheme: bearer
servers:
  - url: https://api.onetrading.com/fast
    description: Production Env
security: []

```