# Signup fraud check

> POST /signup/check scores a sign-up from its email, phone, IP, name and User-Agent in one call and returns allow, review or block with every reason.

`POST https://api.qelka.com/v1/signup/check`

Score a new account in one call. Send what your sign-up form collects, and the email check, the age of the email domain, the phone check, the consumer reports to the FTC and the IP check run in parallel. The answer is a decision (`allow`, `review` or `block`), a risk score from 0 to 100, every reason with its points and the input it comes from, and the full result of each check. Each call costs 3 credits, whatever fields you send, and nothing when one of the checks did not answer.

## Request

Send at least one of `email`, `phone`, `ip`, `name` and `user_agent`. A request with none of them is a `400 invalid_request`.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | No | none | The email address the user typed. Checked in `fast` mode: syntax, domain, mail servers, disposable and role addresses, without contacting the mail server. |
| `phone` | string | No | none | The phone number, in international format, or national format with `country`. |
| `ip` | string | No | none | The public IPv4 or IPv6 address the sign-up came from. A private address is a `422`. |
| `name` | string | No | none | The name the user typed, up to 200 characters. |
| `user_agent` | string | No | none | The `User-Agent` header of the sign-up request, up to 1,024 characters. |
| `country` | string | No | none | ISO 3166-1 alpha-2 code of the country the user declared. Compared with the IP country, and used to read a national phone number. |
| `fresh` | boolean | No | `false` | Accepted for symmetry with the other endpoints. Sign-up checks are never cached, so it changes nothing. |

The checks that run depend on what you send:

| Check | Runs when | Skipped (`not_applicable`) when |
|---|---|---|
| Email | `email` is sent | Never |
| Email domain age | `email` is sent and its domain is valid | The domain is a free mailbox provider or a disposable service: its age says nothing about the person |
| Phone | `phone` is sent | Never |
| FTC reports | `phone` is sent | The number is outside the North American Numbering Plan |
| IP | `ip` is sent | Never |
| Name and User-Agent | `name` or `user_agent` is sent | Never: these are read locally, without a lookup |

```bash title="cURL"
curl https://api.qelka.com/v1/signup/check \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "someone@mailinator.com", "ip": "8.8.8.8", "name": "Jane Doe", "user_agent": "python-requests/2.32.3"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/signup/check', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    email: 'someone@mailinator.com',
    ip: '8.8.8.8',
    name: 'Jane Doe',
    user_agent: 'python-requests/2.32.3',
  }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result.decision, result.score, result.reasons)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/signup/check",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "email": "someone@mailinator.com",
        "ip": "8.8.8.8",
        "name": "Jane Doe",
        "user_agent": "python-requests/2.32.3",
    },
    timeout=30,
)
result = response.json()
print(result["decision"], result["score"], result["reasons"])
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/signup/check');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'email' => 'someone@mailinator.com',
        'ip' => '8.8.8.8',
        'name' => 'Jane Doe',
        'user_agent' => 'python-requests/2.32.3',
    ]),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
echo $result['decision'], ' ', $result['score'], PHP_EOL;
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{
		"email":      "someone@mailinator.com",
		"ip":         "8.8.8.8",
		"name":       "Jane Doe",
		"user_agent": "python-requests/2.32.3",
	})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/signup/check", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result["decision"], result["score"])
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/signup/check')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({
  email: 'someone@mailinator.com',
  ip: '8.8.8.8',
  name: 'Jane Doe',
  user_agent: 'python-requests/2.32.3'
})

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts "#{result['decision']} #{result['score']}"
```

