API reference

Pi Recon

Data reconciliation and validation API.

Base URL

https://api.recon.io/v1

Endpoints

18 documented routes

Table of Contents

  1. What is Recon?
  2. The Problem We Solve
  3. How It Works
  4. Core Capabilities
    • Five-Tier Deterministic Rule Engine
    • AI-Powered Matching for Unresolved Transactions
    • Multi-Modal Ingestion
    • Automated AI Engine Trigger
    • Confidence Scoring
    • Provider Resolution
    • Graceful Handling of Imperfect Data
  5. How Clients Use Recon
  6. Security & Compliance
  7. Usage Metering & Cost Controls
  8. Observability & Operations
  9. Product Maturity & Version History
  10. What Recon Is Not

1. What is Recon?

Recon is an automated payment reconciliation service built by PayIntelli. It ingests transaction records from external sources — acquirers, payment providers, finance teams — and systematically matches them against the authoritative transaction ledger maintained by the PayIntelli platform, producing a categorised result for every record: either a confirmed match at a specific confidence tier, or a flagged discrepancy requiring further attention.

Every payment business deals with the reconciliation problem: the records your payment provider sends you will not be a perfect mirror of the records in your own system. Amounts differ by fractions of a cent due to currency rounding. Timestamps differ by a day because of time-zone offsets. Transaction IDs arrive in different formats from different providers. Without an automated reconciliation layer, finance teams spend enormous amounts of time manually comparing spreadsheets — and they still miss things.

Recon replaces that manual process with a two-stage automated pipeline. The first stage is a deterministic rule engine that applies structured matching criteria in strict order, catching the bulk of transactions quickly and consistently. The second stage is an AI engine that handles the harder cases — the transactions that did not resolve cleanly through rules — using scored field matching and an LLM-generated explanation of each decision.

The result is a classified record in the database for every transaction in the reconciliation batch, with an audit trail of which engine matched it, at what confidence level, and why.

Example scenario: A client's finance team exports a CSV from their acquiring bank at month-end. It contains 5,000 transaction records. The file is uploaded to Recon. The rule engine processes each row: 4,700 match exactly on ID, amount, currency, and date (Tier 1). A further 180 match on ID and amount but have a one-day date discrepancy (Tier 2). Sixty more have an amount that is within 1% of the reference (Tier 3 — exchange rate rounding). Forty could not be matched by rules and are sent to the AI engine, which uses scored field matching and Claude to evaluate and explain each case. The finance team opens a dashboard showing the matched transactions in one column and the unresolved ones — with reasons — in another. The entire process takes under two minutes.

2. The Problem We Solve

Payment reconciliation is one of the most operationally intensive tasks in finance. Every business that processes payments through acquirers, PSPs, or card networks has to reconcile their internal transaction records against the settlement files or statements they receive from those providers. The problem compounds quickly with scale, and it compounds further when a business operates through multiple providers simultaneously.

The Manual Reconciliation Problem

2. The Problem We Solve

Description

At low transaction volumes, reconciliation is done manually. A finance analyst exports a report from the payment system and compares it, row by row, against the provider's settlement file. This works — badly — at low volumes. At any meaningful scale, it fails for several reasons.

It is slow. A team of analysts working on a large batch can take days to clear a month-end reconciliation. During that time, discrepancies are invisible, chargebacks may go unnoticed, and financial reporting is delayed.

It is error-prone. Human eyes miss things. When comparing two datasets with slight differences in formatting, date representation, and field naming conventions, errors in one direction are indistinguishable from errors in the other direction without careful cross-checking.

It does not scale. Hiring more analysts is the only way to increase throughput. As transaction volumes grow, the cost of reconciliation grows linearly — and the error rate grows too, because the same analysts are now under more pressure.

The Rule-Only Reconciliation Problem

2. The Problem We Solve

Description

The first automation attempt most businesses make is building a set of rules: if the transaction ID matches and the amount matches, it is reconciled. These rules resolve the straightforward cases quickly, which is a significant improvement. But rule systems break down at the edges.

Real-world reconciliation data is imperfect. Provider settlement files have date format inconsistencies. Currency conversions introduce fractional rounding differences. Time zones shift dates by a day. Provider IDs are represented as names in one system and as numeric codes in another. A rigid rule system that requires exact matches will reject a large proportion of transactions that are genuinely the same payment, simply because one field is formatted slightly differently.

