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

# Consultar resultado

> Obtiene el resultado de una solicitud enviada por tu token.

`GET /api/v1/trading/requests/{request_id}` consulta una solicitud enviada con el
mismo token y una verificación de cuenta vigente. Usa el ID devuelto en `answer.id`
o `answer.ID`; no es un ticket de orden o posición.

## Confirmación

El envío devuelve un ID sin esperar la ejecución. Este GET lee el resultado
guardado y puede repetirse; no hace una consulta de la posición actual.

| Respuesta | Qué hacer |
| - | - |
| 200 | Leer `summary`: el resultado final puede ser éxito, rechazo o ejecución parcial. |
| 202 | Aún pendiente. Respetar `Retry-After` y repetir solo el GET, con un plazo máximo local. |
| 409 / `TRADE_RESULT_UNAVAILABLE` | No hay resultado final conservado; puede haber datos parciales. Consultar órdenes y posiciones antes de decidir otra acción. |
| 409 / `TRADE_RESULT_AMBIGUOUS` | El ID es ambiguo entre sesiones. Solicitar conciliación al proveedor. |
| 403 | Revisar token, permisos y vigencia de la verificación. |

Un timeout o resultado no disponible **no significa que la operación haya fallado**.
No reenvíes el POST con otra clave. Al agotar el plazo de seguimiento, marca la
solicitud como incierta y consulta el estado de la cuenta.

## Interpretar `summary`

HTTP 200 y el `retcode` exterior describen la consulta, no el éxito del trading.

| `status` | `success` | Significado |
| - | - | - |
| `succeeded` | true | Acción completada; un cierre parcial solicitado no cierra toda la posición. |
| `placed` | true | Orden pendiente colocada, todavía sin confirmar ejecución en mercado. |
| `rejected` | false | Rechazada; revisar `mt5_code` y `message`. |
| `partially_executed` | null | Ejecutada parcialmente; comprobar el volumen restante. |
| `pending` | null | Esperando confirmación. |
| `no_change` | null | El broker no realizó cambios. |
| `unknown` | null | Resultado incierto. |

`message` está en inglés. Códigos habituales: `10009` completada, `10008` pendiente
colocada, `10010` ejecución parcial, `10019` margen insuficiente y `10025` sin cambios.
`success: null` no equivale a éxito ni a rechazo.

`operation` identifica `market_order`, `place_pending`, `close_position`,
`cancel_order`, `modify_order` o `modify_position`. Solicitudes antiguas pueden
usar `modify_stops`; una operación no reconocida usa `unknown`.

## Encontrar la posición

Guarda `summary.position_id` cuando `position_resolution` sea `resolved`.
Comprueba que coincide con `Position` en las posiciones actuales antes de cerrarla
o modificarla. No lo deduzcas de `order_id` o `deal_id`.

| `position_resolution` | Significado |
| - | - |
| `pending` | Asociación todavía en proceso; repetir el GET más tarde. |
| `resolved` | Ticket asociado confirmado. |
| `not_applicable` | Esta solicitud no requiere asociar una ejecución a una posición. |
| `unavailable` | No pudo resolverse con los datos o intentos disponibles. |
| `mismatch` | Datos incompatibles; no se publica el ticket. |

La asociación se obtiene en segundo plano y es histórica: no garantiza que la
posición siga abierta. En netting, varias operaciones pueden compartir posición.
No lista todos los fills de una ejecución parcial ni sigue la activación futura
de una pendiente. Un fallo de asociación no justifica repetir la operación.

## Datos de solicitud y ejecución

`summary.execution` contiene lo informado por MT5 en el resultado guardado:

| Campo | Valor |
| - | - |
| `symbol`, `side`, `order_type` | Símbolo, buy/sell y código del tipo de orden. |
| `requested_volume`, `executed_volume` | Volumen solicitado y ejecutado, en unidades MT5: 10000 = 1 lote. |
| `requested_price`, `executed_price` | Precio solicitado y precio de ejecución informado. |
| `sl`, `tp` | Protección informada en esa solicitud; no son los niveles actuales. |

