> ## 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.

# Enviar orden de mercado

> Solicita una apertura y devuelve la respuesta de envío a MT5.

## Qué hace esta operación

Requiere cuenta verificada, trading habilitado e Idempotency-Key válida. El servicio devuelve 400 si falta el encabezado o su formato es inválido. Conserva clave y cuerpo antes de enviar; después guarda el ID MT5 y consulta su resultado.

## Proceso completo

Consulta [la guía paso a paso](https://api-trading-docs.ap-markets.com/es/trading/orders.md) y [los errores y su tratamiento](https://api-trading-docs.ap-markets.com/es/errors.md).

Los valores del explorador son ejemplos. Sustituye cuenta, símbolo, volumen y precio con datos válidos para tu integración.

## SL y TP opcionales

`sl` y `tp` son precios absolutos. Puedes enviar uno o ambos al abrir; omitidos
o `null` no se envían, y `0` indica ausencia del nivel. Se validan precisión y
distancias; no se redondean precios inválidos.
La protección de compra se valida respecto a Bid y la de venta respecto a Ask.

[Modificar órdenes o posiciones](https://api-trading-docs.ap-markets.com/es/trading/modifications.md) · [Volumen en unidades MT5](https://api-trading-docs.ap-markets.com/es/trading/volume.md)


## OpenAPI

````yaml es/openapi.json POST /api/v1/orders/market
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/market:
    post:
      tags:
        - Trading
      summary: Enviar orden de mercado
      description: >-
        Open a trade with optional SL/TP. Filling is automatic: FOK when
        allowed, otherwise IOC when supported. IOC may fill partially; check the
        result and positions. Unfilled volume is not resubmitted.
      operationId: market_order_api_v1_orders_market_post
      parameters:
        - 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/MarketOrderRequest'
            example:
              login: 104205
              symbol: EURUSD
              volume: 100
              side: buy
              comment: REST API
              sl: null
              tp: null
      responses:
        '200':
          description: Respuesta satisfactoria
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: 'Respuesta: Enviar orden de mercado'
        '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:
    MarketOrderRequest:
      properties:
        sl:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Sl
          description: >-
            Optional absolute Stop Loss price. Omit or send null to skip; 0
            specifies no SL.
        tp:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Tp
          description: >-
            Optional absolute Take Profit price. Omit or send null to skip; 0
            specifies no TP.
        login:
          type: integer
          exclusiveMinimum: 0
          title: Login
          description: Login de la cuenta de trading.
          examples:
            - 104205
          example: 104205
        symbol:
          type: string
          maxLength: 32
          minLength: 1
          pattern: ^[A-Za-z0-9._() -]+$
          title: Símbolo
          description: Nombre del símbolo MT5.
          examples:
            - EURUSD
          example: EURUSD
        volume:
          type: integer
          exclusiveMinimum: 0
          title: Volumen
          description: >-
            Integer MT5 units: 10000 = 1 lot, independent of contract size. Must
            match the symbol minimum, maximum and step.
          examples:
            - 100
          example: 100
        side:
          type: string
          enum:
            - buy
            - sell
          title: Dirección
          description: Dirección de la orden.
          examples:
            - buy
          example: buy
        price:
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: 'null'
          title: Precio
          description: >-
            Precio explícito anterior; envíalo junto con digits u omite ambos
            para precio automático.
          deprecated: true
        digits:
          anyOf:
            - type: integer
              maximum: 10
              minimum: 0
            - type: 'null'
          title: Decimales
          description: >-
            Decimales explícitos anteriores; omite este campo y price para usar
            la configuración del símbolo.
          deprecated: true
        comment:
          type: string
          maxLength: 31
          title: Comentario
          description: Comentario de la orden guardado en MT5.
          default: REST API
      additionalProperties: false
      type: object
      required:
        - login
        - symbol
        - volume
        - side
      title: Solicitud de orden de mercado
      examples:
        - comment: REST API
          login: 104205
          side: buy
          symbol: EURUSD
          volume: 100
  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.