The alternative — relaxing the rules to be more permissive — introduces false positives: matches that look correct on the rule criteria but are actually different transactions. Both outcomes are costly.

What Recon Does Differently

2. The Problem We Solve

Description

Recon combines a structured, tiered rule engine with an AI matching layer. The rule engine handles the clear cases fast, deterministically, and with full auditability. The AI engine handles the ambiguous residual cases using weighted field scoring and an LLM that produces a human-readable explanation for every decision.

Every outcome is recorded with a tier, a rule label, an engine identifier, and a confidence score. Operations teams and finance analysts can see exactly how every transaction was classified and why, without any manual comparison required.


3. How It Works

At a high level, every Recon processing cycle follows this flow:

Finance team uploads a settlement file, or S3 event triggers processing
          ↓
Rule Engine receives the transaction batch
          ↓
Request is authenticated — unauthorised requests are rejected immediately
          ↓
For each transaction in the batch:
          ↓
  The rule engine looks up the transaction ID in the reference ledger
          │
          ├── ID not found in reference → Tier 5 (unmatched, staged for AI)
          │
          └── ID found → provider and payment method are checked first
                    │
                    ├── Provider or method mismatch → Uncategorized (staged for AI)
                    │
                    └── Provider and method match → Rule evaluation:
                              │
                              ├── Tier 1: ID + exact amount + exact currency + exact date
                              │         → matched → recon_internal_transactions
                              │
                              ├── Tier 2: ID + exact amount + currency + date ±30 days
                              │         → matched → recon_internal_transactions
                              │
                              ├── Tier 3: ID + currency + amount within 1% + date ±30 days
                              │         → matched → recon_internal_transactions
                              │
                              ├── Tier 4: ID + currency + amount within 2% + date ±30 days
                              │         → unmatched, staged → recon_staging_raw_transactions
                              │
                              └── No rule matched → unmatched, staged → recon_staging_raw_transactions
          ↓
After CSV batch completes, AI Engine is triggered automatically (fire-and-forget)
          ↓
AI Engine processes all records in recon_staging_raw_transactions:
          ↓
  For each staged transaction:
    → Fetch candidate transactions from reference ledger within ±30-day window
    → Score each candidate across 10 weighted fields (transaction_id, client_id,
      provider, amount, currency, brand, status, user_id, checkout_id, date)
    → Select best candidate using hierarchical field-match selection
    → Call Claude (claude-3-5-haiku) to generate a human-readable match explanation
    → Update staged record: set matched_transaction_id, confidence_score,
      match_description, engine = "AI Engine"
          ↓
All transactions are now classified with tier, rule, engine, and confidence score

The rule engine and AI engine are independent Lambda functions. The rule engine runs synchronously during the upload or S3 event processing and produces results immediately. The AI engine is triggered asynchronously at the end of a CSV batch and runs in the background, updating staged records without blocking the upload response.

4. Core Capabilities

4.1 Five-Tier Deterministic Rule Engine

4. Core Capabilities

Description

The rule engine evaluates every incoming transaction through a strict, ordered hierarchy of five matching rules. Rules are applied in priority order — a transaction is assigned to the highest tier it qualifies for.

Tier 1 — Perfect match:
Transaction ID matches exactly. Amount matches exactly. Currency matches exactly. Date matches exactly (same calendar day). This is the strongest possible match. Tier 1 transactions are written to recon_internal_transactions with recon_status = matched and a confidence score of 100.

Tier 2 — Date-tolerant match:
Transaction ID matches exactly. Amount matches exactly. Currency matches. Date is within ±30 days of the reference. This handles date discrepancies caused by cut-off timing, time zone differences between provider and platform, or batch processing delays. Written to recon_internal_transactions.

Tier 3 — Amount-tolerant match:
Transaction ID matches. Currency matches. Amount is within 1% of the reference amount. Date is the same day or within ±30 days. This handles minor rounding differences — the most common source of which is currency conversion at slightly different exchange rates. Written to recon_internal_transactions.

Tier 4 — Weak match, staged:
Transaction ID matches. Currency matches. Amount is within 2% of the reference. Date is the same day or within ±30 days. This covers larger rounding or fee deduction discrepancies. Because the confidence is lower, Tier 4 transactions are written to recon_staging_raw_transactions for further review by the AI engine.

