# Bot & Fraud Detection API Reference

> Platform documentation snapshot. Access, charging and provider requirements remain operation-specific; examples do not execute requests.

### What it does

Risk-scores a signup or transaction using email, domain, IP and behavioral signals to catch disposable emails, fake domains, bot patterns and abusive signup behavior.

### Use cases

- Block trial abuse and stolen-card signups before they consume credits or compute.
- Gate free-trial provisioning on a risk threshold instead of manual review.
- Score marketplace or lead-gen form submissions to keep junk out of the CRM.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `email` | string | Email address to evaluate. Required if `ip` is not provided. |
| `ip` | string | End-user IP address. Required if `email` is not provided. Scored for VPN / proxy / Tor / hosting / relay / bogon via ipinfo.io. |
| `name` | string | Full name supplied at signup/checkout. Used for gibberish detection. Optional. |

### Response Schema

_Complete documented fields for this section, with nested notation preserved. Endpoint-specific envelopes, availability and additional fields are described under each endpoint below._

| Field | Notes |
|-------|-------|
| decision (allow \| review \| block) | |
| risk_score (0-10) | |
| confidence (low \| medium \| high) | |
| reason | |
| signals.business_score | |
| signals.business_signals[] | |
| checks.email_valid | |
| checks.disposable | |
| checks.free_provider | |
| checks.mx_valid | |
| checks.gibberish_name | |
| checks.domain_live | |
| checks.email_status | |
| known_company | |
| known_contact | |
| domain_signup_count | |

**Illustrative Example Response (synthetic, not a complete endpoint schema):**

```json
{
  "data": {
    "decision": "string",
    "risk_score": 0,
    "confidence": "string",
    "reason": "string",
    "signals.business_score": 0,
    "signals.business_signals[]": "string",
    "checks.email_valid": "user@example.com",
    "checks.disposable": "string",
    "checks.free_provider": "string",
    "checks.mx_valid": "string",
    "checks.gibberish_name": "string",
    "checks.domain_live": "string",
    "checks.email_status": "user@example.com",
    "known_company": "string",
    "known_contact": "string",
    "domain_signup_count": 0
  }
}
```

### POST /fraud-check — Evaluate Email / Signup

Score a signup / signal payload for fraud risk. You can send email only, ip only, or email + ip — at least one is required.

- Email checks: disposable / free-provider detection, MX validation, gibberish-name detection, third-party email status, domain liveness + business-signal crawl, and internal signals (known B2B company, known CRM contact, repeat-domain velocity).
- IP checks: VPN, proxy, Tor, residential relay, datacenter / hosting, and bogon detection via ipinfo.io Privacy Detection.

Returns a structured decision (`allow` / `review` / `block`) with a 0-99 `risk_score` and an itemized `signals` + `checks` object.

Auth: Pass your workspace API key in the `x-amz-security-token` header (the legacy `Authorization: Bearer <key>` form is also accepted on this endpoint).
Cost: 1 credit per call.

**Example Request Body:**

```json
{
  "email": "john.doe@trevipay.com",
  "ip": "203.0.113.42",
  "name": "John Doe"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/fraud-check' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "email": "john.doe@trevipay.com",
  "ip": "203.0.113.42",
  "name": "John Doe"
}'
```

