# Cancel Order by Order ID

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/account/orders/{order_id}:
    delete:
      summary: Cancel Order by Order ID
      deprecated: false
      description: >-
        Submits a request to close an open order by providing a valid
        `order_id`. Optionally pass the order's `instrument_code`.


        The call waits for the exchange to confirm the cancellation (up to 2
        seconds).


        Requires an API key with the `TRADE` scope. This endpoint is not
        rate-limited.
      tags:
        - One Trading Public REST API/Trading
      parameters:
        - name: order_id
          in: path
          description: The order ID of the order to cancel
          required: true
          example: ''
          schema:
            type: string
            format: uuid
        - name: instrument_code
          in: query
          description: >-
            Optional. The instrument the order is on; the exchange then looks
            for the order on this instrument only, and an order on another
            instrument is not found (`404`).
          required: false
          example: BTC_USDC
          schema:
            type: string
      responses:
        '200':
          x-apidog-name: OK
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  order_id:
                    type: string
                    format: uuid
                  client_id:
                    type: string
                    format: uuid
                  account_id:
                    type: string
                    format: uuid
                  instrument_code:
                    type: string
                  time:
                    type: string
                    format: date-time
                  side:
                    type: string
                  price:
                    type: string
                  amount:
                    type: string
                  type:
                    type: string
                    enum:
                      - LIMIT
                    x-apidog-enum:
                      - value: LIMIT
                        name: ''
                        description: ''
                    description: Always LIMIT
                  status:
                    type: string
                    enum:
                      - CANCELLED
                    x-apidog-enum:
                      - value: CANCELLED
                        name: ''
                        description: ''
                required:
                  - order_id
                  - client_id
                  - account_id
                  - instrument_code
                  - time
                  - side
                  - price
                  - amount
                  - type
                  - status
                x-apidog-orders:
                  - order_id
                  - client_id
                  - account_id
                  - instrument_code
                  - time
                  - side
                  - price
                  - amount
                  - type
                  - status
                x-apidog-ignore-properties: []
              example:
                order_id: e4cc5059-b6dd-4e7e-9d22-2d3576333fab
                client_id: 316d076d-76f7-49c6-beb1-7831e0f93a9e
                account_id: 726288e6-a463-4f88-9068-024ae8f97a34
                instrument_code: SOL_EUR
                time: '2024-11-14T15:56:37.417Z'
                side: SELL
                price: '150'
                amount: '1'
                type: LIMIT
                status: CANCELLED
          headers: {}
        '400':
          x-apidog-name: Bad Request
          description: Invalid identifier.
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Invalid order ID.
          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:
                '3':
                  summary: Unauthorized
                  value:
                    error: UNAUTHORIZED
                    error_message: Unauthorized access
                '4':
                  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:
                '5':
                  summary: Gateway
                  value:
                    message: Forbidden
                '6':
                  summary: Permission denied
                  value:
                    error: PERMISSION_DENIED
                    error_message: Permission denied
                '7':
                  summary: Not provisioned
                  value:
                    error: EXCHANGE_ACCOUNT_NOT_PROVISIONED
                    error_message: >-
                      The account is authenticated but has no exchange account
                      yet
          headers: {}
        '404':
          x-apidog-name: Record Not Found
          description: >-
            The exchange has no matching open order (on `instrument_code`, when
            given).
          content:
            application/json:
              schema: *ref_0
              example:
                error: Order not found.
          headers: {}
        '422':
          x-apidog-name: Unprocessable
          description: The exchange could not cancel the order.
          content:
            application/json:
              schema: *ref_0
              example:
                error: Order unprocessable.
          headers: {}
        '500':
          x-apidog-name: Server Error
          description: >-
            `Order response timeout` means the exchange did not confirm the
            cancellation in time; check the order status before retrying.
          content:
            application/json:
              schema: *ref_0
              examples:
                '10':
                  summary: Timeout
                  value:
                    error: Order response timeout
                '11':
                  summary: Server error
                  value:
                    error: Server error.
          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-3612096-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: []

```