Tier 5 — ID not found:
The transaction ID does not exist in the reference ledger at all. This could indicate a transaction that was processed by the acquirer but not recorded internally, a data entry error, or a genuinely fraudulent charge. Written to recon_staging_raw_transactions.

Uncategorized — Provider or method mismatch:
The transaction ID exists in the reference ledger, but the provider or payment method recorded in the incoming file does not match the reference. This typically indicates a data integrity issue — a transaction being attributed to the wrong provider. Written to recon_staging_raw_transactions.

A critical design decision of the rule engine is that provider identity and payment method are prerequisites for rule evaluation, not a tier in themselves. If the provider or payment method does not match the reference, the transaction is uncategorized regardless of how well the other fields match. This prevents misleading matches across different providers for the same transaction ID.

4.2 AI-Powered Matching for Unresolved Transactions

4. Core Capabilities

Description

Transactions that the rule engine could not resolve cleanly — Tier 4, Tier 5, and Uncategorized — are processed by the AI engine as a second pass.

The AI engine uses a weighted field scoring model across 10 dimensions:

For each staged transaction, the AI engine fetches all reference transactions within a ±30-day window, scores each against the staged record using these weights, and selects the best candidate using a hierarchical field-match selection algorithm. The algorithm starts with the highest-weight field (transaction ID) and progressively narrows the candidate set — if multiple candidates still remain after all fields are evaluated, the one with the highest score, smallest amount difference, and smallest time difference wins.

Once the best candidate is identified, the AI engine calls Claude (claude-3-5-haiku) to generate a brief, human-readable explanation of the match decision. The explanation cites the specific fields that matched, the fields that did not, the amount difference if any, and the overall confidence score. This explanation is stored in match_description on the staging record and is available for audit and review.

Parameters

ParameterTypeRequiredDescription
Transaction IDstringOptional
Client IDstringOptional
ProviderstringOptional
AmountstringOptional
CurrencystringOptional
Card brand / payment methodstringOptional
StatusstringOptional
DatestringOptional
User IDstringOptional
Checkout IDstringOptional
**Total**stringOptional

4.3 Multi-Modal Ingestion

4. Core Capabilities

Description

The rule engine accepts transaction data in four different input formats, handling whichever the calling system provides:

CSV upload (base64-encoded): The client sends the CSV file content as a base64 string in the JSON request body, along with a filename. The rule engine decodes the CSV, writes it to S3 with AES-256 encryption, then processes each row.

