Skip to content

Risk & fraud

Fraud scoring, sanctions (OFAC) screening, device/IP fingerprinting and identity verification (KYC) behind one risk API.

1. Overview

Base path: https://api.infrai.cc/v1/risk
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/risk capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/risk/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

2. Methods (3)

2.1risk.score

POST /v1/risk/score

Score a user/account event (login, payment, signup) for fraud and abuse risk, returning a normalized 0..1 score plus an accept / review / reject disposition. Billable work-action, ML high-margin (service_markup).

Parameters

NameTypeRequiredDescription
subject_idstringOptionalUser / account id under evaluation.
event_typestringOptionalThe event being scored / reported.
default: "login"e.g. login
ipstringOptionalOriginating IP address.
format: ipv4
emailstringOptionalEmail address associated with the subject.
format: email
device_fingerprintstringOptionalDevice fingerprint / visitor id.
amountnumberOptionalTransaction amount.
≥ 0
currencystringOptionalISO currency code for the amount.
3–3 chars
propertiesRecord<string, unknown>OptionalArbitrary signal properties.
vendorstringOptionalExplicit vendor pin.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

RiskScore { score, decision, reasons: string[] }
NameTypeDescription
vendorstringVendor that handled or will handle this request
scorenumbernormalized risk score, higher = riskier
0–1
disposition"accept" | "review" | "reject"Risk assessment disposition (allow, challenge, deny)
score_idstringUnique identifier for this risk score
reasonsstring[]List of reasons contributing to the risk score

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/risk/score \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

2.2risk.device.fingerprint

POST /v1/risk/device/fingerprint

Resolve a stable device fingerprint / visitor id from a client-collected token plus IP and user-agent signals, for bot and incognito detection. Served by a vendor (sift / castle).

Parameters

NameTypeRequiredDescription
request_tokenstringOptionalClient-collected token / visitor id.
ipstringOptionalOriginating IP address.
user_agentstringOptionalClient user-agent string.
propertiesRecord<string, unknown>OptionalArbitrary signal properties.

Returns

Device { device_id, signals: object }
NameTypeDescription
okbooleanWhether the fingerprint was processed
fingerprint_hashstring | nullHash of the device fingerprint
risk_scorenumber | nullRisk score for this device (0-1)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/risk/device/fingerprint \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

2.3risk.event.report

POST /v1/risk/event/report

Report a risk-relevant event or label (chargeback, fraud, abuse) back to the vendor as feedback to improve future scoring.

Parameters

NameTypeRequiredDescription
subject_idstringOptionalUser / account id under evaluation.
event_typestring
Required
The event being scored / reported.
e.g. chargeback
label"fraud" | "legit" | "chargeback"OptionalOutcome label — fraud, legit or chargeback.
reasonstringOptionalFree-text reason for the report.
propertiesRecord<string, unknown>OptionalArbitrary signal properties.

Returns

{ ok: boolean }
NameTypeDescription
okbooleanWhether the event was recorded
event_idstring | nullUnique identifier for the recorded event

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/risk/event/report \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event_type": "sample"}'
Advanced: pin a vendor

By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.

GET /v1/discovery/{capability}

risk.score

3. All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

risk.device.fingerprintPOST /v1/risk/device/fingerprint

Resolve a stable device fingerprint / visitor id from a client-collected token plus IP and user-agent signals, for bot and incognito detection. Served by a vendor (sift).

Parameters (4)
NameTypeRequiredDescription
request_tokenstringOptionalclient-collected token / visitor id
ipstringOptionalIP address from which the session was created
user_agentstringOptionalUser-Agent string of the client
propertiesobjectOptionalAdditional properties for risk assessment
risk.event.reportPOST /v1/risk/event/report

Report a risk-relevant event or label (chargeback, fraud, abuse) back to the vendor as feedback to improve future scoring.

Parameters (5)
NameTypeRequiredDescription
subject_idstringOptionalIdentifier of the subject being risk-scored
event_typestringRequiredType of risk event (e.g. login, payment, registration)
e.g. chargeback
label"fraud" | "not_fraud"OptionalRisk label (e.g. low, medium, high)
reasonstringOptionalReason for the current state or action
propertiesobjectOptionalAdditional properties for risk assessment
risk.scorePOST /v1/risk/score

Score a user/account event (login, payment, signup) for fraud and abuse risk, returning a normalized 0..1 score plus an accept / review / reject disposition. Billable work-action, ML high-margin (service_markup).

Parameters (10)
NameTypeRequiredDescription
subject_idstringOptionaluser/account id under evaluation
event_typestringOptionalType of risk event (e.g. login, payment, registration)
default: "login"e.g. login
ipstringOptionalIP address from which the session was created
format: ipv4
emailstringOptionalEmail address
format: email
device_fingerprintstringOptionalDevice fingerprint hash for identity tracking
amountnumberOptionalMonetary amount in the specified currency
≥ 0
currencystringOptionalISO 4217 currency code (e.g. USD, CNY)
3–3 chars
propertiesobjectOptionalAdditional properties for risk assessment
vendor"maxmind" | "sift" | "shumei" | "tongdun"OptionalVendor that handled or will handle this request
idempotency_keystringOptionalClient-provided idempotency key; prevents duplicate execution on retry

4. End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · risk — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) risk.score — POST /v1/risk/score · Score a user/account event (login, payment, signup) for fraud and abuse risk, returning a normalized 0..1 score plus an accept / review / reject disposition. Billable work-action, ML high-margin (service_markup).
r1 = show("risk.score", infrai("POST", "/v1/risk/score", {}))

# 2) risk.device.fingerprint — POST /v1/risk/device/fingerprint · Resolve a stable device fingerprint / visitor id from a client-collected token plus IP and user-agent signals, for bot and incognito detection. Served by a vendor (sift).
r2 = show("risk.device.fingerprint", infrai("POST", "/v1/risk/device/fingerprint", {}))

# 3) risk.event.report — POST /v1/risk/event/report · Report a risk-relevant event or label (chargeback, fraud, abuse) back to the vendor as feedback to improve future scoring.
r3 = show("risk.event.report", infrai("POST", "/v1/risk/event/report", {"event_type":"sample"}))