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

# Enrich, persist, and notify via webhook

> Mismo cuerpo que `POST /enrich-order`. Tras enriquecer y persistir, envía un POST JSON al webhook
(`ORDER_WEBHOOK_URL`) con **únicamente el payload enriquecido** (misma forma que el campo `payload`
de la respuesta 200 de `/enrich-order`).
La respuesta HTTP de **esta** API solo indica si el flujo y el webhook respondieron bien; no devuelve la orden.




## OpenAPI

````yaml api-reference/openapi.json POST /enrich-order-forward
openapi: 3.0.1
info:
  title: Api V3 documentación
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.artisn.desarrollo-redbrand.com/api
  - url: https://api.kfc-group.desarrollo-redbrand.com
  - url: https://{apiId}.execute-api.{region}.amazonaws.com/{stage}
    description: API Gateway (PRIVATE; invocación típica vía VPC endpoint).
    variables:
      apiId:
        default: '{api-id}'
        description: ID del API REST desplegado.
      region:
        default: us-east-1
      stage:
        default: dev
        description: Mismo valor que parámetro EnvironmentName del stack.
security:
  - bearerAuth: []
paths:
  /enrich-order-forward:
    post:
      tags:
        - Orders
      summary: Enriquecer, guardar y notificar por webhook
      description: >
        Mismo cuerpo que `POST /enrich-order`. Tras enriquecer y persistir,
        envía un POST JSON al webhook

        (`ORDER_WEBHOOK_URL`) con **únicamente el payload enriquecido** (misma
        forma que el campo `payload`

        de la respuesta 200 de `/enrich-order`).

        La respuesta HTTP de **esta** API solo indica si el flujo y el webhook
        respondieron bien; no devuelve la orden.
      operationId: enrichOrderForward
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnrichOrderRequest'
            examples:
              simple:
                summary: Payload mínimo (igual que en /enrich-order)
                value:
                  payload:
                    orderId: ord-001
                    store:
                      id: '21'
                    order:
                      products:
                        - modifierGroups:
                            - selectedModifiers:
                                - productId: sku-001
                                  price:
                                    totalPrice:
                                      total: 10.5
              igualQueEnrichOrder:
                summary: Mismo contrato que /enrich-order
                value:
                  payload:
                    orderId: ord-2025-001
                    source: pos
                    store:
                      id: store-br-01
      responses:
        '200':
          description: Orden persistida y webhook respondió 2xx
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichForwardOkResponse'
              examples:
                ok:
                  summary: Notificación entregada
                  value:
                    message: Orden enriquecida, guardada y notificada al destino.
        '400':
          description: >-
            Igual que `POST /enrich-order` (body, orderId, o errores fiscales
            con `code`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichOrderErrorResponse'
        '500':
          description: >-
            Error interno, ORDER_WEBHOOK_URL vacía, o fallo al
            enriquecer/persistir
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichOrderErrorResponse'
              examples:
                sinWebhook:
                  summary: URL de webhook no configurada
                  value:
                    message: ORDER_WEBHOOK_URL no configurada.
                proceso:
                  summary: Error genérico tras validación del webhook
                  value:
                    message: No se pudo completar el proceso.
                    error: 'Error: ...'
        '502':
          description: >-
            El destino no respondió, error de red, o respuesta HTTP no 2xx del
            webhook
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichOrderErrorResponse'
              examples:
                badGateway:
                  summary: Webhook 4xx/5xx
                  value:
                    message: El webhook de destino respondió con error.
                    error: 'HTTP 503: Service Unavailable'
                red:
                  summary: Sin respuesta HTTP / fallo de red
                  value:
                    message: No se pudo contactar el webhook de destino.
                    error: 'TypeError: fetch failed'
components:
  schemas:
    EnrichOrderRequest:
      description: >
        Raíz flexible: puede incluir `payload` u omitirse (entonces los campos
        de orden van en la raíz).

        Se permiten propiedades adicionales no listadas.
      type: object
      additionalProperties: true
      properties:
        payload:
          $ref: '#/components/schemas/OrderPayload'
    EnrichForwardOkResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: Orden enriquecida, guardada y notificada al destino.
    EnrichOrderErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
        error:
          type: string
          description: Detalle encadenado en errores 500 o 502.
        code:
          type: string
          description: >
            Presente en 400 por datos fiscales: FISCAL_PRODUCTO_SIN_NCM,
            FISCAL_MATRIZ_SIN_NCM, FISCAL_PRECIO_AUSENTE (solo si falta el
            bloque `totalPrice`, no por importes en 0).
    OrderPayload:
      type: object
      additionalProperties: true
      description: >-
        Datos de la orden (productos, tienda, pagos). `orderId` obligatorio para
        200.
      properties:
        orderId:
          type: string
          example: ord-2025-001
        source:
          type: string
          example: pos
        store:
          type: object
          properties:
            id:
              type: string
            code:
              type: string
            name:
              type: string
        order:
          type: object
          properties:
            products:
              type: array
              items:
                type: object
        payments:
          type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````