Update a Rule
PATCH https://api.fraudio.com/v1/rules/:rule_id
Endpoint Overview
The "Update Rule" endpoint allows you to modify and adjust a specific fraud detection rule using its unique identifier. This capability ensures that as your organization's requirements change, your fraud prevention measures can evolve to match.
If you face any challenges when updating a rule or need clarity on certain aspects of this endpoint, don't hesitate to contact our Support Team. We're eager to help.
Request Parameters
Path Parameters
The endpoint requires the following path parameter:
rule_id
: The unique identifier (UUID) of the rule you wish to update.
Example Request With Path Parameter
PATCH https://api.fraudio.com/v1/rules/123e4567-e89b-12d3-a456-426614174000
Request Body
The body of the request should contain the fields of the rule you wish to update. Note: Not all fields may be updatable; refer to the rule object documentation for details on each field.
After a successful update, the version of the rule will be incremented by 1.
Example:
{
"name": "Updated Rule Name",
"description": "Updated description for the rule."
}
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 when updating a rule. | 200 OK - Rule updated response |
400 | Bad Request | Response when the request body is malformed or contains invalid data. | Problem response |
404 | Not Found | Response when the specified rule ID does not exist. | Problem 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 PATCH 'https://api.fraudio.com/v1/rules/YOUR_RULE_ID_HERE' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer $ACCESS_TOKEN" \
-d '{
"externalId": "new-external-id",
"name": "Updated Rule Name",
"description": "Updated rule description",
"trigger": "transaction.mcccode == 1234",
"action": "review",
"status": "disabled",
"priority": 2
}'
import os
import requests
rule_id = "YOUR_RULE_ID_HERE"
rules_endpoint = f"https://api.fraudio.com/v1/rules/{rule_id}"
access_token = os.environ["ACCESS_TOKEN"]
headers = {
"authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
data = {
"externalId": "new-external-id",
"name": "Updated Rule Name",
"description": "Updated rule description",
"trigger": "transaction.mcccode == 1234",
"action": "review",
"status": "disabled",
"priority": 2
}
r = requests.patch(rules_endpoint, headers=headers, json=data)
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 UpdateRule {
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
String ruleId = "YOUR_RULE_ID_HERE";
String ruleEndpoint = "https://api.fraudio.com/v1/rules/" + ruleId;
String accessToken = System.getenv("ACCESS_TOKEN");
String requestBody = String.join(
"{",
"\"externalId\": \"new-external-id\",",
"\"name\": \"Updated Rule Name\",",
"\"description\": \"Updated rule description\",",
"\"trigger\": \"transaction.mcccode == 1234\",",
"\"action\": \"review\",",
"\"status\": \"disabled\",",
"\"priority\": 2",
"}"
);
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(ruleEndpoint))
.header("authorization", String.format("Bearer %s", accessToken))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(requestBody))
.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 $rule_id = "YOUR_RULE_ID_HERE"; # Replace with your specific rule ID
my $rule_endpoint = 'https://api.fraudio.com/v1/rules/' . $rule_id;
my $access_token = $ENV{"ACCESS_TOKEN"};
my $request_body = '{
"externalId": "new-external-id",
"name": "Updated Rule Name",
"description": "Updated rule description",
"trigger": "transaction.mcccode == 1234",
"action": "review",
"status": "disabled",
"priority": 2
}';
my $req = HTTP::Request->new(PATCH => $rule_endpoint);
$req->header('authorization' => "Bearer $access_token", "Content-Type" => "application/json");
$req->content($request_body);
my $ua = LWP::UserAgent->new;
my $resp = $ua->request($req);
my $message = $resp->decoded_content;
print "Received reply: $message";
<?php
$rule_id = "YOUR_RULE_ID_HERE"; // Replace with your specific rule ID
$rule_endpoint = "https://api.fraudio.com/v1/rules/" . $rule_id;
$access_token = $_SERVER["ACCESS_TOKEN"];
$request_body = json_encode([
"externalId" => "new-external-id",
"name" => "Updated Rule Name",
"description" => "Updated rule description",
"trigger" => "transaction.mcccode == 1234",
"action" => "review",
"status" => "disabled",
"priority" => 2
]);
$options = [
"http" => [
"header" =>
"authorization: Bearer $access_token\r\n" .
"Content-Type: application/json\r\n",
"method" => "PATCH",
"content" => $request_body
],
];
$context = stream_context_create($options);
$result = file_get_contents($rule_endpoint, false, $context);
print $result;
?>