/api/anomaly_transactions

Header
POST https://api.Fluxrails.app/api/v1/ai/anomaly_transactions
X-Customer-Api-Id: <uuid>
X-Secret: <secret>
Content-Type: application/json
Request Body Schema
// Example Response Body
{
  "kpi": {
    "detected_pct": 14.29,    // % of rows flagged ≥ threshold
    "auc": 1.0                // ROC-AUC on labeled subset (if any labels)
  },
  "details": [
    {
      "id": "txn-001",
      "anomaly_score": -0.1224,
      "fraud_flag": false
    },
    {
      "id": "txn-004",
      "anomaly_score":  0.0064,
      "fraud_flag": true
    },
    {
      "id": "txn-006",
      "anomaly_score": -0.0987,
      "fraud_flag": false
    }
  ],
  "interpretation": "14.29% of records flagged by IsolationForest. Threshold = quantile(0.96) = -0.0000."
}
Example Request Body
// Request Body Schema
{
  "contamination": number,     // between 0 and 1, expected share of anomalies
  "rows": [
    {
      "id": "string",          // unique transaction ID
      "features": {            // any numeric or categorical fields
        "<key>": <number|string>, …
      },
      "label": 0|1|null        // optional ground-truth: 1=fraud, 0=legit, null/unset=unlabeled
    }
  ]
}
Example Response Body
// Example Request Body
{
  "contamination": 0.04,
  "rows": [
    {
      "id": "txn-001",
      "features": { "amount": 58.90,  "channel": "web",    "country": "BR", "hour": 17 },
      "label": 0
    },
    {
      "id": "txn-004",
      "features": { "amount": 9100.00,"channel": "pos",    "country": "NG", "hour": 2  },
      "label": 1
    },
    {
      "id": "txn-006",
      "features": { "amount": 820.00, "channel": "mobile", "country": "BR", "hour": 23 }
    }
  ]
}
Description

• Unsupervised anomaly scoring for transactions: flags the top-weird rows based on IsolationForest, LOF, or Auto-Encoder bake-off. • `contamination` sets the expected anomaly rate (decision threshold). • Returns per-transaction `anomaly_score` (higher = more anomalous) and boolean `fraud_flag`. • Provides batch KPIs: `detected_pct` and optional `auc` on labeled subset. • Delivers a one-line `interpretation` summarizing model choice, threshold, and flag rate.

Business Usage

• Stream real-time transaction feeds into this route for instant fraud triage. • Sort `details` by `anomaly_score` to prioritize high-risk reviews. • Monitor `detected_pct` drift to adjust `contamination` or feature set. • Feed back confirmed labels to improve model selection (higher AUC). • Integrate high-score flags into your risk engine for blocking or step-up authentication.

← Back to all routes