> ## Documentation Index
> Fetch the complete documentation index at: https://api-trading-docs.ap-markets.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a pending order

> Use the pending Order ticket and verified login. Returns a request ID; check its result to confirm cancellation. If the order fills first, cancellation does not close the resulting position.

Send only the verified account login. The order ticket is in the URL. The receipt is not a final cancellation: query the returned request ID. If the order executes first, cancellation may fail; the resulting position is never closed automatically.

```json theme={null}
{"login": 104205}
```

`Idempotency-Key` is required. Reuse the same key when retrying the same intent.


## OpenAPI

````yaml POST /api/v1/orders/{order}/cancel
openapi: 3.1.0
info:
  title: AP Markets API — Partner Portal
  description: >-
    Endpoints seguros para verificar la propiedad de cuentas, consultar el
    mercado y operar en cuentas previamente verificadas.
  version: 0.1.0
servers:
  - url: https://api-trading.ap-markets.com
    description: AP Markets API
security: []
paths:
  /api/v1/orders/{order}/cancel:
    post:
      tags:
        - Trading
      summary: Cancelar una orden pendiente
      description: >-
        Use the pending Order ticket and verified login. Returns a request ID;
        check its result to confirm cancellation. If the order fills first,
        cancellation does not close the resulting position.
      operationId: cancel_order_api_v1_orders__order__cancel_post
      parameters:
        - name: order
          in: path
          required: true
          schema:
            type: integer
            title: Order
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 16
            maxLength: 128
            pattern: ^[A-Za-z0-9._:-]{16,128}$
            example: 550e8400-e29b-41d4-a716-446655440000
          description: >-
            Persisted key for this intent. Reuse the same key and body when
            retrying; use a new key for another trading intent, including a
            modification.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelOrderRequest'
      responses:
        '200':
          description: Respuesta satisfactoria
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: 'Respuesta: Cancelar una orden pendiente'
        '400':
          description: Idempotency-Key ausente o inválida.
        '409':
          description: Clave reutilizada con otros datos o solicitud pendiente.
        '422':
          description: Invalid request or incompatible trading parameters.
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    type: string
              example:
                detail: Invalid request
      security:
        - HTTPBearer: []
components:
  schemas:
    CancelOrderRequest:
      properties:
        login:
          type: integer
          exclusiveMinimum: 0
          title: Login
          description: Verified owner account login.
          example: 123456
      additionalProperties: false
      type: object
      required:
        - login
      title: CancelOrderRequest
      examples:
        - login: 104205
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Envía el token entregado por el proveedor en el encabezado Authorization
        mediante autenticación Bearer.

````

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