Skip to content

Risk & fraud

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

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"

Methods

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).

Parameters

NameTypeRequiredDescription
subject_idstringOptionalUser / account id under evaluation.
event_typestringOptionalThe event being scored / reported.
ipstringOptionalOriginating IP address.
emailstringOptionalEmail address associated with the subject.
device_fingerprintstringOptionalDevice fingerprint / visitor id.
amountnumberOptionalTransaction amount.
currencystringOptionalISO currency code for the amount.
propertiesRecord<string, unknown>OptionalArbitrary signal properties.
vendorstringOptionalExplicit vendor pin.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

RiskScore { score, decision, reasons: string[] }

Example

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

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

risk.ofac.check

POST /v1/risk/ofac/check

Screen a name / address / id against sanctions lists (OFAC SDN, EU, UN consolidated), returning match details. Billable work-action.

Parameters

NameTypeRequiredDescription
namestring
Required
Full legal name to screen.
addressstringOptionalAddress to screen.
countrystringOptionalCountry code.
dobstringOptionalDate of birth (YYYY-MM-DD).
id_numberstringOptionalGovernment ID number.
listsstring[]OptionalSanctions lists to check against.

Returns

OfacResult { match: boolean, hits: object[] }

Example

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

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

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 / 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 }

Example

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

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

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.

Parameters

NameTypeRequiredDescription
subject_idstringOptionalUser / account id under evaluation.
event_typestring
Required
The event being scored / reported.
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 }

Example

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

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
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": "..."}'

risk.kyc.submit

POST /v1/risk/kyc/submit

Submit an identity-verification (KYC) request — document type, name, DOB, document/selfie images — to a real-name verification vendor (shumei / tongdun).

Parameters

NameTypeRequiredDescription
subject_idstring
Required
User / account id under evaluation.
document_typestringOptionalIdentity document type.
document_countrystringOptionalIssuing country of the document.
full_namestringOptionalFull name on the document.
dobstringOptionalDate of birth (YYYY-MM-DD).
document_imagesstring[]OptionalDocument image references.
selfie_imagestringOptionalSelfie image reference.
metadataRecord<string, unknown>OptionalArbitrary key/value metadata.

Returns

KycCase { case_id, status }

Example

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

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

risk.kyc.status

GET /v1/risk/kyc/status

Fetch the current state (pending / approved / rejected / manual_review) of a previously submitted KYC verification. Sticky_resource: status must be polled on the same vendor that accepted the submission.

Parameters

NameTypeRequiredDescription
subject_idstring
Required
User / account id under evaluation.

Returns

KycCase { case_id, status, decided_at? }

Example

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

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/risk/kyc/status \
  -H "Authorization: Bearer $INFRAI_API_KEY"
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

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.

CapabilityEndpointDescription
risk.device.fingerprintPOST /v1/risk/device/fingerprintResolve 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).
risk.event.reportPOST /v1/risk/event/reportReport a risk-relevant event or label (chargeback, fraud, abuse) back to the vendor as feedback to improve future scoring.
risk.kyc.statusGET /v1/risk/kyc/statusFetch the current state (pending / approved / rejected / manual_review) of a previously submitted KYC verification. Sticky_resource: status must be polled on the same vendor that accepted the submission.
risk.kyc.submitPOST /v1/risk/kyc/submitSubmit an identity-verification (KYC) request — document type, name, DOB, document/selfie images — to a real-name verification vendor (shumei / tongdun).
risk.ofac.checkPOST /v1/risk/ofac/checkScreen a name / address / id against sanctions lists (OFAC SDN, EU, UN consolidated), returning match details. Billable work-action.
risk.scorePOST /v1/risk/scoreScore 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).

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://console.infrai.cc (Google/
GitHub sign-in grants $2 free credit). 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_pk_proj_..."  # <- 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.ofac.check — POST /v1/risk/ofac/check · Screen a name / address / id against sanctions lists (OFAC SDN, EU, UN consolidated), returning match details. Billable work-action.
r2 = show("risk.ofac.check", infrai("POST", "/v1/risk/ofac/check", {"name":"..."}))

# 3) 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 / castle).
r3 = show("risk.device.fingerprint", infrai("POST", "/v1/risk/device/fingerprint", {}))

# 4) risk.kyc.status — GET /v1/risk/kyc/status · Fetch the current state (pending / approved / rejected / manual_review) of a previously submitted KYC verification. Sticky_resource: status must be polled on the same vendor that accepted the submission.
r4 = show("risk.kyc.status", infrai("GET", "/v1/risk/kyc/status"))