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

# POST /analyze

> Real-time scoring for a transaction

```
POST {API_BASE}/v1/transactions/analyze
```

`{API_BASE}` is `https://sandbox-api.fraudeg.com/api` or `https://api.fraudeg.com/api`, depending on
your [environment](https://docs.fraudeg.com/en/entornos.md). In production:

```
POST https://api.fraudeg.com/api/v1/transactions/analyze
```

Scores a live transaction and returns a decision. This route **does** treat the call
as live traffic.

To see the mature model's response **without** treating it as live —in production or in
pre-official-integration— use [`/analyze/sandbox`](https://docs.fraudeg.com/en/referencia/analyze-sandbox). That path
is a mode, not the sandbox host.

## Headers

| Header | Required | Description |
| - | - | - |
| `X-Api-Key` | Yes | `TRANSACTIONS_WRITE` scope. See [Authentication](https://docs.fraudeg.com/en/integrar/autenticacion.md) |
| `X-Idempotency-Key` | Yes | 16–128 url-safe characters. See [Idempotency](https://docs.fraudeg.com/en/integrar/idempotencia.md) |
| `Content-Type` | Yes | `application/json` |

## Request

Required fields:

| Field | Type | Accepted wire alias |
| - | - | - |
| `order_id` | string | — |
| `user_id` | string | — |
| `transaction_amount` | number | — |
| `payment_method` | string | `paymentInstrumentType` |

The canonical name is `payment_method`. `paymentInstrumentType` is the same field under a different
name in the JSON. It accepts up to 50 characters; a longer value returns `422`. See [Payment methods and rails](https://docs.fraudeg.com/en/referencia/metodos-de-pago.md).

All other fields are optional. The full list is in [Fields](https://docs.fraudeg.com/en/integrar/campos.md).

```json theme={null}
{
  "order_id": "8788426783",
  "user_id": "usr_48213",
  "transaction_amount": 129.90,
  "payment_method": "card",
  "cavv_result": "failed",
  "device_id": "dvc_a91f",
  "ip_address": "190.12.4.55"
}
```

## Response

```json theme={null}
{
  "data": {
    "transaction_id": "01e6efd4-c884-5bc0-af43-68b3fac8d0f8",
    "order_id": "8788426783",
    "risk_score": 29.07,
    "risk_level": "medium",
    "flags": [
      {
        "code": "AUTH_3DS_FAILED",
        "category": "authentication",
        "severity": "high",
        "description": "3DS authentication explicitly failed"
      }
    ],
    "recommendation": "…",
    "decision": {
      "type": "BLOCK",
      "reason": ["AUTH_3DS_FAILED"],
      "confidence": 0.89,
      "conditions": []
    },
    "transaction_state": "BLOCKED"
  },
  "timestamp": "2026-07-29T16:43:36.22",
  "status": "OK"
}
```

Field by field: [Response format](https://docs.fraudeg.com/en/referencia/respuesta.md). In particular:

* [`decision.type`](https://docs.fraudeg.com/en/conceptos/decisiones) is the only actionable field — never act
  on `risk_score`.
* The catalog of `flags[].code` lives in [Flags catalog](https://docs.fraudeg.com/en/referencia/flags.md), not here.
* `recommendation` is a sentence in the company's language. Don't branch on it.

## Errors

The public API error envelope is:

```json theme={null}
{
  "error_code": "DATA_CONFLICT",
  "message": "There is a conflict with the provided information.",
  "details": "A request with this X-Idempotency-Key is already in progress",
  "timestamp": "2026-07-29T16:43:36.22"
}
```

`error_code` comes from the [error codes](https://docs.fraudeg.com/en/referencia/codigos-de-error.md) catalog. The text
that tells one case from another is in **`details`**, not in `message` (`message` is the code's generic
prose).

### HTTP statuses for this endpoint

| HTTP | Typical `error_code` | When |
| - | - | - |
| `400` | `BAD_REQUEST` | `X-Idempotency-Key` header missing or invalidly formatted (16–128, url-safe alphabet) |
| `403` | `INSUFFICIENT_PERMISSIONS` | The key doesn't have `TRANSACTIONS_WRITE`, or is used on a route that doesn't accept API keys |
| `409` | `DATA_CONFLICT` | **Two cases**, distinguishable by `details`. See below |
| `422` | `VALIDATION_ERROR` | Invalid payload, or the same `X-Idempotency-Key` was used with a different payload |
| `429` | `TOO_MANY_REQUESTS` | Rate limit |
| `503` | `SERVICE_UNAVAILABLE` | Scoring unavailable. Wait the seconds in the `Retry-After` header and retry with the **same** `X-Idempotency-Key` |

### The two `409`s

Same HTTP status, different `details`:

| `details` (excerpt) | What happened | What to do |
| - | - | - |
| `A request with this X-Idempotency-Key is already in progress` | There's a request **in progress** with that key | Retry later **with the same key** |
| `The response stored for this X-Idempotency-Key was produced by an earlier version of the API and can no longer be replayed` | The transaction **was scored**, but the stored response can no longer be read back | Retry with a **new key**. See [Idempotency](https://docs.fraudeg.com/en/integrar/idempotencia.md) |

A `400`, `403`, or `422` means the request never got scored: nothing was persisted.
A `409` is different: the transaction may already be scored and stored.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.