Documentation Index
Fetch the complete documentation index at: https://docs.finwatch.finance/llms.txt
Use this file to discover all available pages before exploring further.
Getting Started with FinWatch
This guide takes you from zero to a running FinWatch instance with your first fraud detection rule evaluated — in under 10 minutes.What is FinWatch?
FinWatch is an embeddable, developer-first fraud detection engine designed to run alongside your fintech application. Unlike traditional fraud detection platforms that operate as opaque, external services, FinWatch deploys directly into your infrastructure and gives you full transparency and control over the rules that govern your transaction monitoring. At its core, FinWatch provides three things:- The Watch Script DSL — A purpose-built domain-specific language for writing fraud detection rules. Rules are stored as
.wsfiles that can be versioned in Git, reviewed in pull requests, and deployed with the same rigour as your application code. The language is designed to express complex fraud patterns — velocity checks, time-based anomalies, sequential behaviour analysis — in a readable, declarative format. - An Embedded Analytical Engine — FinWatch uses DuckDB, a high-performance embedded analytical database, to store and query transaction data locally. This means aggregate functions like “count the number of transactions from this account in the last 24 hours” execute in milliseconds without requiring a round-trip to an external database. DuckDB’s columnar storage and vectorised execution engine are optimised for exactly this type of analytical workload.
- GitOps-Native Rule Management — Rules can be synced from a Git repository, enabling a full CI/CD lifecycle for fraud logic; write a rule, open a PR, get it reviewed by your compliance team, merge, and FinWatch picks it up automatically. Every change is audited, every version is recoverable.
Prerequisites
Before you begin, make sure you have the following:- Docker (recommended) — Install Docker
- curl — For sending HTTP requests from the command line. Pre-installed on macOS and most Linux distributions.
- A text editor — For writing
.wsrule files. Any editor works;VS Codeis recommended. - Basic terminal knowledge — You should be comfortable running commands in a terminal.
- Go 1.21+ — Install Go
- Git — For cloning the repository and (optionally) for GitOps rule management.
Installation
Docker
The fastest way to get FinWatch running:- Starts FinWatch in the background (
-d). - Maps port
8081on your host to port8081in the container. - Sets the watch script directory to
/app/watch_scriptsinside the container. - Mounts a local directory (
my_rules/) so you can add and edit rule files from your host machine.
[] — this means FinWatch is running and ready.
Environment Variables
FinWatch’s behaviour is configured through environment variables. Here is a complete reference:WATCH_SCRIPT_DIR
Default:
watch_scriptsDirectory where .ws rule files are stored and watched for changes.WATCH_SCRIPT_GIT_REPO
Default: (empty)Git repository URL to sync rules from. If set, enables GitOps mode.
WATCH_SCRIPT_GIT_BRANCH
Default:
mainThe Git branch to track for rule updates.CLIENT_DSN
Default: (empty)PostgreSQL connection string for the database. Enables the watermark sync feature.
FINWATCH_MEMORY_LIMIT
Default:
2GiBMaximum memory DuckDB is allowed to use. Accepts values like 1GiB, 4GiB, 512MiB.FINWATCH_PORT
Default:
8081The HTTP port FinWatch listens on.Your First Transaction
With FinWatch running, let’s inject a transaction. This simulates what your application would do in production: sending a transaction to FinWatch for real-time risk evaluation. Run the followingcurl command:
| Field | Type | Required | Description |
|---|---|---|---|
transaction_id | string | No | A unique identifier. Auto-generated as a UUID if not provided. |
amount | float | Yes | The monetary value of the transaction. |
currency | string | Yes | The ISO 4217 currency code (e.g., "USD", "EUR", "NGN"). |
source | string | No | The account or entity initiating the transaction. |
destination | string | No | The account or entity receiving the transaction. |
reference | string | Yes | A unique reference string for idempotency. |
description | string | No | A human-readable description of the transaction. |
status | string | No | The current status of the transaction (e.g., "pending", "applied", "failed"). |
created_at | string (RFC3339) | No | The timestamp of the transaction. Defaults to the current time if not provided. |
meta_data | object | No | Arbitrary key-value metadata. This is where you put custom fields your rules can reference (e.g., IP address, country, device type, MCC codes). |
200 OK with an empty body. The transaction is now stored in DuckDB and has been evaluated against all active rules.
At this point, you have no rules — so nothing was flagged. Let’s fix that.
Your First Rule
Create a directory for your rules (if you haven’t already) and add a new file:HighValueCheck.ws inside my_rules/:
- Name:
HighValueCheck— A clear, descriptive identifier. - Description: Explains the rule’s purpose in plain English for auditors and analysts.
- Condition (
when): Checks if the transaction’samountfield is greater than10000. - Action (
then):- Verdict:
review— Flag for human analyst review (don’t hard-block). - Score:
0.7— High confidence that this warrants attention. - Reason: A clear explanation that will appear in logs and dashboards.
- Verdict:
my_rules/ directory for changes. Within seconds of saving the file, you should see a log message indicating the rule was compiled:
Testing the Rule
Now inject the same transaction again:$15,000 transaction exceeds the $10,000 threshold in your rule. In the FinWatch logs, you’ll see that the HighValueCheck rule fired and produced a review verdict with a 0.7 risk score.
Now inject a transaction that should not trigger the rule:
$500 transaction falls well below the $10,000 threshold. The rule does not fire. No verdict is produced.
What Just Happened?
Here’s the complete flow of what happened when you injected that$15,000 transaction:
- Ingestion: The HTTP handler receives the JSON payload and decodes it into a
Transactionstruct. - Storage: The transaction is inserted into the local DuckDB
transactionstable. This makes it available for aggregate queries by other rules. - Rule Evaluation: The engine loads all compiled rules and evaluates them against the transaction. Each rule’s
whenclause is checked. If it evaluates totrue, thethenclause produces aRiskVerdict. - Risk Consolidation: All verdicts are aggregated. The final risk score, verdict, and reason are determined.
- Anomaly Reporting: If the final verdict warrants it, an anomaly notification is sent to the FinWatch Cloud dashboard via the WebSocket tunnel for real-time alerting.
Next Steps
You’ve successfully installed FinWatch, injected a transaction, and written your first rule. Here’s where to go from here:- Writing Your First Rule — A deeper tutorial on building rules step by step.
- Conditions Deep Dive — Learn every operator, logical combinator, and pattern matching technique available in the
whenclause. - Aggregate Functions Guide — The most powerful feature of the DSL: detecting fraud patterns over time using
count(),sum(),avg(), and more. - The Rule Cookbook — A library of production-ready rule patterns you can copy and customise.
- DSL Reference — The complete language reference for the Watch Script DSL.
- API Documentation — Full REST API reference for all FinWatch endpoints.
.png?fit=max&auto=format&n=0JF6z69u57hmqsWm&q=85&s=531373acedba0eb783b669f6d558dfd8)