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

# Cancel Order

> Cancel an open order.



## OpenAPI

````yaml POST /v1/matching/orders/cancel
openapi: 3.1.0
info:
  title: Options Matching API
  version: 1.0.0
  description: >-
    Order management endpoints for Rails Options. Base URLs vary by environment
    — see the Environments page. Authorize with the access token obtained from
    the Auth API.
servers:
  - url: https://api-options.sandbox.rails.xyz
security:
  - bearerAuth: []
paths:
  /v1/matching/orders/cancel:
    post:
      summary: Cancel Order
      description: >-
        Cancels an open order. See [Order
        Lifecycle](/latest/options/guides/order-lifecycle#placing-orders-over-rest).
      operationId: cancelOptionsOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelOrderRequest'
            example:
              clientRequestId: 9f1c2c9e-3f4a-4a4e-9f10-2b7d3f2a1c55
              cancel:
                orderId: 01JRQM8H5XYZABCDEFGHJKMNPQ
                contract: BTC-7FEB26-100000-C
      responses:
        '202':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelOrderQueued'
              example:
                queued: true
                accepted: false
                body: order queued, pending acceptance
                action: cancel
                messageId: 1770000000000-0
                clientRequestId: 9f1c2c9e-3f4a-4a4e-9f10-2b7d3f2a1c55
                contract: BTC-7FEB26-100000-C
                orderId: 01JRQM8H5XYZABCDEFGHJKMNPQ
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: orderId is required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          $ref: '#/components/responses/MatchingUnavailableOnSubmit'
        '504':
          $ref: '#/components/responses/MatchingTimeoutOnSubmit'
components:
  schemas:
    CancelOrderRequest:
      type: object
      properties:
        clientRequestId:
          type: string
          description: Client-generated UUID for correlation.
        cancel:
          $ref: '#/components/schemas/CancelTarget'
      required:
        - cancel
    CancelOrderQueued:
      type: object
      properties:
        queued:
          type: boolean
          description: Always `true`.
        accepted:
          type: boolean
          description: Always `false`.
        body:
          type: string
          description: Always `order queued, pending acceptance`.
        action:
          type: string
          description: Always `cancel`.
        messageId:
          type: string
          description: Identifier assigned to the queued request.
        clientRequestId:
          type: string
          description: Client-generated UUID for correlation.
        contract:
          type: string
          description: Contract name.
        orderId:
          type: string
          description: Unique identifier for the order.
      required:
        - queued
        - accepted
        - action
        - contract
        - orderId
    Error:
      type: object
      properties:
        error:
          type: string
          description: A human-readable message describing the error.
      required:
        - error
    CancelTarget:
      type: object
      properties:
        orderId:
          type: string
          description: Target order identifier.
        contract:
          type: string
          description: 'Contract name. Example value: `BTC-7FEB26-100000-C`.'
      required:
        - orderId
        - contract
  responses:
    Unauthorized:
      description: ''
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
    Forbidden:
      description: ''
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: read-only token cannot create orders
    RateLimited:
      description: ''
      headers:
        Retry-After:
          description: >-
            Number of seconds to wait before making another request (429
            responses only).
          required: true
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: api rate limit exceeded
    MatchingUnavailableOnSubmit:
      description: ''
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: matching service unavailable
    MatchingTimeoutOnSubmit:
      description: ''
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: matching service timed out
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````