Create a Rule
POST https://api.fraudio.com/v1/rules
Endpoint Overview
The Rule creation endpoint is part of our Rules Management API, designed to streamline the way you define and handle fraud detection rules within your organization. With this endpoint, you can programmatically add new rules that specify conditions (triggers) and the resulting actions (allow, review, deny). Each rule can be prioritized and enabled or disabled as needed, providing you with robust and flexible control over fraud management.
tip
For any questions or uncertainties regarding this endpoint, our Support Team is available for assistance.
Request Parameters
Request parameters in JSON format
Toggle to view an example of request parameters in JSON format for creating a rule
json
{
"externalId": "rule-1",
"name": "Deny merchant",
"description": "Deny suspicious merchant",
"trigger": "transaction.merchant == \"suspicious-merchant-1\"",
"action": "deny",
"status": "enabled",
"priority": 1
}
Request parameters: Field Reference Table
Field | Data Type | Description |
---|---|---|
externalId | String | Unique identifier for the rule from an external system. |
name | String | Brief title for the rule. |
description | String | Detailed explanation of the rule's functionality. |
trigger | String | Logical expressions to evaluate incoming pre-auth transactions. |
action | String | Action to take when the trigger is met. Can be allow , review , or deny . |
status | String | Current state of the rule. Can be enabled , disabled , or archived . |
priority | Integer | Priority level for the rule. Ranges from 1 (highest) to 5 (lowest). |
Response Parameters
Status Code | Status Message | Description | Schema |
---|---|---|---|
200 | OK | Standard response for successful HTTP requests. | 200 OK - Rule creation response |
4xx , 500 , 501 , 502 , 503 , 504 | error | Various error messages for unsuccessful HTTP requests. | Problem response |
Code Samples
- Shell
- Python
- Java
- Perl
- PHP
curl -X POST 'https://api.fraudio.com/v1/rules' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer $ACCESS_TOKEN" \
--data-raw '{
"externalId":"rule-1",
"name":"Deny merchant",
"description":"Deny suspicious merchant",
"trigger":"transaction.merchant == \"suspicious-merchant-1\"",
"action":"deny",
"status":"enabled",
"priority":1
}'
import json
import os
import requests
rules_endpoint = "https://api.fraudio.com/v1/rules"
access_token = os.environ["ACCESS_TOKEN"]
rule = {
"externalId": "rule-1",
"name": "Deny merchant",
"description": "Deny suspicious merchant",
"trigger": "transaction.merchant == \"suspicious-merchant-1\"",
"action": "deny",
"status": "enabled",
"priority": 1
}
headers = {
"authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
r = requests.post(rules_endpoint, headers=headers, data=json.dumps(rule))
print(r.json())
package com.fraudio;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class CreateRule {
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
String createRuleEndpoint = "https://api.fraudio.com/v1/rules";
String accessToken = System.getenv("ACCESS_TOKEN");
String rule = "{\"externalId\":\"rule-1\",\"name\":\"Deny merchant\",\"description\":\"Deny suspicious merchant\",\"trigger\":\"transaction.merchant == \\\"suspicious-merchant-1\\\"\",\"action\":\"deny\",\"status\":\"enabled\",\"priority\":1}";
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(createRuleEndpoint))
.header("authorization", String.format("Bearer %s", accessToken))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(rule))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse < String > response = client.send(request, HttpResponse.BodyHandlers.ofString());
String responseBody = response.body();
System.out.println("Response Code: " + response.statusCode() + "\nResponse Body: " + responseBody);
}
}
use LWP::UserAgent;
use HTTP::Request::Common;
my $create_rule_endpoint = 'https://api.fraudio.com/v1/rules';
my $access_token = $ENV{"ACCESS_TOKEN"};
my $rule = '{"externalId":"rule-1","name":"Deny merchant","description":"Deny suspicious merchant","trigger":"transaction.merchant == \"suspicious-merchant-1\"","action":"deny","status":"enabled","priority":1}';
my $req = HTTP::Request -> new(POST => $create_rule_endpoint);
$req -> header('authorization' => "Bearer $access_token", "Content-Type" => "application/json");
$req -> content($rule);
my $ua = LWP::UserAgent -> new;
my $resp = $ua -> request($req);
my $message = $resp -> decoded_content;
print "Received reply: $message";
<?php
$create_rule_endpoint = "https://api.fraudio.com/v1/rules";
$access_token = $_SERVER["ACCESS_TOKEN"];
$rule =
"{\"externalId\":\"rule-1\",\"name\":\"Deny merchant\",\"description\":\"Deny suspicious merchant\",\"trigger\":\"transaction.merchant == \\\"suspicious-merchant-1\\\"\",\"action\":\"deny\",\"status\":\"enabled\",\"priority\":1}";
$options = [
"http" => [
"header" =>
"authorization: Bearer $access_token\r\n" .
"Content-Type: application/json\r\n",
"method" => "POST",
"content" => $rule,
],
];
$context = stream_context_create($options);
$result = file_get_contents($create_rule_endpoint, false, $context);
print $result;
?>