Precios y volúmenes pueden ser cadenas. `null` significa dato no disponible;
no se sustituye por cero. Un cero informado por MT5 se conserva. Los SL/TP no
guardados en resultados antiguos permanecen `null`.

`retcode` y `answer` se mantienen por compatibilidad, con campos públicos limitados.
Para conocer el estado vigente, consulta las órdenes o posiciones de la cuenta.

[Idempotencia](https://api-trading-docs.ap-markets.com/es/trading/idempotency.md) · [Volumen](https://api-trading-docs.ap-markets.com/es/trading/volume.md)


## OpenAPI

````yaml es/openapi.json GET /api/v1/trading/requests/{request_id}
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/trading/requests/{request_id}:
    get:
      tags:
        - Trading
      summary: Consultar resultado de solicitud
      description: >-
        Read a stored request result using the submitting token and a valid
        account verification. 202 means pending; 200 may include a rejection.
        Use summary to determine the outcome. This query does not fetch current
        positions.
      operationId: trade_request_result_api_v1_trading_requests__request_id__get
      parameters:
        - name: request_id
          in: path
          required: true
          schema:
            type: integer
            title: ID de solicitud
      responses:
        '200':
          description: Respuesta satisfactoria
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeResultWithSummary'
        '202':
          description: Result collection is pending; retry GET after Retry-After.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeResultPending'
        '409':
          description: >-
            Result unavailable or identifier ambiguous; reconcile without
            resubmitting.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeResultUnavailable'
        '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:
    TradeResultWithSummary:
      properties:
        retcode:
          type: string
          title: Retcode
        answer:
          anyOf:
            - additionalProperties:
                items:
                  $ref: '#/components/schemas/TradeResultEvent'
                type: array
              type: object
            - items:
                $ref: '#/components/schemas/TradeResultEvent'
              type: array
            - $ref: '#/components/schemas/TradeExecutionData'
          title: Answer
        summary:
          $ref: '#/components/schemas/TradeOutcome'
      additionalProperties: false
      type: object
      required:
        - retcode
        - answer
        - summary
      title: TradeResultWithSummary
    TradeResultPending:
      properties:
        summary:
          anyOf:
            - $ref: '#/components/schemas/TradeOutcome'
            - type: 'null'
        status:
          type: string
          const: pending
          title: Status
        request_id:
          type: integer
          title: ID de solicitud
        result:
          anyOf:
            - $ref: '#/components/schemas/TradeResultResponse'
            - type: 'null'
      type: object
      required:
        - status
        - request_id
      title: TradeResultPending
    TradeResultUnavailable:
      properties:
        summary:
          anyOf:
            - $ref: '#/components/schemas/TradeOutcome'
            - type: 'null'
        code:
          type: string
          enum:
            - TRADE_RESULT_UNAVAILABLE
            - TRADE_RESULT_AMBIGUOUS
          title: Code
        request_id:
          type: integer
          title: ID de solicitud
        detail:
          type: string
          title: Detalle
        result:
          anyOf:
            - $ref: '#/components/schemas/TradeResultResponse'
            - type: 'null'
      type: object
      required:
        - code
        - request_id
        - detail
      title: TradeResultUnavailable
    TradeResultEvent:
      properties:
        result:
          anyOf:
            - $ref: '#/components/schemas/TradeExecutionData'
            - type: 'null'
        answer:
          anyOf:
            - $ref: '#/components/schemas/TradeRequestData'
            - type: 'null'
      additionalProperties: false
      type: object
      title: TradeResultEvent
    TradeExecutionData:
      properties:
        ID:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Id
        Retcode:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Retcode
        DealID:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Dealid
        OrderID:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Orderid
        Volume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Volumen
          description: >-
            Confirmed execution volume in MT5 units: 10000 = 1 lot, independent
            of contract size. May be encoded as a string.
        Price:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Precio
        ResultRetcode:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultretcode
        ResultDeal:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultdeal
        ResultOrder:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultorder
        ResultVolume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultvolume
          description: >-
            Executed volume, which may be less than requested. MT5 units: 10000
            = 1 lot, independent of contract size. May be encoded as a string.
        ResultPrice:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Resultprice
        PriceSL:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Pricesl
        PriceTP:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Pricetp
      additionalProperties: false
      type: object
      title: TradeExecutionData
      description: >-
        Public execution fields, including the flat result format used by some
        brokers.
    TradeOutcome:
      properties:
        execution:
          anyOf:
            - $ref: '#/components/schemas/ExecutionDetails'
            - type: 'null'
        deal_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Deal Id
        order_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Order Id
        position_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Position Id
          description: >-
            Verified MT5 deal PositionID; historical association, not proof the
            position is still open.
        position_resolution:
          type: string
          enum:
            - pending
            - resolved
            - unavailable
            - not_applicable
            - mismatch
          title: Position Resolution
          default: pending
        request_id:
          type: integer
          title: ID de solicitud
        operation:
          type: string
          enum:
            - market_order
            - place_pending
            - close_position
            - cancel_order
            - modify_stops
            - modify_position
            - modify_order
            - unknown
          title: Operation
        status:
          type: string
          enum:
            - succeeded
            - rejected
            - partially_executed
            - placed
            - no_change
            - pending
            - unknown
          title: Status
        success:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Success
          description: >-
            True: requested action completed/placed; false: rejected; null:
            partial, pending, unchanged or uncertain. Placement is not a market
            fill.
        mt5_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Mt5 Code
        message:
          type: string
          title: Mensaje
      type: object
      required:
        - request_id
        - operation
        - status
        - success
        - mt5_code
        - message
      title: TradeOutcome
    TradeResultResponse:
      properties:
        retcode:
          type: string
          title: Retcode
        answer:
          anyOf:
            - additionalProperties:
                items:
                  $ref: '#/components/schemas/TradeResultEvent'
                type: array
              type: object
            - items:
                $ref: '#/components/schemas/TradeResultEvent'
              type: array
            - $ref: '#/components/schemas/TradeExecutionData'
          title: Answer
      additionalProperties: false
      type: object
      required:
        - retcode
        - answer
      title: TradeResultResponse
    TradeRequestData:
      properties:
        IDClient:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Idclient
        Symbol:
          anyOf:
            - type: string
            - type: 'null'
          title: Símbolo
        Type:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Type
        TypeFill:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Typefill
        Volume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Volumen
          description: >-
            Requested volume in MT5 units: 10000 = 1 lot, independent of
            contract size. May be encoded as a string.
        PriceOrder:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Priceorder
        Position:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Posición
        ResultRetcode:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultretcode
        ResultDeal:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultdeal
        ResultOrder:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultorder
        ResultVolume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Resultvolume
          description: >-
            Executed volume, which may be less than requested. MT5 units: 10000
            = 1 lot, independent of contract size. May be encoded as a string.
        ResultPrice:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Resultprice
        PriceSL:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Pricesl
        PriceTP:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Pricetp
      additionalProperties: false
      type: object
      title: TradeRequestData
    ExecutionDetails:
      properties:
        symbol:
          anyOf:
            - type: string
            - type: 'null'
          title: Símbolo
        side:
          anyOf:
            - type: string
              enum:
                - buy
                - sell
            - type: 'null'
          title: Dirección
        order_type:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Tipo de orden
        requested_volume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Requested Volume
        executed_volume:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Executed Volume
        requested_price:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Requested Price
        executed_price:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Executed Price
        sl:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Sl
          description: >-
            Historical SL reported in this request result; null means
            unavailable, not zero. Not the current position SL.
        tp:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: 'null'
          title: Tp
          description: >-
            Historical TP reported in this request result; null means
            unavailable, not zero. Not the current position TP.
      type: object
      title: ExecutionDetails
  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.