{
  "openapi": "3.0.3",
  "info": {
    "title": "Migo Credits API v2",
    "version": "2.0.0",
    "description": "API de créditos de Migo. Cuatro servicios: cr-users, cr-transactions, cr-accounts y cr-webhooks. Todos los endpoints de negocio requieren el header `Authorization` validado por un TOKEN Authorizer en API Gateway. Los webhooks (callbacks de banco/colector) y los eventos internos (EventBridge/SNS) no usan ese authorizer. Persistencia: MySQL (RDS) + MongoDB (configuración). No se usa PostgreSQL.\n"
  },
  "servers": [
    {
      "url": "https://{host}/v2/credits",
      "description": "Base de los servicios de crédito v2",
      "variables": {
        "host": {
          "default": "api.migopayments.com"
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Users"
    },
    {
      "name": "Transactions"
    },
    {
      "name": "Accounts"
    },
    {
      "name": "Webhooks"
    }
  ],
  "security": [
    {
      "tokenAuth": []
    }
  ],
  "paths": {
    "/users": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Crear usuario de crédito (idempotente por número de documento)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewUserInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Usuario creado o existente",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/NewUserOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "6010 datos faltantes · 6014 fecha inválida · 6015 género inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users/{userUID}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Consultar usuario por UID",
        "parameters": [
          {
            "name": "userUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usuario",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/NewUserOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "6001 usuario no encontrado / parámetro faltante",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users/{userUID}/banks/{bankSlug}/affiliations": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Iniciar afiliación del usuario con un banco (envía OTP)",
        "parameters": [
          {
            "name": "userUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bankSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "bam"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AffiliateUserInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Solicitud enviada al banco",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AffiliateUserOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "6010 datos · 6011 email · 6012 phone · 6013 phone2 · 5000 banco sin afiliación",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "2001 config no encontrada · 6001 usuario no existe · 6000 ya afiliado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users/{userUID}/banks/{bankSlug}/affiliations/otp": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Validar OTP de afiliación",
        "parameters": [
          {
            "name": "userUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bankSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AffiliationOTPInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resultado de validación de OTP",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AffiliationOTPOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "2001 config · 6001 usuario",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users/pre-qualifieds": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Crear usuario pre-calificado",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPreQualifiedInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pre-calificado creado",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/NewPreQualifiedOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "6010 datos faltantes / error al crear",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users/pre-qualifieds/{code}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Consultar pre-calificados por código",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Arreglo de pre-calificados",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/NewPreQualifiedOutput"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "6010 no encontrados",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/transactions": {
      "post": {
        "tags": [
          "Transactions"
        ],
        "summary": "Crear transacción de crédito",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewTransactionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transacción creada",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/NewTransactionOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "2003 monto · 2004 usuario bloqueado · 6001 usuario crédito",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{trxUID}/authorize": {
      "post": {
        "tags": [
          "Transactions"
        ],
        "summary": "Preautorizar (reservar) el monto con la entidad financiera",
        "parameters": [
          {
            "name": "trxUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthorizeTransactionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transacción autorizada (o DENIED si el banco rechaza)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/TransactionResponse"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "2000 transacción no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "2004 bloqueado / OTP inválido · 2002 cuenta no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{trxUID}/capture": {
      "post": {
        "tags": [
          "Transactions"
        ],
        "summary": "Capturar (cobrar) el monto preautorizado",
        "parameters": [
          {
            "name": "trxUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CaptureTransactionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transacción aprobada (o DENIED)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/CaptureTransactionOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "2000 no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "2000 estado inválido · 2003 banco sin respuesta",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{trxUID}/cancel": {
      "delete": {
        "tags": [
          "Transactions"
        ],
        "summary": "Cancelar transacción (antes del cobro)",
        "parameters": [
          {
            "name": "trxUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transacción cancelada / dismissed",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/CancelVoidOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "2001 no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "2000 estado no cancelable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{trxUID}/void": {
      "delete": {
        "tags": [
          "Transactions"
        ],
        "summary": "Reversar transacción ya capturada (asíncrono, resuelto por webhook)",
        "parameters": [
          {
            "name": "trxUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Solicitud de reverso enviada al banco (status PENDING)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/CancelVoidOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "2001 no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "2000 no reversable / banco sin reverso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/accounts": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Consultar datos de cuenta de crédito",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Datos de cuenta",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AccountOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "6000 faltan parámetros · 6003 cuenta no encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/accounts/otp": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Enviar OTP de cuenta",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountOTPInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OTP enviado (device = teléfono enmascarado)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AccountOTPOutput"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "6000 faltan parámetros",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/merchants/{merchant}/users/{user}/banks/{bank}/affiliations": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [],
        "summary": "(Banco → Migo) Respuesta de afiliación",
        "parameters": [
          {
            "name": "merchant",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "user",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bank",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BankAffiliationWebhookInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Procesado"
          }
        }
      }
    },
    "/webhooks/banks/{bank}/accounts/updates": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [],
        "summary": "(Banco → Migo) Actualización de cuenta (amortización / mora)",
        "parameters": [
          {
            "name": "bank",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BankNotificationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Procesado"
          }
        }
      }
    },
    "/webhooks/collectors/{collector}/payment": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [],
        "summary": "(Colector → Migo) Notificación de pago",
        "parameters": [
          {
            "name": "collector",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CollectorPaymentNotificationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Procesado"
          }
        }
      }
    },
    "/webhooks/unbanked/credits/authorize": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [],
        "summary": "(MO → Migo) Autorización de crédito no bancarizado",
        "responses": {
          "200": {
            "description": "Procesado"
          }
        }
      }
    },
    "/webhooks/transactions/cancellation": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [],
        "summary": "(EventBridge → Migo) Cancelación automática de transacciones expiradas",
        "responses": {
          "200": {
            "description": "Procesado"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "tokenAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "TOKEN Authorizer de API Gateway. Valor = token emitido por Migo."
      }
    },
    "schemas": {
      "SuccessEnvelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "type": "object"
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "6010"
              },
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "message": {
                "type": "string",
                "example": "Missing user data"
              }
            }
          },
          "data": {
            "type": "object"
          }
        }
      },
      "NewUserInput": {
        "type": "object",
        "required": [
          "firstName",
          "lastName",
          "document",
          "dateOfBirth",
          "gender",
          "userAddress"
        ],
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "middleName": {
            "type": "string"
          },
          "extraName": {
            "type": "string"
          },
          "secondSurname": {
            "type": "string"
          },
          "marriedName": {
            "type": "string"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female"
            ]
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "example": "1990-05-20"
          },
          "maritalStatus": {
            "type": "string"
          },
          "nationality": {
            "type": "string"
          },
          "taxId": {
            "type": "string"
          },
          "document": {
            "type": "object",
            "required": [
              "type",
              "number"
            ],
            "properties": {
              "type": {
                "type": "string",
                "example": "DPI"
              },
              "number": {
                "type": "string"
              },
              "expiration": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "userAddress": {
            "type": "object",
            "required": [
              "address",
              "department",
              "city"
            ],
            "properties": {
              "address": {
                "type": "string"
              },
              "department": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "country": {
                "type": "string"
              }
            }
          }
        }
      },
      "NewUserOutput": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "documentType": {
            "type": "string"
          },
          "documentNumber": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "CREATED"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AffiliateUserInput": {
        "type": "object",
        "required": [
          "merchant",
          "clientCode",
          "phone"
        ],
        "properties": {
          "merchant": {
            "type": "string"
          },
          "clientCode": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "phone2": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "callbackUrl": {
            "type": "string",
            "format": "uri"
          },
          "additionalBankData": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "businessName": {
                "type": "string"
              },
              "score": {
                "type": "number"
              },
              "preApprovedAmount": {
                "type": "number"
              },
              "monthlyIncome": {
                "type": "number"
              },
              "monthlyExpenses": {
                "type": "number"
              }
            }
          }
        }
      },
      "AffiliateUserOutput": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "merchant": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "Affiliation requested"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AffiliationOTPInput": {
        "type": "object",
        "required": [
          "merchant",
          "clientCode",
          "code"
        ],
        "properties": {
          "merchant": {
            "type": "string"
          },
          "clientCode": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "example": "123456"
          }
        }
      },
      "AffiliationOTPOutput": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "merchant": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "NewPreQualifiedInput": {
        "type": "object",
        "required": [
          "code",
          "customer",
          "bank",
          "name",
          "phone"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "customer": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        }
      },
      "NewPreQualifiedOutput": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "customer": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "NewTransactionInput": {
        "type": "object",
        "required": [
          "merchant",
          "clientCode",
          "amount"
        ],
        "properties": {
          "merchant": {
            "type": "string",
            "description": "clientSlug"
          },
          "clientCode": {
            "type": "string",
            "description": "id del usuario en el comercio"
          },
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "GTQ"
          },
          "channel": {
            "type": "string",
            "example": "wa"
          },
          "externalId": {
            "type": "string"
          },
          "createdBy": {
            "type": "string"
          },
          "ads": {
            "type": "array",
            "items": {}
          },
          "processorAmount": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "userInfo": {
            "type": "object",
            "properties": {
              "firstName": {
                "type": "string"
              },
              "lastName": {
                "type": "string"
              },
              "phone": {
                "type": "string"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "emailTo": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "postback": {
            "type": "object",
            "properties": {
              "approved": {
                "type": "string"
              },
              "denied": {
                "type": "string"
              },
              "dismis": {
                "type": "string"
              },
              "cancel": {
                "type": "string"
              },
              "error": {
                "type": "string"
              }
            }
          },
          "customerKeys": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "NewTransactionOutput": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "URL": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "AuthorizeTransactionInput": {
        "type": "object",
        "required": [
          "account",
          "processor",
          "code"
        ],
        "properties": {
          "account": {
            "type": "string"
          },
          "processor": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "OTP"
          }
        }
      },
      "TransactionResponse": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "AUTHORIZED"
          },
          "channel": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "paymentData": {
            "type": "object"
          }
        }
      },
      "CaptureTransactionInput": {
        "type": "object",
        "properties": {
          "captureAmount": {
            "type": "number",
            "description": "Opcional; si se omite captura el total"
          }
        }
      },
      "CaptureTransactionOutput": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "APPROVED"
          },
          "total": {
            "type": "number"
          },
          "bank": {
            "type": "string"
          }
        }
      },
      "CancelVoidOutput": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AccountInput": {
        "type": "object",
        "required": [
          "bank"
        ],
        "description": "Requiere bank y al menos uno de: trxUID o user.value",
        "properties": {
          "bank": {
            "type": "string"
          },
          "trxUID": {
            "type": "string"
          },
          "user": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            }
          }
        }
      },
      "AccountOutput": {
        "type": "object",
        "properties": {
          "account": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "balance": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "approvedAmount": {
            "type": "number"
          },
          "usedAmount": {
            "type": "number"
          },
          "bank": {
            "type": "string"
          },
          "payment": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "paymentDate": {
                "type": "string"
              }
            }
          },
          "buy": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "paymentDate": {
                "type": "string"
              }
            }
          }
        }
      },
      "AccountOTPInput": {
        "type": "object",
        "required": [
          "trxUID",
          "account"
        ],
        "properties": {
          "trxUID": {
            "type": "string"
          },
          "account": {
            "type": "string"
          }
        }
      },
      "AccountOTPOutput": {
        "type": "object",
        "properties": {
          "device": {
            "type": "string",
            "description": "Teléfono enmascarado",
            "example": "****5678"
          }
        }
      },
      "BankAffiliationWebhookInput": {
        "type": "object",
        "required": [
          "status",
          "merchant",
          "bank",
          "userUid"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "authorized",
              "not_authorized",
              "error",
              "missing_data",
              "pending"
            ]
          },
          "account": {
            "type": "string"
          },
          "accountLimit": {
            "type": "number"
          },
          "approvedAmount": {
            "type": "number"
          },
          "balance": {
            "type": "number"
          },
          "outstandingBalance": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "bankData": {
            "type": "object",
            "properties": {
              "pin": {
                "type": "string"
              },
              "productId": {
                "type": "string"
              },
              "offerId": {
                "type": "string"
              }
            }
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "merchant": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "userUid": {
            "type": "string"
          },
          "clientCode": {
            "type": "string"
          }
        }
      },
      "BankNotificationInput": {
        "type": "object",
        "required": [
          "account",
          "changes",
          "notificationType"
        ],
        "properties": {
          "account": {
            "type": "string"
          },
          "notificationType": {
            "type": "string",
            "enum": [
              "debtAmortization",
              "delinquencyUpdate"
            ]
          },
          "changes": {
            "type": "object",
            "properties": {
              "interest": {
                "type": "number"
              },
              "inDefault": {
                "type": "boolean"
              },
              "daysOverdue": {
                "type": "number"
              },
              "debtAmortization": {
                "type": "number"
              },
              "transaction": {
                "type": "string"
              },
              "transactionStatus": {
                "type": "string",
                "enum": [
                  "amortized",
                  "delinquency",
                  "authorized"
                ]
              },
              "overdueAmount": {
                "type": "number"
              },
              "timestamp": {
                "type": "string"
              }
            }
          }
        }
      },
      "CollectorPaymentNotificationInput": {
        "type": "object",
        "required": [
          "transactionId",
          "amount",
          "currency",
          "status",
          "date"
        ],
        "properties": {
          "transactionId": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "amount": {
            "type": "number"
          },
          "fee": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "externalEntityId": {
            "type": "string"
          },
          "externalTransactionId": {
            "type": "string"
          },
          "date": {
            "type": "string"
          }
        }
      }
    }
  }
}