S3 URI: The client provides the S3 URI of a file already in object storage (s3://bucket/path/to/file.csv). The rule engine reads directly from S3 and processes the file.

Bucket and key: The client provides the S3 bucket name and key separately. Equivalent to the S3 URI mode.

Single record: The client provides a single transaction as a JSON object with at minimum a transaction ID. The rule engine processes and categorises it immediately and returns the result inline.

The S3 event trigger is also supported — the rule engine can be invoked directly by an S3 ObjectCreated event when a file lands in the designated bucket, enabling fully automated reconciliation without any API call from the client system. EventBridge, SNS, and SQS fan-out patterns are all supported as event sources.

4.4 Automated AI Engine Trigger

4. Core Capabilities

Description

After processing a CSV batch — whether uploaded directly or read from S3 — the rule engine automatically triggers the AI engine as a fire-and-forget call. The client does not need to call the AI engine separately. The AI engine runs asynchronously in the background and updates staged records without blocking the rule engine's response.

This design ensures that the reconciliation pipeline is fully self-contained from the client's perspective. The client submits a file, the rule engine responds immediately with a summary of how many rows were processed and how many succeeded, and the AI engine continues working in the background on the harder cases.

4.5 Confidence Scoring

4. Core Capabilities

Description

Every reconciled record is stored with a numeric confidence score:

  • Score 100 — Tier 1, 2, or 3 matches (rule engine, strong deterministic match)
  • Score 60 — Tier 4, Tier 5, or Uncategorized (written to staging, pending AI resolution)
  • Score 0–100 (variable) — AI engine matches; the score is the weighted field match score out of 100

The confidence score gives downstream systems and operations teams a way to prioritise review. A batch with 4,700 records at confidence 100 and 40 records with a confidence score below 50 tells the finance team exactly where to focus their attention.

4.6 Provider Resolution

4. Core Capabilities

Description

Both the rule engine and the AI engine normalise provider identifiers automatically. Providers may arrive in the incoming file as numeric IDs or as name strings. The engines resolve numeric IDs to canonical provider names via the payment_providers table and normalise all provider names to lowercase for consistent comparison. Resolved names are cached within the Lambda execution environment to avoid repeated database lookups for the same provider within a single batch.

4.7 Graceful Handling of Imperfect Data

4. Core Capabilities

Description

Real settlement files are not clean. Recon is built to handle common data quality problems without failing:

Missing transaction IDs — if a row in the CSV has no ID field, the rule engine generates a deterministic SHA-1 hash from the available fields (client ID, checkout ID, amount, currency, date, filename, row index) and uses that as the transaction identifier. The row is processed and stored normally.

Ambiguous date formats — the rule engine accepts dates in ISO 8601, epoch timestamps (seconds and milliseconds), and a range of common day-month-year formats. Timezone-naive timestamps are treated as UTC.

Gzip-compressed CSV files — files with a .gz extension or Content-Encoding: gzip are decompressed transparently before processing.

CSV encoding — UTF-8 with BOM (utf-8-sig) is supported, handling files exported from Excel without manual pre-processing.

Duplicate rows — the database insert uses ON CONFLICT DO NOTHING, so submitting the same file twice will not create duplicate records.


5. How Clients Use Recon

Integrating Recon into a reconciliation workflow is straightforward. The client decides on the ingestion mode that fits their process and calls the rule engine endpoint accordingly.

Option A — Automated S3 trigger (recommended for high volume)

The client configures their acquirer or internal process to drop settlement files into the designated S3 bucket. An EventBridge rule fires on ObjectCreated events and invokes the rule engine Lambda automatically. No API call from the client system is needed. The AI engine follows automatically. This is the zero-touch integration.

Option B — CSV upload via API

The client system reads the settlement file, base64-encodes it, and POSTs it to the rule engine endpoint with a filename. This is the most common integration pattern for clients who manage their own file handling and want explicit confirmation that the file was received and processed.

Step 1 — Call the API with your CSV

Step 2 — Receive the processing summary

The response is immediate:

Step 3 — AI engine runs in the background

The rule engine has already triggered the AI engine. Within minutes, the staged records will be updated with AI match decisions and Claude-generated explanations.

Step 4 — Review results

Operations and finance teams query recon_internal_transactions for matched records and recon_staging_raw_transactions for unresolved records. The engine, rule_tier, confidence_score, and match_description fields provide a complete audit trail for every record.

6. Security & Compliance

6.1 Authentication

6. Security & Compliance

Description

The rule engine API is protected by Cognito-based JWT authorisation for authenticated client requests. The AI engine is protected by API key authentication scoped to the recon product. Requests without valid credentials are rejected before any processing begins. S3-triggered invocations bypass the authentication layer, as they originate from an AWS-internal event source.

6.2 Data Isolation

6. Security & Compliance

Description

All reconciliation processing is scoped to the authenticated client. Client IDs extracted from JWT claims are used to scope S3 key prefixes, so files from one client are stored in a separate path from files from another client. The database records include the client ID, allowing queries to be scoped without risk of cross-client data exposure.

6.3 Encrypted Connections

6. Security & Compliance

Description

All API communication is over encrypted connections. Database connections enforce SSL in transit. S3 objects are stored with AES-256 server-side encryption (ServerSideEncryption: AES256). The AI engine's Claude API call is made over HTTPS.

6.4 Credential Protection

6. Security & Compliance

Description

Database credentials, the Claude API key, and the Recon internal API key are all retrieved at Lambda startup from a centralised secrets management service. They are held in memory only, never logged, and never returned in error responses or API payloads.


7. Usage Metering & Cost Controls

Recon records one unit of usage against the client's account for every transaction row processed by the rule engine, regardless of the tier result.

Usage is recorded asynchronously via an internal SQS queue, so metering does not add latency to transaction processing. Usage data feeds into PayIntelli's billing and reporting infrastructure.

AI engine invocations are metered separately through the LLM token logging system. Every Claude API call records input and output token counts against the client ID in a dedicated logging endpoint, enabling token-level cost attribution per client.

Clients can request usage and token consumption reports through their account management contact.

8. Observability & Operations

Logging

8. Observability & Operations

Description

Both the rule engine and the AI engine produce structured log entries for every significant event:

Rule engine logs:

  • Every invocation (request received, auth result, ingestion mode detected)
  • Every file uploaded to S3 (bucket, key, client ID)
  • Every batch processed (row count, success count, error count, AI engine trigger status)
  • Every single-record categorisation (tier, rule applied)
  • AI engine trigger sent confirmation
  • Every unhandled exception with full traceback

AI engine logs:

  • Every invocation
  • Candidate fetch results (count, time window, staging record details)
  • Sample of top candidates evaluated (with scores and field matches)
  • Best candidate selected (with score, field match breakdown, amount and time differences)
  • Claude request and response (model, client ID, token counts)
  • Each batch record result (matched, score, candidate ID, reason)
  • Persist success or failure for each record

AI Engine Debug Mode

8. Observability & Operations

Description

The AI engine has a configurable debug log mode (AI_ENGINE_DEBUG environment variable, default: enabled). When debug mode is on, the engine logs detailed intermediate state at each step: the candidates fetched, the scoring applied to each candidate, the hierarchical selection process, the Claude request payload, and the final decision. This gives full visibility into why a specific staging record was matched to a specific reference transaction.

Token Cost Tracking

8. Observability & Operations

Description

Every Claude API call made by the AI engine is logged to a dedicated LLM cost tracking endpoint with input tokens, output tokens, model name, and client ID. This provides per-client AI cost attribution and allows monitoring of LLM usage trends over time.

Error Transparency

8. Observability & Operations

Description

The rule engine returns clear error responses for known failure modes:

  • Missing input fields (missing_filename, missing_client_id, missing_input)
  • Configuration problems (missing_bucket)
  • Internal errors with a traceback in logs

The AI engine validates required table environment variables at startup and returns a configuration error if they are missing, rather than producing cryptic SQL errors at runtime.


9. Product Maturity & Version History

VersionDateMilestone
0.5.0October 2025Initial rule engine: five-tier deterministic matching; CSV upload and S3 event support; basic DB insert
1.0.0February 2026Full production release: provider resolution and name normalisation; multi-modal input (base64, S3 URI, bucket/key, single record); AES-256 S3 encryption; usage metering via SQS; Cognito JWT auth; synthetic transaction ID generation for ID-less rows
1.1.0April 2026AI engine introduced: weighted 10-field scoring; hierarchical candidate selection; Claude integration for match explanation; automated AI trigger post-CSV batch; token usage logging
1.1.1June 2026AI engine connection stability improvements (keepalives, rollback on error state); gzip CSV support; BOM-tolerant CSV decoding; debug log mode configurable via environment

10. What Recon Is Not

To set accurate expectations for clients and integration teams:

Recon is not a real-time transaction system. Recon processes settlement files and batches — typically at end-of-day or end-of-month intervals. It is not a component of the live payment authorisation flow. It runs after transactions have already been processed by the acquirer and settled.

Recon is not a dispute or chargeback management platform. Recon identifies discrepancies between internal records and provider files. It does not initiate chargebacks, generate dispute evidence, communicate with card networks, or participate in the chargeback resolution process.

Recon is not a ledger or accounting system. Recon produces classified match records in database tables, but it does not integrate with accounting software, generate journal entries, or produce financial reports. The classified records are inputs to those processes, not the processes themselves.

Recon is not a fraud detection system. Identifying that a transaction exists in a provider's settlement file but not in the internal ledger may be a signal worth investigating, but Recon does not score fraud risk or make fraud decisions. That is the responsibility of Shield.

Recon is not a guarantee of completeness. The rule engine and AI engine together process every record in the submitted batch, but the quality of the output depends on the quality of the reference data in the internal ledger. If the reference ledger is incomplete or has data integrity issues, Recon's match rate will reflect those issues rather than hiding them.

Recon is not a human analyst replacement for complex disputes. For transactions where the AI engine produces a low confidence score or no match at all, human review remains essential. Recon reduces the volume of records requiring human review dramatically, but it does not eliminate it entirely.

Recon is not a provider statement parser. Recon expects structured CSV input with defined field names. It does not parse proprietary statement formats from specific acquirers or perform optical character recognition on PDF statements. Clients are responsible for converting provider statements into the expected CSV structure before submission.