Fraud rules

Block cards at checkout based on card properties and transaction amount using configurable rules evaluated before each payment attempt.
View as Markdown

How fraud rules work

PaymentKit evaluates your fraud rules after card tokenization, before a payment is authorized. Each rule contains one or more conditions; if a rule matches, the card is blocked and the customer sees a decline message.

Rules are evaluated in the order they are listed. The first matching rule wins and blocks the card — subsequent rules are not evaluated.


Fraud settings vs. fraud rules

There are two related but distinct concepts:

ConceptWhat it controls
Fraud settingsAccount-level toggle (enabled) and optional custom decline message
Fraud rulesIndividual card-matching rules (CRUD resource)

Fraud rules are only evaluated when enabled is true in your account’s fraud settings.


Manage fraud settings

Get fraud settings

$curl https://api.paymentkit.com/api/accounts/{account_id}/fraud-settings \
> -H "Authorization: Bearer sk_live_..."

Response:

1{
2 "enabled": true,
3 "fraud_rules": [],
4 "custom_message": null
5}

Update fraud settings

$curl -X PATCH https://api.paymentkit.com/api/accounts/{account_id}/fraud-settings \
> -H "Authorization: Bearer sk_live_..." \
> -H "Content-Type: application/json" \
> -d '{
> "enabled": true,
> "custom_message": "This payment method is not accepted."
> }'
FieldTypeDescription
enabledbooleanWhether fraud protection is active
custom_messagestring | nullDecline message shown to customers. Overrides the per-rule reason when set.

Setting custom_message replaces the per-rule reason for all rules. Leave it null to show each rule’s individual reason to the customer.

Reset fraud settings

Resets all fraud settings to defaults (enabled: false, no custom message):

$curl -X DELETE https://api.paymentkit.com/api/accounts/{account_id}/fraud-settings \
> -H "Authorization: Bearer sk_live_..."

This does not delete your fraud rules — it only resets the account-level settings. Your rules remain and can be re-enabled.


Manage fraud rules

Create a rule

$curl -X POST https://api.paymentkit.com/api/{account_id}/fraud-rules \
> -H "Authorization: Bearer sk_live_..." \
> -H "Content-Type: application/json" \
> -d '{
> "name": "Block prepaid cards",
> "logic": "AND",
> "enabled": true,
> "reason": "Prepaid cards are not accepted.",
> "conditions": [
> {
> "field": "card_type",
> "operator": "equals",
> "value": "prepaid"
> }
> ]
> }'

Response:

1{
2 "id": "frule_live_a1b2c3d4e5f6g7h8",
3 "name": "Block prepaid cards",
4 "logic": "AND",
5 "enabled": true,
6 "reason": "Prepaid cards are not accepted.",
7 "conditions": [
8 {
9 "field": "card_type",
10 "operator": "equals",
11 "value": "prepaid"
12 }
13 ],
14 "created_at": "2024-01-15T10:30:00Z",
15 "updated_at": "2024-01-15T10:30:00Z"
16}

Rule fields

FieldRequiredDefaultDescription
nameYesDisplay name (max 255 chars)
logicNoANDAND — all conditions must match; OR — any condition triggers the rule
enabledNotrueWhether this rule is active
reasonYesDecline reason shown to the customer (max 500 chars)
conditionsYesOne or more conditions (see below)

Conditions

Each condition has three fields:

FieldOptions
fieldcountry, brand, card_type, amount, iin
operatorequals, in, not_in, greater_than, less_than, starts_with
valueString, number, or list of strings (depending on operator)

Field reference

FieldDescriptionExample values
countryCard billing country (ISO 3166-1 alpha-2)"US", ["RU", "KP", "IR"]
brandCard network"visa", "mastercard", "amex", "discover"
card_typeCard funding type"credit", "debit", "prepaid"
amountTransaction amount in the account’s default currency (integer, minor units)5000 (= $50.00)
iinCard IIN/BIN (first 6 digits of card number)"411111", ["411111", "555555"]

Operator compatibility

OperatorCompatible fieldsValue type
equalsAll fieldsString or number
incountry, brand, card_type, iinList of strings
not_incountry, brand, card_type, iinList of strings
greater_thanamountNumber
less_thanamountNumber
starts_withiin, countryString

List rules

$curl "https://api.paymentkit.com/api/{account_id}/fraud-rules?page=1&page_size=20" \
> -H "Authorization: Bearer sk_live_..."

Supports pagination, filtering, and sorting:

ParameterDescription
pagePage number (default: 1)
page_sizeResults per page
filter[name]Filter by rule name
filter[enabled]Filter by enabled status
sortSort field: name, enabled, created_at, updated_at
orderasc or desc
searchFull-text search across name and reason

Get a rule

$curl https://api.paymentkit.com/api/{account_id}/fraud-rules/{rule_id} \
> -H "Authorization: Bearer sk_live_..."

Update a rule

All fields are optional — only include the fields you want to change:

$curl -X PATCH https://api.paymentkit.com/api/{account_id}/fraud-rules/{rule_id} \
> -H "Authorization: Bearer sk_live_..." \
> -H "Content-Type: application/json" \
> -d '{
> "enabled": false
> }'

Delete a rule

$curl -X DELETE https://api.paymentkit.com/api/{account_id}/fraud-rules/{rule_id} \
> -H "Authorization: Bearer sk_live_..."

Returns 204 No Content on success.


Example: multi-condition rule

Block high-value transactions from specific countries, using AND logic (both conditions must match):

$curl -X POST https://api.paymentkit.com/api/{account_id}/fraud-rules \
> -H "Authorization: Bearer sk_live_..." \
> -H "Content-Type: application/json" \
> -d '{
> "name": "High-value restricted countries",
> "logic": "AND",
> "enabled": true,
> "reason": "This transaction cannot be processed.",
> "conditions": [
> {
> "field": "country",
> "operator": "in",
> "value": ["RU", "KP", "IR"]
> },
> {
> "field": "amount",
> "operator": "greater_than",
> "value": 100000
> }
> ]
> }'

Block any card from a set of specific BINs using OR logic (either condition triggers the rule):

$curl -X POST https://api.paymentkit.com/api/{account_id}/fraud-rules \
> -H "Authorization: Bearer sk_live_..." \
> -H "Content-Type: application/json" \
> -d '{
> "name": "Blocked BINs",
> "logic": "OR",
> "enabled": true,
> "reason": "This card cannot be used for this purchase.",
> "conditions": [
> {
> "field": "iin",
> "operator": "in",
> "value": ["411111", "555555", "378282"]
> }
> ]
> }'

Permissions

ActionRequired permission
View fraud settingsSETTINGS:VIEW
Update / reset fraud settingsSETTINGS:EDIT
View fraud rulesBILLING_OBJECT:VIEW
Create fraud rulesBILLING_OBJECT:CREATE
Update fraud rulesBILLING_OBJECT:EDIT
Delete fraud rulesBILLING_OBJECT:DEACTIVATE