## Response

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this check: `lkp_` followed by 26 characters. |
| `object` | string | Always `signup_check`. |
| `input` | string | The first field you sent among `email`, `phone`, `ip`, `name` and `user_agent`. |
| `decision` | string | `block` from 70 points, `review` from 30, `allow` below. |
| `score` | integer | Risk score from 0 to 100: the sum of the points of every reason, capped at 100. Higher is riskier. |
| `reasons` | array of objects | Every signal found, strongest first. |
| `reasons.code` | string | One of the codes listed below. |
| `reasons.field` | string | The input the signal comes from: `email`, `phone`, `ip`, `name`, `user_agent` or `country`. |
| `reasons.severity` | string | `critical` (90 points or more), `high` (40 to 89), `medium` (20 to 39), `low` (1 to 19) or `info` (0). |
| `reasons.points` | integer | Points this signal adds to `score`. |
| `reasons.message` | string | A plain-English explanation, for your logs or your support team. |
| `checks` | object | The status of each check: `email`, `email_domain_age`, `phone`, `phone_reports`, `ip`, `name` and `user_agent`. Each is `ok`, `not_provided` (you did not send the field), `not_applicable` (the check does not apply, see the table above) or `unavailable` (the source did not answer). |
| `email` | object or null | The [email check](https://qelka.com/docs/api-reference/email) result, without `id`, `credits_used` and `cached`. |
| `email_domain_age` | object or null | The registration of the email domain: `domain`, `status` (`found`, `not_found`, `unsupported` or `error`), `created_at`, `age_days` and `registrar`. |
| `phone` | object or null | The [phone check](https://qelka.com/docs/api-reference/phone) result at the `basic` level. |
| `phone_reports` | object or null | The [FTC reports](https://qelka.com/docs/api-reference/phone-reports) result, for North American numbers. |
| `ip` | object or null | The [IP check](https://qelka.com/docs/api-reference/ip) result. |
| `credits_used` | integer | 3 with a live key, `0` with a test key or when a check is `unavailable`. |
| `cached` | boolean | Always `false`: sign-up checks are never cached. |

```json title="Response"
{
  "id": "lkp_01M8CES6NP4YV4GR95TZ43C08S",
  "object": "signup_check",
  "input": "someone@mailinator.com",
  "decision": "block",
  "score": 100,
  "reasons": [
    { "code": "email_disposable", "field": "email", "severity": "high", "points": 70, "message": "mailinator.com is a disposable email service." },
    { "code": "user_agent_automation", "field": "user_agent", "severity": "high", "points": 40, "message": "The User-Agent names an automation tool or HTTP library (python-requests)." },
    { "code": "ip_datacenter", "field": "ip", "severity": "medium", "points": 30, "message": "8.8.8.8 belongs to a hosting provider (Google LLC), not a home or mobile network." }
  ],
  "checks": { "email": "ok", "email_domain_age": "not_applicable", "phone": "not_provided", "phone_reports": "not_provided", "ip": "ok", "name": "ok", "user_agent": "ok" },
  "email": {
    "object": "email",
    "input": "someone@mailinator.com",
    "status": "risky",
    "reason": "disposable",
    "did_you_mean": null,
    "checks": { "syntax": true, "mx": true, "smtp": null, "catch_all": null, "disposable": true, "role": false, "free_provider": false },
    "domain": { "name": "mailinator.com", "spf": true, "dmarc": true },
    "score": 50
  },
  "email_domain_age": null,
  "phone": null,
  "phone_reports": null,
  "ip": {
    "object": "ip",
    "input": "8.8.8.8",
    "version": 4,
    "country": { "code": "US", "name": "United States" },
    "region": "California",
    "city": "Mountain View",
    "asn": { "number": 15169, "org": "Google LLC", "type": "hosting" },
    "flags": { "tor": false, "vpn": false, "proxy": false, "datacenter": true },
    "risk": { "score": 35, "level": "medium" }
  },
  "credits_used": 3,
  "cached": false
}
```

## Reasons

The [signup risk score](https://qelka.com/docs/signup-risk-score) page lists the exact weight of every code, generated from the code that computes it.

| Code | Field | When it is raised |
|---|---|---|
| `email_disposable` | `email` | The domain is a disposable inbox service |
| `email_invalid` | `email` | The address is not well formed |
| `email_domain_unroutable` | `email` | The domain does not exist, or publishes no mail server or a null MX |
| `email_lookalike_domain` | `email` | The domain imitates a brand domain, such as `paypa1.com` |
| `email_new_domain` | `email` | The domain was registered less than 30 days ago |
| `email_young_domain` | `email` | The domain was registered less than 180 days ago |
| `email_typo` | `email` | The domain looks like a typo of a common provider |
| `email_role` | `email` | A role mailbox such as `info` or `admin` |
| `email_risky_tld` | `email` | The domain is on one of the 20 TLDs with the highest phishing domain score |
| `email_many_digits` | `email` | The part before the at sign holds many digits |
| `email_free_provider` | `email` | A free mailbox provider. Common for real people: 0 points, information only |
| `phone_invalid` | `phone` | The number is not valid |
| `phone_premium_rate` | `phone` | A premium-rate number |
| `phone_heavily_reported` | `phone` | 10 or more consumer reports to the FTC |
| `phone_voip` | `phone` | A VoIP number |
| `phone_reported` | `phone` | Fewer reports to the FTC |
| `ip_tor` | `ip` | A Tor exit node |
| `ip_proxy` | `ip` | A known open proxy |
| `ip_vpn` | `ip` | A VPN service network |
| `ip_datacenter` | `ip` | A hosting provider network, when no stronger IP flag is raised |
| `country_mismatch` | `country` | The declared country, or the phone country, differs from the IP country |
| `name_has_link` | `name` | The name contains a link or a web address |
| `name_has_digits` | `name` | The name contains digits |
| `name_repetitive` | `name` | The name repeats a character or follows a keyboard row |
| `name_too_short` | `name` | The name has fewer than two letters |
| `user_agent_automation` | `user_agent` | The User-Agent names an automation tool or HTTP library, such as `curl`, `python-requests` or a headless browser |
| `user_agent_short` | `user_agent` | The User-Agent is shorter than any browser's |

FTC reports are unverified consumer complaints, and caller ID can be spoofed: the messages say so. Treat them as a signal, not a proof.

## Use the decision

- `allow`: create the account.
- `review`: ask for a second factor, such as a confirmation email or an SMS code, or queue the account for a manual look.
- `block`: refuse, with a message that does not accuse the person, and log the reasons for your support team.

The thresholds suit most free trials. If your product tolerates more or less risk, compare `score` with your own thresholds: the reasons explain every point. The guide [Block fake signups in one call](https://qelka.com/docs/guides/block-fake-signups) shows a complete sign-up route.

## Errors

| Status | Type | When |
|---|---|---|
| `400` | `invalid_request` | The body is not JSON, none of the five fields is sent, a field is too long or an unknown field is sent. |
| `422` | `unprocessable_input` | `ip` is not a valid public IP address. An invalid email or phone number is not an error: it is a reason in the result. |

When a source does not answer, the call still returns `200`: the check has the status `unavailable`, its signals are missing from the score, and the call is free. Errors are never billed. See [Errors](https://qelka.com/docs/errors).

## Test mode

With a test key, each field gets the test answer of its own endpoint (email, phone, phone reports, IP), the email domain age follows the [`/url` test rules](https://qelka.com/docs/test-mode), and the name and User-Agent are checked for real. The decision and the score are computed as in live mode. See [Test mode](https://qelka.com/docs/test-mode).

## Related

- [Signup risk score](https://qelka.com/docs/signup-risk-score): the weight of every reason.
- [Link safety](https://qelka.com/docs/api-reference/url): check the links your users post.
- Free tools: [fraud checker](https://qelka.com/tools/fraud-checker) and [signup risk checker](https://qelka.com/tools/signup-risk-checker).
