Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JoseOlivares19/Proyecto-PC3-JavaScript-Avanzado/llms.txt

Use this file to discover all available pages before exploring further.

The /predict/fraud-shield endpoint analyses a single financial transaction against seven behavioral and contextual risk signals and returns one of three classification labels. The underlying RandomForest model weighs transaction amount, time-of-day, prior failed attempts, customer tenure, device novelty, country risk, and recent purchase frequency to produce a fraud risk score. The response includes confidence, a full probability ranking, and a concrete action set for your fraud operations team or automated decision engine.

Endpoint

POST http://localhost:8001/predict/fraud-shield
Content-Type: application/json

Request Body

monto
float
required
Transaction amount in local currency. Must be between 1 and 20000.
hora_24
integer
required
Hour of the day the transaction was initiated, in 24-hour format. Must be between 0 and 23.
intentos_previos
integer
required
Number of previous failed transaction attempts by this customer in the current session. Must be between 0 and 10.
antiguedad_cliente_meses
integer
required
Customer account age in months. Must be between 0 and 120. Newer accounts carry higher risk weight.
dispositivo_nuevo
integer
required
Whether the transaction originates from a device not previously seen for this account:
  • 0 — Known device
  • 1 — New / unrecognised device
pais_riesgo
integer
required
Risk classification of the transaction’s originating country:
  • 0 — Low-risk country
  • 1 — High-risk country
compras_ultima_hora
integer
required
Number of purchase attempts made by this account in the last 60 minutes. Must be between 0 and 20. Values above 5 contribute additional risk.

Example Request

curl -X POST http://localhost:8001/predict/fraud-shield \
  -H "Content-Type: application/json" \
  -d '{
    "monto": 8750.00,
    "hora_24": 2,
    "intentos_previos": 3,
    "antiguedad_cliente_meses": 1,
    "dispositivo_nuevo": 1,
    "pais_riesgo": 1,
    "compras_ultima_hora": 7
  }'

Example Response

{
  "caso": "FraudShield",
  "prediccion": "FRAUDE_PROBABLE",
  "confianza": 0.9467,
  "ranking": [
    { "clase": "FRAUDE_PROBABLE",    "probabilidad": 0.9467 },
    { "clase": "REVISION_MANUAL",    "probabilidad": 0.0421 },
    { "clase": "TRANSACCION_SEGURA", "probabilidad": 0.0112 }
  ],
  "recomendaciones": [
    "Bloquear temporalmente la operación.",
    "Solicitar autenticación reforzada.",
    "Registrar alerta para revisión del analista."
  ],
  "entrada": {
    "monto": 8750.0,
    "hora_24": 2,
    "intentos_previos": 3,
    "antiguedad_cliente_meses": 1,
    "dispositivo_nuevo": 1,
    "pais_riesgo": 1,
    "compras_ultima_hora": 7
  }
}

Response Fields

caso
string
Human-readable model identifier. Always "FraudShield" for this endpoint.
prediccion
string
The top predicted fraud classification. One of:
LabelMeaning
FRAUDE_PROBABLEHigh fraud risk — block and escalate immediately
REVISION_MANUALModerate risk — request additional customer verification
TRANSACCION_SEGURALow risk — authorise and continue passive monitoring
confianza
float
Probability assigned to the top predicted class, in the range 0.0 to 1.0.
ranking
array of objects
Probability distribution across all three fraud labels, sorted in descending order of probability.
recomendaciones
array of strings
Action set appropriate to the predicted label. For FRAUDE_PROBABLE this includes blocking and escalation steps; for REVISION_MANUAL it includes verification steps; for TRANSACCION_SEGURA it authorises the operation.
entrada
object
Echo of the validated request payload as parsed by Pydantic. Use this for audit logging without re-serialising the original request.
dispositivo_nuevo and pais_riesgo are binary integer flags (0 or 1). Boolean true/false values are not accepted and will produce a 422 Unprocessable Entity error.

Build docs developers (and LLMs) love