Developers
Fraud prevention in one API call.
Send a payment, sign-up, login, account update or payout to POST /v1/score and get the decision back in the same request, with the reasons behind it. Examples are illustrative; the OpenAPI contract is authoritative.
Request
Score a payment
POST /v1/score HTTP/1.1
Host: api.frape.io
Authorization: Bearer frp_test_<prefix>_<secret>
Content-Type: application/json
Idempotency-Key: checkout-81723-attempt-1
{
"event_type": "payment",
"external_id": "order_81723",
"occurred_at": "2026-10-01T12:04:31Z",
"amount": { "value_minor": 12999, "currency": "EUR" },
"customer": {
"account_id": "acct_4821",
"email": "[email protected]",
"phone": "+15555555555",
"first_name": "John",
"last_name": "Doe",
"country": "DE"
},
"card": { "fingerprint": "fp_9c1e4b7a2d", "bin": "424242", "last4": "4242" },
"billing_address": { "country": "DE", "postal_code": "10115" },
"merchant": { "id": "store-berlin", "channel": "web" },
"metadata": { "cart_id": "cart-81723", "item_count": 3, "loyalty_member": true },
"device": {
"ip": "203.0.113.42",
"session_id": "checkout-81723",
"browser_payload": "<string from the browser agent>"
}
}HTTP/1.1 200 OK
Content-Type: application/json
{
"event_id": "0199a1f2-7c3b-7d41-9a2e-5f0c8b1d3e47",
"external_id": "order_81723",
"decision": "CHALLENGE",
"score": 58,
"risk_level": "medium",
"reasons": [
"signal:example_rule",
"signal:another_example_rule",
"score_threshold:CHALLENGE"
],
"matched_rules": [
{ "id": "example_rule", "name": "Example rule from your policy",
"stage": "signal", "score_delta": 5 }
],
"model_called": true,
"model_skip_reason": null,
"policy_version": { "id": "0199a1d0-1b2c-7a3d-8e4f-5a6b7c8d9e0f", "version": 3,
"document_version": "acme.3", "scope": "organization" },
"identity_id": "0199a1e4-3f2a-7c68-b1d9-4e5f6a7b8c9d",
"latency_ms": 212,
"bot_likelihood": 0.05,
"challenge": {
"id": "0199a1f2-7c40-7a12-8b3c-9d0e1f2a3b4c",
"methods": ["three_ds", "otp_sms"],
"expires_at": "2026-10-01T12:19:31Z"
}
}event_type,external_idandoccurred_atare required; a payment also needsamountin integer minor units with an ISO-4217 currency. Unknown fields are rejected.- The other event types have their own required fields.
signup:customerwith anemailor aphone.login:customer.account_idandlogin.result(successorfailure).account_update:customer.account_idandaccount_update.changed_fields(one or more ofemail,phone,password,address,payout_method,name,two_factor).payout:amount,customer.account_idandpayout.method(bank_transfer,card,wallet,cryptoorother). - Send
device.ipwhenever you can: it enables the network and location checks. - Cards are sent as fingerprint, BIN and last four only, with the name on the card and the expiry month and year if you have them. Card numbers and CVVs are rejected under any key name. Never send card numbers, security codes, passwords, API keys or other secrets in any field.
- Running several brands or stores on one account? Send each one's id in
merchant.id(a string of up to 128 characters). Events and the dashboard can be filtered by brand, and policy rules can use it. - Send the customer's name in
customer.first_nameandcustomer.last_name(orfull_name). It is used for the name consistency checks. - The customer's email, phone and name are stored encrypted, with keys held in a secret manager, and hashed for matching. Only authorised users of your organisation can see them in the console, and every access is logged. They are never sent to the AI. They are sent to an outside data provider only if your organisation uses email ping (below) or another pre-check, which are on by default on paid plans.
- Email ping (the mailbox pre-check; on by default on paid plans, not on Free): an admin can turn it off under Settings › Email ping, or set a monthly cap. FRAPE then checks each new email address with its email verification provider in the background, never while scoring, so the request is not slowed. Until a check completes, its result is unavailable, and it never changes a decision unless your rule uses it. The request and response of
POST /v1/scoredo not change. - Retrying with the same
Idempotency-Keyand body within 24 hours replays the original response, with the headerIdempotent-Replayed: true. - After a step-up challenge, send the challenge's id as
challenge_idon the event that follows it. It is accepted only for a challenge of your organization, in the same live or test mode and for the same customer. Your rules can then take the completed challenge into account, and a completed challenge can be used once. It never changes the decision by itself.
Field mapping
Mapping your existing checkout fields
Already building a checkout payload on your backend? Every useful field has a place in the FRAPE request. The field names on the left are examples; yours will differ. Build the request on your server: the card number and the security code stay with you and are never sent.
| Your field | FRAPE field | What FRAPE keeps |
|---|---|---|
| first_name, last_name | customer.first_name, customer.last_name | Keyed hash for matching, stored encrypted |
| email, phone | customer.email, customer.phone | Keyed hash for matching, stored encrypted |
| billing_address (street, city, state, postal code, country) | billing_address (or shipping_address): line1, city, region, postal_code, country | Address hash and country |
| total, currency | amount.value_minor + amount.currency | Integer minor units (cents for USD) |
| order_id | external_id | As sent |
| store_id | merchant.id (one per store or brand), or your own key in metadata | As sent |
| language | customer.language (site language) and device.accept_language (browser) | Language code |
| card_brand | card.brand (and card.funding) | As sent |
| card_number | Never send it. Send card.bin (first 6 digits), card.last4 and card.fingerprint | BIN, last four and a fingerprint FRAPE re-keys |
| security_code (CVV) | Never send it, in any field | Rejected wherever it appears |
| cardholder_name | card.holder_name | Keyed hash, stored encrypted |
| expiry_month, expiry_year | card.exp_month, card.exp_year | Only months to expiry and an expired flag are kept |
| financing_selected | payment.method = bnpl, with payment.provider set to the provider's short name | As sent |
| landing_query, referrer | traffic.url_params, traffic.referrer (and traffic.landing_url) | Only the referrer domain, utm_source / utm_medium / utm_campaign and ad-click flags |
| analytics_client_id | device.analytics_client_id | Keyed hash only, used to link visits |
| previous decision, previous score | external_decisions[]: subject, decision, score, external_reference | Kept for side-by-side comparison, never used to decide |
// Server side only. "order" is the checkout object your backend already builds.
// The card number and the security code are read here and never sent anywhere.
import { createHmac } from "node:crypto";
export function frapeRequest(order, ctx) {
const pan = String(order.card_number).replace(/\D/g, "");
const address = order.billing_address;
return {
event_type: "payment",
external_id: order.order_id,
occurred_at: new Date().toISOString(),
// total is in major units here; 100 is right for two-decimal currencies such as USD
amount: { value_minor: Math.round(Number(order.total) * 100), currency: order.currency },
customer: {
first_name: order.first_name, last_name: order.last_name,
email: order.email, phone: order.phone, language: order.language,
},
card: {
bin: pan.slice(0, 6),
last4: pan.slice(-4),
// your payment provider's card token, or a keyed hash with a secret only you hold
fingerprint: order.card_token ?? createHmac("sha256", process.env.CARD_FP_SECRET).update(pan).digest("hex"),
brand: order.card_brand,
holder_name: order.cardholder_name,
exp_month: Number(order.expiry_month),
exp_year: Number(order.expiry_year),
},
payment: { method: order.financing_selected ? "bnpl" : "card" },
billing_address: {
line1: address.street, city: address.city, region: address.state,
postal_code: address.postal_code, country: address.country,
},
merchant: { id: order.store_id },
device: {
ip: ctx.clientIp, user_agent: ctx.userAgent, accept_language: ctx.acceptLanguage,
analytics_client_id: order.analytics_client_id,
},
traffic: { referrer: order.referrer, url_params: order.landing_query },
// optional, needs a key with comparisons:write and a comparison subject set up in the console
external_decisions: order.previous_decision ? [{
subject: "previous_system",
decision: order.previous_decision,
score: order.previous_score,
}] : undefined,
};
}card.fingerprint must stay the same for the same card: use your payment provider's card token, or an HMAC-SHA256 of the card number with a secret only you hold. Never a plain hash. FRAPE re-keys it again on arrival.
A key that names a card number or a security code (card_number, cvv, security_code and their spellings) is rejected with forbidden_field anywhere in the request, including metadata.
The expiry month and year are only used to work out how many months the card has left; they are not stored. The name on the card is handled like the customer's name.
Link query strings can carry emails, names or tokens. FRAPE keeps only the referrer's domain, the three campaign values and whether an ad-click id was present, and drops everything else.
Custom fields
Send your own fields in metadata
"metadata": {
"store": "store-001",
"channel": "web",
"item_count": 9,
"delivery": "express",
"loyalty_member": false,
"account_age_days": 1
}{
"id": "large_basket_new_account",
"name": "Large basket from a new account",
"stage": "signal",
"enabled": true,
"condition": { "all": [
{ "field": "metadata.item_count", "op": "gte", "value": 7 },
{ "field": "metadata.account_age_days", "op": "lte", "value": 1 }
] },
"action": { "set_fact": { "name": "large_basket_new_account", "value": true }, "score_delta": 10 }
}- Put any field we do not have a place for (order, delivery or channel details) in
metadata: up to 50 keys of 1–64 letters, digits,_,.or-. Each value is text (up to 256 characters, empty allowed), a number ortrue/false. No nested objects, lists ornull. - Policy rules read them as
metadata.<key>. The value in the rule sets the comparison: a number compares as a number (numeric text works too),true/falseas yes/no, anything else as text. An event without the key never matches. The other fields you can use in your own rules are listed in the console's rule builder; choose a field there to see a short description of it. - We store them with the event and show them in the event view under Custom fields. They are never sent to outside data providers. The AI sees a custom field only if you list it in the console under Settings (paid plans, enabled by FRAPE on request), one field at a time, as true/false, a number or one of a short list of values you choose. The key of a shared field must start with a lower-case letter and use only lower-case letters, digits and underscores, up to 32 characters. Free text is never shared with the AI, and neither is a whole number of 7 or more digits. Do not put personal data or secrets in them; card numbers are rejected.
Response
Every answer explains itself
- event_id
- UUIDv7 of the stored event; use it with GET /v1/events/{event_id} and POST /v1/feedback.
- external_id
- Your own id for the order or event, echoed back. Send the same id when a customer retries the same order, so retries count as one order.
- decision
- APPROVE, CHALLENGE, REVIEW or DECLINE, always made by your deterministic policy.
- score
- 0–100 risk score.
- risk_level
- Banded risk level for display.
- reasons[]
- Stable reason codes, e.g. signal:<rule> and score_threshold:<decision>, to show analysts or map to customer messages.
- matched_rules[]
- The rules that fired: id, name, stage and their score delta or decision, for audit and tuning.
- shadow_matched_rules[]
- Optional. Watch-only rules (a policy rule with "mode": "shadow") that fired, in the same shape as matched_rules, with the points or decision each would add once switched on. They never change the decision, score or reasons. Omitted when none fired.
- shadow_score
- Optional, sent with shadow_matched_rules: the score plus the points of the watch-only rules, kept within 0–100: an estimate of the score with them switched on. For information only; never used for the decision.
- model_called
- Whether FRAPE Decision Core, the AI, was consulted for this event. Its answer is advice only: your policy makes the decision, and an AI failure or timeout never approves an event.
- model_skip_reason
- Why the AI was not consulted while scoring (for example terminal_rule or confident_without_model; shadow_mode when your Decision Core runs in shadow and the AI is asked after the decision, advisory only), otherwise null.
- policy_version
- The policy version that made the decision: id, version, document_version and scope.
- identity_id
- The id of the customer identity FRAPE linked this event to, or null.
- latency_ms
- Server-side processing time.
- bot_likelihood
- Optional. An estimate, from 0 to 1, of how likely it is that a bot, not a person, made this request. It is never exactly 0 or 1. It can be wrong. Left out when no check had data for the event, which does not mean 0. A bot is not fraud by itself; use it with your own checks.
- challenge
- Present when the decision is CHALLENGE and your policy sets challenge methods: id, methods (the recommended methods in order of preference, from otp_sms, otp_email, email_link, sms_link, three_ds, passkey and idv) and expires_at. Perform one of the methods yourself and report the result with POST /v1/challenges/{challenge_id}/result.
- mode
- Optional. shadow when your organization runs this event type in shadow mode: FRAPE's decision is then for observation only. The decision is worked out the same way in both modes.
- external_decisions_result
- Optional, when you sent external_decisions: stored (how many were stored) and rejected[] (the index and a code for each item that was not). A rejected item never fails the request.
- replay
- Only on event-time replay requests, which need a test key: run_id and event_time, the time the event was evaluated at.
Webhooks
Get updates pushed to your systems
Add an HTTPS endpoint in the admin console under Operations › Webhooks and choose the event types it receives. Every delivery is signed: check X-Frape-Signature (HMAC-SHA256 of the timestamp and the body) before you trust it. Use id to ignore repeats, and apply updates of the same aggregate in aggregate.version order.
- event.scored
- An event was scored: the decision, score, reasons and matched rules.
- alert.created
- An alert rule fired for an event or identity.
- case.updated
- A case was created, assigned, commented on or moved to a new status.
- challenge.completed
- A step-up challenge received the result you reported.
- event.reviewed
- An analyst closed out an event with a final Approve or Decline, or reopened that review.
POST <your webhook URL>
Content-Type: application/json
X-Frape-Signature: t=1759321800,v1=<hex HMAC-SHA256>
{
"id": "0199a1f3-0c2e-7b55-9d10-3e4f5a6b7c8d",
"type": "event.reviewed",
"version": 1,
"occurred_at": "2026-10-01T12:30:00Z",
"organization_id": "0199a1c0-2a3b-7c4d-8e5f-6a7b8c9d0e1f",
"aggregate": { "type": "event", "id": "0199a1f2-7c3b-7d41-9a2e-5f0c8b1d3e47", "version": 1 },
"data": {
"event_id": "0199a1f2-7c3b-7d41-9a2e-5f0c8b1d3e47",
"external_id": "order_81723",
"event_type": "payment",
"merchant_id": "store-berlin",
"original_decision": "REVIEW",
"status": "completed",
"outcome": "DECLINE",
"reviewed_at": "2026-10-01T12:30:00Z",
"actor": { "type": "user", "id": "0199a1c1-5d6e-7f80-9a1b-2c3d4e5f6a7b" }
}
}event.reviewedtells you the final answer for an event FRAPE sent to REVIEW or CHALLENGE: release the order onAPPROVE, cancel it onDECLINE.original_decisionis FRAPE's decision and never changes.statusiscompletedwith anoutcome, orreopenedwithoutcome: nullwhen an analyst takes the decision back.- The analyst's written reason stays in FRAPE and is never sent. Match the event to your order with
external_id.
Device signals
Add the browser agent
<!-- 1. On your checkout, login or sign-up page (always the current version) -->
<script src="https://frape.io/agent/frape-agent.js"></script>
<!-- or a fixed version with integrity (pages that must authorise every script change):
<script src="https://frape.io/agent/frape-agent-<version>.js"
integrity="sha384-<hash>" crossorigin="anonymous"></script> -->
<script>
const frape = FrapeAgent.init({
sessionId: "checkout-81723",
// optional: false keeps no device id and touches no browser storage
// persistDeviceId: false,
// optional: days before a new device id is issued (1 to 395, default 395)
// deviceIdMaxAgeDays: 90,
// optional: your own STUN server, or [] to turn the network check off
// stunUrls: ["stun:stun.example.com:3478"],
// optional: false turns off the interaction counts and rhythm summary
// trackBehavior: false,
// optional: false turns off only the blocker check (agent 0.5; fingerprinting protection from 0.6.1)
// privacyProbe: false,
// optional: your own collection hostname, or false to turn the connection check off
// collectUrl: "https://collect.example.com/v1/edge",
});
form.addEventListener("submit", async (event) => {
event.preventDefault();
const browserPayload = await frape.collect();
// 2. send browserPayload to your backend with the form,
// then add it as device.browser_payload (same session_id)
});
</script>The agent collects signals on your page and returns one string: device and browser characteristics, an interaction summary and a connection check. Forward the string unchanged. Your backend sends it as device.browser_payload; your API key never reaches the browser.
The default address always serves the current agent version, so your page gets each new version without a change on your side; each version and what changed are listed on the agent integrity page. If your payment pages must authorise every script change, load a fixed version instead: copy that tag, with its version and integrity hash, from the admin console under Operations › API keys. A published version never changes, so the hash keeps the browser from running anything else. Serve the page over HTTPS: from agent 0.5.0 some rendering signals need a secure page and are left out on plain HTTP.
For your payment page script inventory, the agent integrity page has a signed list of every version and its hash, ready-made security headers and a verification tool.
sessionId is your own non-secret reference for the visit or checkout (never a session cookie or token); send the same value as device.session_id. What the agent collects, and suggested wording for your privacy notice: device signals.
stunUrls sets the STUN servers of the WebRTC network check, which finds the visitor's public IP address. It starts at init() and stops after 1.5 seconds. By default it uses a public STUN server, named on the device signals page, which sees the visitor's IP address. Pass your own stun: URLs (at most two), or [] to turn the check off. FRAPE keeps only the result, never the addresses.
By default the agent keeps a first-party device id in the browser's localStorage, so a returning browser can be recognised. persistDeviceId: false turns that off: the agent then makes no storage access of any kind. deviceIdMaxAgeDays sets how many days an id is kept before a new one is issued: a whole number from 1 to 395, and 395 when you leave it out.
From agent 0.5.0 the payload also carries an interaction summary, computed in the browser as counts in fixed ranges. No key, typed value or pointer position leaves the page. From agent 0.6.0 the summary also counts the use of autofill, password managers and phone keyboards, without reading any value or text and without sending which field. trackBehavior: false turns the counts and the summary off. Older agent versions keep working.
From agent 0.5.0 the agent also checks whether an ad or tracker blocker is active, and from agent 0.6.1 whether the browser uses fingerprinting protection. Only one yes or no is sent for both. No extension is listed and no image or pixel data is sent. It runs while trackBehavior is on; privacyProbe: false turns only this check off.
From agent 0.5.0 (payload v5) the agent also runs a connection check: at init() it sends one request without cookies to https://collect.frape.io/v1/edge, in parallel with the network check and stopped after the same 1.5 seconds. FRAPE sees the visitor's own connection on that request and answers with a token, which the payload carries in a new edge section. The token is opaque: forward the payload unchanged as today. POST /v1/score has no contract change. If your pages send a Content Security Policy, add connect-src https://collect.frape.io; if the request is blocked or fails, every other signal stays the same. collectUrl takes your own https:// collection hostname, or false to turn the check off.
FRAPE reads the token when it scores the event and keeps only results, never the IP address. With agent 0.4 or older the connection check does not run.
Bot check
Forward your Turnstile result
Running Cloudflare Turnstile on your checkout or login page? Check the widget's token on your backend with Siteverify and your own secret key, then send the result with the event as device.turnstile. FRAPE never calls Siteverify, and never receives the token or your secret key: a request that contains them, or any other extra key, is rejected with 400 validation_failed.
Send success (required) and, when Siteverify returns them, challenge_ts, hostname, action, cdata and error_codes (Siteverify calls it error-codes). Leave out Siteverify's metadata and messages. We keep only what we work out from it, never the hostname, the challenge time or cdata.
Your policy decides what the result does. In the admin console under Operations › Settings, tick “Our pages run Turnstile” to flag events that arrive without a result, and list the sites your widgets run on to check hostname.
"device": {
"ip": "203.0.113.42",
"session_id": "checkout-81723",
"browser_payload": "<string from the browser agent>",
"turnstile": {
"success": true,
"challenge_ts": "2026-10-01T12:03:58Z",
"hostname": "shop.example.com",
"action": "checkout",
"error_codes": []
}
}// Node 20+: check the token with YOUR secret, then forward the result.
const r = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
method: "POST",
body: new URLSearchParams({
secret: process.env.TURNSTILE_SECRET_KEY,
response: req.body["cf-turnstile-response"],
remoteip: clientIp,
}),
});
const v = await r.json();
const turnstile = {
success: v.success === true,
...(v.challenge_ts && { challenge_ts: v.challenge_ts }),
...(v.hostname && { hostname: v.hostname }),
...(v.action && { action: v.action }),
error_codes: v["error-codes"] ?? [],
};
// add it to the score request: device.turnstile = turnstile# Python 3 with requests
v = requests.post(
"https://challenges.cloudflare.com/turnstile/v0/siteverify",
data={"secret": os.environ["TURNSTILE_SECRET_KEY"],
"response": form["cf-turnstile-response"], "remoteip": client_ip},
timeout=5,
).json()
turnstile = {"success": v.get("success") is True,
"error_codes": v.get("error-codes", [])}
for k in ("challenge_ts", "hostname", "action"):
if v.get(k):
turnstile[k] = v[k]
event["device"]["turnstile"] = turnstile// Go: net/http, encoding/json, net/url
resp, err := http.PostForm("https://challenges.cloudflare.com/turnstile/v0/siteverify", url.Values{
"secret": {os.Getenv("TURNSTILE_SECRET_KEY")}, "response": {token}, "remoteip": {clientIP},
})
if err != nil { return /* score without device.turnstile */ }
defer resp.Body.Close()
var v struct {
Success bool `json:"success"`
ChallengeTS string `json:"challenge_ts"`
Hostname string `json:"hostname"`
Action string `json:"action"`
ErrorCodes []string `json:"error-codes"`
}
_ = json.NewDecoder(resp.Body).Decode(&v)
ts := map[string]any{"success": v.Success, "error_codes": v.ErrorCodes}
if v.ChallengeTS != "" { ts["challenge_ts"] = v.ChallengeTS }
if v.Hostname != "" { ts["hostname"] = v.Hostname }
if v.Action != "" { ts["action"] = v.Action }
event.Device["turnstile"] = tsAI agents
Tell FRAPE when an AI agent is buying
Some customers let an AI agent browse and pay for them. Add the optional agent block to any event to tell FRAPE what you know about it: who started the event, which company runs the agent, the agent's signature when its request to your site carried one, and the spending limits or agent payment token you were given. Every field is optional and is your own statement, except the signature, which FRAPE checks. Without the block nothing changes.
Forward the signature. An agent that signs its requests (HTTP Message Signatures, RFC 9421) sends the request headers Signature, Signature-Input and usually Signature-Agent. Copy them into signature, signature_input and signature_agent from the request the event belongs to, for example the checkout submission, exactly as your server received them: do not trim, re-order or re-encode the values. Add method, the HTTP method of that request. When you send the signature object, signature, signature_input and authority are required; leave the object out when the request had no signature.
Set authority yourself. It is your own site's public hostname, as configured on your server: the host your checkout is served on, with the port only when it is not the default. Never copy it from the Host, :authority or X-Forwarded-Host header of the incoming request: the caller controls those values.
Forward the headers of one request with one event. When the same signature arrives with a different order, FRAPE records that it was reused.
The other fields are optional context. initiated_by is human, agent or unknown. operator is the company that runs the agent, as it presented itself to you: one of the operator values of the OpenAPI contract, or other. mandate holds the limits the person gave the agent, as presented to you: type, max_amount, expires_at and human_present. FRAPE does not verify the mandate. network_agent_token names the card network whose agent token paid, or none. Send the kind only, never the token or the credential itself.
A failed check never rejects the call. When the signature is missing, cannot be checked or does not check out, the event is scored as usual and the result is recorded as information for your rules, not returned as an error. Only a block that does not follow the contract, such as an extra key or a signature without authority, is rejected with 400 validation_failed, like any other invalid request.
An AI agent is not fraud by itself. Your policy decides what the result does. FRAPE keeps the result of the signature check with the event, not the header values.
"agent": {
"initiated_by": "agent",
"operator": "other",
"signature": {
"signature": "sig1=:zzZz64Qsywnew4Bl0n53tczk6v33m3G+/nWIFElBWJB81Foqc3LWdiH8wrRnIOtcVptlTbtUktXpniKG3HdfCA==:",
"signature_input": "sig1=(\"@authority\" \"@method\" \"signature-agent\");created=1799999995;keyid=\"MxQAxk9mO8qc4rIg0gUpCfIidSzKPLSZi6EKdWSRLSM\";alg=\"ed25519\";expires=1800003595;nonce=\"Ewy2jN-_QBwCFlpOzQ4Ker1T-md9dUTb1d6xXFF-Um5h1q8gz1nFqqFh_OGvbwrWous_-4wc2lHHyyTSzI7rWQ\";tag=\"web-bot-auth\"",
"signature_agent": "\"https://agents.frape.test\"",
"authority": "shop.frape.test",
"method": "POST"
},
"mandate": {
"type": "cart",
"max_amount": { "value_minor": 15000, "currency": "EUR" },
"expires_at": "2026-10-01T13:00:00Z",
"human_present": false
},
"payment_credential": { "network_agent_token": "none" }
}// Node (Express). Your own public hostname, from your configuration: e.g. "shop.example.com".
// Never read it from the request (Host, :authority, X-Forwarded-Host): the caller controls those.
const SITE_HOST = process.env.SITE_HOST;
// Copy the three headers and the method of the request the event belongs to, unchanged.
const agent = {};
const signature = req.get("signature");
const signatureInput = req.get("signature-input");
if (signature && signatureInput) {
agent.signature = {
signature,
signature_input: signatureInput,
authority: SITE_HOST,
method: req.method,
};
const signatureAgent = req.get("signature-agent");
if (signatureAgent) agent.signature.signature_agent = signatureAgent;
}
// add it to the score request when it has content: event.agent = agentExamples
Fast declines and errors
{
"event_id": "0199a1f2-80d4-7e19-b6a0-2c7d9e5f1a08",
"external_id": "order_81724",
"decision": "DECLINE",
"score": 100,
"risk_level": "critical",
"reasons": ["example_block_reason"],
"matched_rules": [
{ "id": "example_block_rule", "name": "Example blocking rule from your policy", "stage": "pre_hard",
"decision": "DECLINE", "reason": "example_block_reason" }
],
"model_called": false,
"model_skip_reason": "terminal_rule",
"policy_version": { "id": "0199a1d0-1b2c-7a3d-8e4f-5a6b7c8d9e0f", "version": 3,
"document_version": "acme.3", "scope": "organization" },
"latency_ms": 9
}HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
{
"type": "https://docs.frape.io/errors/forbidden_field",
"title": "Forbidden field",
"status": 400,
"code": "forbidden_field",
"errors": [
{ "pointer": "/card/number", "code": "forbidden_field",
"message": "card numbers (PAN) and CVV are never accepted" }
]
}HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
{
"type": "https://docs.frape.io/errors/validation_failed",
"title": "Request validation failed",
"status": 400,
"code": "validation_failed",
"errors": [
{ "pointer": "/amount", "code": "invalid_type", "message": "must be a JSON object" },
{ "pointer": "/billing_address/country", "code": "pattern",
"message": "must be an ISO 3166-1 alpha-2 country code in upper case, such as US or MX" },
{ "pointer": "/email", "code": "unknown_field", "message": "unknown field" },
{ "pointer": "/occurred_at", "code": "out_of_range",
"message": "must be a time between 2000-01-01T00:00:00Z and 24 hours after the current time" }
]
}Every field error names the field (pointer), a stable code and a message that says what the field expects, such as its length limit, its allowed values or its format. Messages never repeat the value you sent. Show them to your developers, and branch your code on code, not on the text.
Country codes must be assigned ISO 3166-1 alpha-2 codes in upper case (or XK). Text fields must not contain control characters other than tab, line feed and carriage return. occurred_at must be between 2000-01-01T00:00:00Z and 24 hours after our clock. Whole numbers may be written as 8 or 8.0.
| Status | code | When |
|---|---|---|
| 400 | validation_failed | A field is missing, unknown, in the wrong place or has a value that is not allowed. Details are in errors[]. |
| 400 | forbidden_field | A card number or security code anywhere in the body. |
| 401 | unauthorized | Missing, malformed, unknown, revoked or expired API key. |
| 402 | plan_quota_exceeded | Your plan's events for the period are used up (the included events of a plan with a hard monthly limit, the spending limit you set on a plan billed for extra events, or the test-key allowance). The body adds plan, limit and quota_resets_at. No event is created. There is no Retry-After: wait for quota_resets_at or upgrade. |
| 403 | insufficient_scope | The API key does not have the score:write scope, or you sent external_decisions without the comparisons:write scope. |
| 403 | org_suspended | Your organization is suspended. |
| 409 | idempotency_conflict | The same Idempotency-Key was already used with a different body. |
| 409 | idempotency_in_progress | The first request with this Idempotency-Key is still running. Retry after Retry-After (1 second). |
| 429 | rate_limited | The rate limit of the API key or of your plan is used up. Wait for Retry-After. |
| 500 | internal | An unexpected error. The body never contains internal details. |
| 503 | temporarily_unavailable | No decision was made. Retry after Retry-After with the same Idempotency-Key. |
POST /v1/score needs an API key with the score:write scope. Errors are application/problem+json with a stable code. New codes may be added, so handle codes you do not know.
Pre-checks
Check the email and phone before the payment
POST /v1/prechecks starts the slow checks, such as the mailbox check, before there is anything to score. Call it as soon as the customer types their email or phone: at sign-up, or at the checkout email step. FRAPE answers 202 Accepted at once and runs the checks in the background. When you score the payment a few minutes later, the answers are already stored, so the customer's first purchase gets them and scoring takes no longer.
POST /v1/prechecks HTTP/1.1
Host: api.frape.io
Authorization: Bearer frp_live_<prefix>_<secret>
Content-Type: application/json
{
"email": "[email protected]",
"phone": "+15555555555",
"first_name": "John",
"last_name": "Doe",
"customer_id": "cust_81723"
}HTTP/1.1 202 Accepted
Content-Type: application/json
{
"id": "019a2b3c-4d5e-7f60-8a1b-2c3d4e5f6a7b",
"accepted": ["mailbox", "caller_name", "line_type"]
}- Call it from your server with your live API key, never from the browser: a key in a page would let anyone spend your checks. The key needs the
score:writescope. The browser agent never calls it. - Send at least one of
emailorphone;first_name,last_name,full_name,customer_idandcountryare optional.country(two letters, such asUS) is used to read a phone number written without the country code. The rules are those of the same fields undercustomeron/v1/score. Unknown keys are ignored. - The response is never a result, score or decision.
ididentifies the request;acceptedlists the checks that will have an answer for you: on, available, given the email or phone they need, and within your allowance. The list contains only the checks that are enabled for your organization and available. It lists them whether or not FRAPE already holds an answer, so it never tells you what FRAPE knows. It is empty with a test key, when every check is turned off, or when your monthly allowance is used. - Checks:
mailbox(live),email_footprint(not currently available),phone_footprint(not currently available),sim_swap(coming),caller_name(live),line_type(live). Every check is on by default on paid plans once it is live; an admin can turn each one off in Settings › Pre-checks (the mailbox check: Settings › Email ping). The Free plan does not include pre-checks. The check names inacceptedmay grow, so accept names you do not know. - Test keys (
frp_test_) validate the request and answer 202 with"accepted": []: nothing is sent to a provider and nothing is stored. - Sending the same values again before their answers are due for a refresh queues nothing new and costs nothing. Answers already stored are free; only a check run against a provider counts.
| Status | code | When |
|---|---|---|
| 400 | validation_failed | No email and no phone (required at /email), or a value that fails the same rules as the same field under customer on /v1/score. Details are in errors[]. |
| 400 | forbidden_field | A card number or security code anywhere in the body. |
| 401 | unauthorized | Missing, unknown, revoked or expired API key. |
| 403 | insufficient_scope | The API key does not have the score:write scope. |
| 403 | org_suspended | Your organization is suspended. |
| 413 | payload_too_large | The request body is larger than 64 KiB. |
| 429 | rate_limited | The same rate limit as /v1/score for your plan. Wait for Retry-After. |
| 503 | temporarily_unavailable | FRAPE could not take the request. Nothing was queued; retry after Retry-After. |
Errors are application/problem+json, as on /v1/score. A used-up allowance, a check you turned off or a provider that is down is not an error: you still get 202, without that check in accepted.
// Your server. Never call /v1/prechecks from the browser.
const FRAPE = "https://api.frape.io";
const headers = {
Authorization: `Bearer ${process.env.FRAPE_API_KEY}`, // frp_live_...
"Content-Type": "application/json",
};
// 1. Checkout email step: the customer has just typed an email.
// Fire and forget: the 202 comes back at once and carries no result.
fetch(`${FRAPE}/v1/prechecks`, {
method: "POST",
headers,
body: JSON.stringify({ email: customer.email, phone: customer.phone }),
}).catch(() => {}); // a failed pre-check never blocks the customer
// 2. Minutes later, at payment: score as usual with the same email and phone.
// The pre-check answers are already stored and your rules can use them.
const res = await fetch(`${FRAPE}/v1/score`, {
method: "POST",
headers: { ...headers, "Idempotency-Key": `checkout-${order.id}` },
body: JSON.stringify({
event_type: "payment",
external_id: order.id,
occurred_at: new Date().toISOString(),
amount: { value_minor: order.totalMinor, currency: order.currency },
customer: { email: customer.email, phone: customer.phone },
// ...device, card, billing as on any payment
}),
});Do not wait for the pre-check before you continue: the answers are written in the background, and a payment scored before they arrive is scored without them, as today.
Send the same email and phone in customer on /v1/score. Your rules can use the answers; a pre-check never changes a decision on its own.
FRAPE sends a value only to the provider of a check that is on for you, keeps only the verdict, stored with a keyed hash of the email or phone, and may reuse it for other customers that use the same check, solely to prevent fraud, until 180 days after it was last refreshed or used. Name checks (caller name) are the exception: their result is kept only for you and that name, never reused for other customers. What pre-checks send and keep. Before you send an email or phone, tell your customers in your privacy notice, shown at sign-up or checkout, that it is checked with fraud-prevention services; your terms with FRAPE require it. See the end-user disclosure.
Reference
Other endpoints
The same API key format and the same application/problem+json errors apply. Each call needs an API key with the scope shown.
| Endpoint | Scope | What it does |
|---|---|---|
| POST /v1/feedback | feedback:write | Tell FRAPE what happened to a scored event. Send event_id, occurred_at and either label (fraud, chargeback or legit) or outcome_type (for example confirmed_fraud, chargeback, dispute_won, false_positive or confirmed_legit), with optional amounts, reason_code and external_reference. Answers 201 with feedback_id, event_id, label and created_at. A repeat with the same external_reference answers 200 with duplicate: true and stores nothing. To correct an outcome, send a new one with retracts_feedback_id. |
| POST /v1/feedback/batch | feedback:write | Up to 500 outcomes in one call, in a body of up to 1 MiB. Each item names the event by event_id or by your external_id (events of the last 30 days) and carries the same fields as POST /v1/feedback. Answers 200 with results[], one per item in the order sent: index, status (stored, duplicate or rejected) and, for a rejected item, a code. One bad item never fails the batch. |
| POST /v1/external-decisions | comparisons:write | Send another system's decisions for events FRAPE already scored, for side-by-side comparison. 1 to 500 items, each with subject (a comparison subject set up in the console), decision and event_id or external_id, plus optional score, reasons and external_reference. Answers 200 with results[]: index, status (stored, duplicate, conflict or rejected) and a code. These decisions never change a FRAPE decision. |
| GET /v1/events/{event_id} | events:read | The stored decision of one of your events: the fields of the score response plus event_type, occurred_at, created_at, label and outcomes_summary. An id that is not yours answers 404 not_found. |
| GET /v1/challenges/{challenge_id} | events:read | A step-up challenge: id, event_id, status (pending, passed, failed, abandoned or expired), methods, method, assurance, expires_at, created_at and completed_at. |
| POST /v1/challenges/{challenge_id}/result | challenges:write | Report the result of a challenge you performed with your own tools. An Idempotency-Key is required. Send method (one of the challenge's methods) and result (passed, failed or abandoned), with optional evidence: three_ds_status and liability_shift for three_ds, user_verified for passkey. Never send codes, phone numbers or emails. Answers 200 with the challenge. 409 challenge_already_resolved or challenge_expired; 422 challenge_method_not_allowed. |
Get started
Start stopping fraud today.
Start free with test keys, then see every decision explained on your own live traffic, with Decision Core advising in watch mode until you switch it on. Or tell us what you need to protect, and we will walk you through how FRAPE would decide it. Compare plans.