# Rule Engine

<mark style="color:yellow;">`POST`</mark>  `/api/v2/engine/evaluate`

Allows businesses to define, manage, and execute automated compliance rules based on logical conditions. Each rule follows a clear structure:

**If (Condition), then (Action)**

These rules automatically evaluate incoming data, such as transactions against defined compliance criteria. When a condition is met, the system takes action, like triggering an alert or flagging a case, allowing compliance teams to respond quickly and accurately.

Typical use cases include:

* Automate compliance checks
* Enforcing country-specific regulations
* Detecting and escalating suspicious activity

***

### Travel Rule Threshold by Country

**Purpose:** Apply country-specific transaction thresholds in line with jurisdictional Travel Rule requirements. For each transaction, convert the transaction amount from the original currency to the official currency of the specified country (based on the country code). Compare the converted amount against the applicable Travel Rule threshold for that country.

**Condition / Action:** If the amount is equal to or exceeds the threshold, then, trigger an alert.

{% hint style="success" %}
Thresholds by country are configured based on each customer’s specific requirements. For more information, please contact the Ospree tech team or email <support@ospree.io>.
{% endhint %}

| Name            | Type   | Description                                                                                                                                                                                                                                                                       | Required |
| --------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| transaction\_id | string | Unique identifier for the transfer, generated by the business system. Example: <mark style="color:orange;">`transfer20250312040414`</mark>                                                                                                                                        | True     |
| amount          | number | The value being transferred, whether for an incoming or outgoing transaction.                                                                                                                                                                                                     | True     |
| currency        | string | The three-letter [ISO 4217](https://www.iban.com/currency-codes) currency code representing the currency of the transaction (Example:  <mark style="color:orange;">`USD`</mark>, <mark style="color:orange;">`EUR`</mark>). Used to determine the value for threshold evaluation. | True     |
| country         | string | <p>Country to verify the threshold (use <a href="https://www.iban.com/country-codes">ISO 3166-1 alpha-2 </a>country code).</p><p>Example: <mark style="color:orange;"><code>AE</code></mark> (United Arab Emirate)</p>                                                            | True     |

{% tabs %}
{% tab title="REQUEST" %}

```json
curl -X POST https://sandbox.ospree.io/api/v2/engine/evaluate
-h 'Content-Type: application/json' \
-h 'Accept: application/json' \
-h 'Authorization: ••••••' \
-d '{
  "transaction": {
    "transaction_id": "txn_1234567890",
    "amount": 1000,
    "currency": "USD",
    "country": "AE"
  },
  "rule_codes": [
    "THRESHOLD_BY_COUNTRY"
  ]
}' 
```

{% endtab %}
{% endtabs %}

When the amount is equal to or exceeds the defined threshold, the system will trigger a Travel Rule alert for compliance action or further review.

{% tabs %}
{% tab title="RESPONSE" %}

```json
 "status": "success",
  "data": {
    "transaction_id": "txn_1234567890",
    "evaluated_at": "2025-06-30T10:16:58.763539",
    "results": [
      {
        "rule_code": "THRESHOLD_BY_COUNTRY",
        "status": "breach",
        "message": "Transfer exceeds threshold (3500 AED) for AE"
      }
    ]
  }
```

{% endtab %}
{% endtabs %}

When the amount is below the defined threshold, no alert is triggered and no further action is required.

{% tabs %}
{% tab title="RESPONSE" %}

```json
 "status": "success",
  "data": {
    "transaction_id": "txn_1234567890",
    "evaluated_at": "2025-06-30T10:50:44.836868",
    "results": [
      {
        "rule_code": "THRESHOLD_BY_COUNTRY",
        "status": "pass",
        "message": "Transfer is within threshold (3500 AED) for AE"
      }
    ]
  }
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ospree.io/ospree-api/rule-engine.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
