Account · Concept
Custom risk scores
Write a condition as a plain-English question with the answers you choose, like yes or no, or a few options. Our model scores each answer with a probability, and your rules act on the answer and how likely it is.
When to use it
- A judgement that doesn't reduce to one field and a threshold: "Does the shipping address fit this customer?"
- Sorting a case into a few kinds: "Which kind of customer is this order from?" with answers like normal, reseller and card testing.
- A condition your team applies by hand in the review queue today and wants measured.
A risk score never decides on its own. Your rules read its answer like any other field, and hold the thresholds.
How it works
- You write the question and its answers.
kind: yes_nohas the answersyesandno, which you can relabel and describe;kind: choicehas 2 to 8 answers, each avalue, alabeland an optionaldescription. A choice of three or more gets a "None of these" answer (none_of_these) unless you sendnone_of_these: false. - You choose the fields it reads. Only those fields are sent to the model.
- A rule asks. When a rule's outcome still depends on the answer, the model gives each answer a probability. A rule that is already decided by its other conditions never asks.
- Your rule decides. It reads the answer and its probability, like any other field.
Each live risk score adds three fields to the rules of its domains:
| Field | What it holds |
|---|---|
policy. | The answer with the highest probability. A tie goes to the answer listed first. |
policy. | One per answer: its probability. They add up to 1. |
policy. | Whether the probabilities were checked against your own outcomes. |
A rule usually reads the answer and how likely it is together:
{
"label": "Address doesn't fit, and the model is sure",
"when": [
{ "fact": "order.amount", "op": "gt", "value": 250 },
{ "fact": "policy.shipping_mismatch.answer", "op": "eq", "value": "no" },
{ "fact": "policy.shipping_mismatch.p.no", "op": "gt", "value": 0.8 }
],
"require": { "approval": true }
}
In the rule above, a small cart never reaches the model, because the first condition already doesn't match.
Write a risk score
- Turn them on. An owner or admin turns on custom risk scores in Settings → AI
(
PUT /v1/account/risk_scores/settingswithenabled: true). They are off by default. - Create it.
POST /v1/account/risk_scoreswith akey, thequestion(10 to 300 characters, asking one thing), optionalguidance, theanswersand thebindings: fields from the ones your rules can read (GET /v1/account/policies/fields), or a requestfieldfor free text (at most 500 characters, marked as text a person wrote). - Look at the data to be scored.
POST /v1/account/risk_scores/{key}/previewwith a past record or astatereturns the exact payload, and calls no model.
Every change makes a new, immutable version (POST /v1/account/risk_scores/{key}/versions). A new version never
changes the answers your live rules read until you promote it.
Test it
POST /v1/account/risk_scores/{key}/test with a past record or a state answers the risk score and records the
evaluation. GET /v1/account/risk_scores/{key}/evaluations lists recent ones: the answer, every probability, and
calibrated.
A checkout result lists every risk score its decision read, with the answer or the reason there was none. The deciding
rule's policy.trace shows each risk score condition as a risk_score node: the answer, its probabilities as rules
read them and as the model gave them, whether they were calibrated, and the evaluation's id.
Reasons
Every answer gets a short reason by default, written by a small model after the answer: one or two sentences naming the fields it leaned on, headed "Reason" on screens. The answer never waits for it and a reason never changes an outcome; one that couldn't be written reads unavailable.
reason.enabledturns reasons off for a risk score.reason.underandreason.overnarrow them to answers whose probability is under or over a number, or both.- Reasons are written for decisions and tests, never for shadow, replays or eval runs. They are stored encrypted, read
on one evaluation at a time (
GET /v1/account/risk_score_evaluations/{id}), never shown to customers, and included in the evaluation's price.
Go live
A risk score decides nothing until it has been measured on your own cases and has run beside your rules. A draft
of your rules may read a risk score that isn't live, so you can replay it; publishing rules that read one answers
risk_score_not_live.
-
Build a golden set.
POST /v1/account/risk_scores/{key}/golden_casesadds a past record or astatewith the answer you confirm is right. An eval run needs at least 20 cases covering two or more answers. -
Run an eval run.
POST /v1/account/risk_scores/{key}/eval_runsanswers every case and reports, per answer, how well the probabilities tell the answers apart (AUC), precision and recall at the thresholds your rules use, and how the top answers compare with the right ones. It also checks that the answers are stable, that text written into a free-text field can't move them by more than 0.10, and how much they shift when the answers are listed in reverse, when two descriptions are swapped, or when the question is reworded.A run that fits in the current minute answers at once; a larger one answers with
status: "running"and finishes in the background, read it withGET /v1/account/risk_scores/{key}/eval_runs/{id}. Eval runs, replays and Suggestions tests send at most what the answering service's per-minute limit leaves room for, keep a fifth of it for live decisions, and wait for the next minute rather than stop early. -
Shadow.
POST /v1/account/risk_scores/{key}/versions/{version}/shadowanswers the version on a sample of live cases after each response, without changing anything. -
Publish.
POST /v1/account/risk_scores/{key}/versions/{version}/publishneeds a passed eval run, 200 shadow evaluations or 7 days of shadow, and a replay you have read. Otherwise it answersrisk_score_not_readyand lists each step still open. A risk score doesn't have to be calibrated to go live.
GET /v1/account/risk_scores/{key} lists the same steps before you call publish: ready.shadow and ready.live each
say whether the newest version is ready and, in missing, which steps are still open (eval_run, shadow with how
many shadow evaluations so far, replay_viewed).
Replay and shadow
- Replay.
POST /v1/account/risk_scores/{key}/replayanswers a version over a window of your past records, newest first, at most 5,000. Senddry_run: truefirst to see how many records and evaluations it will count and the model cost. - What a replay shows. The share of cases by top answer, each answer's probability distribution, and, at five thresholds, how many orders and how much order value a rule at that threshold would decline, with the labelled results: true positive declines, false positive declines, missed and allowed, each with its order value. Labels come from the outcomes you report on orders.
- The finer grid.
gridgives the same every 0.05, with the share of cases above each threshold and the outcome rates if a rule declined above it, beside today's. Values are in the records'currency. - Finding them.
GET /v1/account/risk_scores/{key}/replayslists the replays, newest first, and the risk score'slatest_replaynames the newest finished one. - Shadow. A version in shadow answers the same cases as the live one, after each response, on a sample (1 in 4
by default,
shadow_sample_rate). It never changes a response, a bill line for the decision, an approval or a notification.
Labels and calibration
A model's probabilities aren't trustworthy until they are checked against what happened. A risk score is checked against your own outcomes, one answer at a time.
- Labels. Each version maps the labels you already have to the answer they show was right (
labels.map, for example{ "no": ["chargeback", "fraud"], "yes": ["legitimate", "matured_clean"] }). They come from the outcomes you report on orders, frommatured_clean(no dispute or flag aftermature_after_days), and fromPOST /v1/account/risk_scores/{key}/labelswith the right answer for a case. The latest label on a case wins, and a change keeps the history. - The list.
GET /v1/account/risk_scores/{key}/labelslists every label that counts, from people, your API, payments andmatured_clean, each with the answer it shows, then the ones you set that a later label replaced. - The starting map. A new yes/no risk score starts with
yesmeaning the risk is there: chargeback, fraud and refund abuse showyeswas right; legitimate andmatured_cleanshownowas. If your question asks the opposite ("Does the address fit?"), flip the map. A risk score with a few options starts with no map, and reads "No label mapped yet" (labels_status: not_mapped) until you add one. - Calibration. With 100 or more labelled cases (and 20 for every answer your rules read),
POST /v1/account/risk_scores/{key}/calibratorsfits a calibrator on the older 70% of cases and measures it on the newest 30%.GET /v1/account/risk_scores/{key}/calibrationshows, per answer, how often it was right when it said 80% (the reliability table, after calibration and, inraw_reliability, before it), how far off it is on average (expected calibration error), how well it tells the answers apart (AUC), and how many cases are labelled. - Activation. The first calibrator waits for you to activate it, because it changes what a threshold in your rules means. Later refits replace it on their own only when they are no worse and move no answer's probabilities much.
- Before calibration your rules may still use the risk score with any outcome; the probabilities are the model's
own and
policy.<key>.calibratedis false. - What the labels don't cover. Outcomes exist for orders that went through or were reviewed, not for the ones rejected; the calibration page says how many of the evaluated cases are labelled.
When there is no answer
A model call can time out, fail, or not be made because a limit is spent. Then the risk score has no answer, never a
guessed one: its fields are unavailable, result on the evaluation says why, and your rule decides what happens:
| Setting | What the condition does |
|---|---|
skip | Doesn't match: the decision is what it would be without the risk score. |
match | Matches: the rule's outcome applies. |
ask | Matches, and the rule asks a person instead of refusing. |
A condition's if_unavailable wins; otherwise the risk score's own if_unavailable; otherwise the domain's default:
skip for checkout and traffic, ask for captures and agent actions. An evaluation with no answer is never billed.
Usage and billing
- The unit is one evaluation that returned probabilities. An evaluation with no answer, an answer reused for the same case within ten minutes, and a rule that never needed to ask are not counted. Reasons are included.
- Each plan includes evaluations every month, and evaluations past them are billed per evaluation (see the pricing page). On the trial, calls stop once the included evaluations are used.
- Tests, eval runs and replays first use a separate monthly testing allowance; past it they count like decisions.
monthly_capin the settings stops calls past a number of evaluations a month.GET /v1/account/risk_scores/usageshows the month so far, and the list of risk scores gives each one'sevaluations_this_month(live and shadow answers).- In the sandbox, risk scores give fixed test answers at no charge. Set
sandbox_provider: "real"on a risk score to ask the real model; those answers come out of the testing allowance and stop when it runs out. The published sandbox keys always get the test answers; a risk score read with them sayspublished_account: true. See the sandbox. - A risk score that Suggestions drafts is tested on your labelled records at no charge to you.
What is sent to the model
- Only the bound fields.
GET /v1/account/policies/fieldsgives each field'ssensitivitybefore you save: whether it is derived, personal, or never sent. - A sensitive field (a government id, a full card number, a security code, a password, a token, biometric data, a precise location) can never be bound.
- A raw personal field (a name, an email address, a street address, a phone number, an IP address, free text a person
wrote, or one of your own fields) is sent only when you choose it, after you accept the risk score data terms once
for your account (
accept_terms_version). In the live environment personal fields can't be bound yet; sandbox accepts them. - Your answers are sent as neutral option names (
a,b, …), with your label and description as each one's meaning, because a model can follow an option's name over its meaning. - We store the answer, the probabilities and hashes of what was sent, never the fields themselves.
Errors
| Code | When |
|---|---|
risk_ | Custom risk scores aren't turned on for the account. |
risk_ | The answer set isn't valid; param names the part. |
risk_ | A binding names something a risk score can't read. |
risk_ | A binding names a sensitive field. |
risk_ | A raw personal field before the data terms were accepted. |
risk_ | A raw personal field in live. |
risk_ | The model isn't a versioned id. |
risk_ | The deployment has no model provider for risk scores. |
risk_ | Rules you publish read a risk score that isn't live yet. |
Related
- Analysis queries: read-only SQL over your own records.
- Errors: every error code.