Revenue Leakage API
Analyze commercial records — orders, invoices, payments, and credits — for possible revenue leakage. Accepts raw JSON with no ERP or accounting integration required. Every monetary conclusion traces to supplied numbers, and exposure is reported cautiously.
Endpoint
POST /api/v1/revenue-leak
Metered by records analyzed (the total across all supplied arrays). The synchronous maximum is 10,000 records per request.
Request fields
| Field | Type | Description |
|---|---|---|
| orders | object[] | Order/opportunity records. Linked to invoices by order_id. |
| invoices | object[] | Invoice records. Linked to orders by order_id and to payments by invoice_id. |
| payments | object[] | Payment records. Linked to invoices by invoice_id. |
| credits | object[] | Credit/refund records. Used for duplicate-credit detection. |
Provide at least one array. Common fields (“amount”, “status”, “currency”) are detected automatically; missing values are treated as “no data”, never as zero.
Finding types
| Field | Type | Description |
|---|---|---|
| order_without_invoice | finding | An order with no linked invoice. Potential exposure. |
| invoice_amount_mismatch | finding | Invoiced amount differs from the booked order amount. |
| invoice_without_payment | finding | An unpaid invoice with no linked payment (and not void/refunded). |
| payment_amount_mismatch | finding | Payments do not sum to the invoiced amount. Underpayment is a verified shortfall. |
| duplicate_invoice | finding | The same invoice id appears more than once. |
| duplicate_credit | finding | The same credit id appears more than once. |
| status_conflict | finding | Lifecycle statuses disagree (e.g. a won order with only void invoices). |
| missing_financial_record | finding | A record references an id that is absent from the supplied data. |
Economic integrity
Exposure is split into potential (value at risk, such as an uninvoiced order) and verified (a proven shortfall between two supplied numbers, such as an underpayment). A discrepancy is never called “lost revenue” unless the numbers prove it. Counts are never turned into dollars, and when exposure cannot be defensibly calculated it is null.
Reasoning challenges
Before a finding is presented, it is tested against ordinary explanations — timing gaps, duplicate keys, currency mismatches, and missing evidence. Raised challenges lower a finding’s confidence and are listed in its challenges array so you can judge it for yourself.
Example request
POST /api/v1/revenue-leak
Authorization: Bearer stx_live_...
Content-Type: application/json
{
"orders": [
{ "order_id": "ORD-1", "amount": 18000, "status": "won" },
{ "order_id": "ORD-2", "amount": 9000, "status": "won" }
],
"invoices": [
{ "invoice_id": "INV-2", "order_id": "ORD-2", "amount": 9000, "status": "paid" }
],
"payments": [
{ "payment_id": "PAY-2", "invoice_id": "INV-2", "amount": 7000 }
]
}Example response
{
"request_id": "req_xxx",
"status": "completed",
"summary": { "records_analyzed": 4, "findings": 2, "processing_time_ms": 1 },
"financial_exposure": { "potential": 20000, "verified": 2000, "currency": null },
"findings": [
{
"type": "order_without_invoice",
"message": "Order ORD-1 has no linked invoice; its value is potentially at risk (not yet proven lost).",
"monetary_class": "potential_exposure",
"amount": 18000,
"currency": null,
"confidence": 0.8,
"evidence": [{ "source": "orders", "record_id": "ORD-1", "field": "amount", "value": 18000, "index": 0 }],
"challenges": []
},
{
"type": "payment_amount_mismatch",
"message": "Payments for invoice INV-2 do not equal the invoiced amount (observed discrepancy).",
"monetary_class": "verified_exposure",
"amount": 2000,
"currency": null,
"confidence": 0.9,
"evidence": [
{ "source": "invoices", "record_id": "INV-2", "field": "amount", "value": 9000 },
{ "source": "payments", "record_id": "PAY-2", "field": "amount", "value": 7000 }
],
"challenges": []
}
]
}Code examples
curl -X POST https://crossstax.dev/api/v1/revenue-leak \
-H "Authorization: Bearer $CROSSSTAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"orders": [{ "order_id": "ORD-1", "amount": 18000, "status": "won" }],
"invoices": [],
"payments": []
}'import { CrossStax } from "@crossstax/sdk"
const crossstax = new CrossStax({ apiKey: process.env.CROSSSTAX_API_KEY! })
const result = await crossstax.revenue.detectLeakage({
orders,
invoices,
payments,
})
console.log(result.summary.findings, result.financial_exposure)import os, requests
resp = requests.post(
"https://crossstax.dev/api/v1/revenue-leak",
headers={"Authorization": f"Bearer {os.environ['CROSSSTAX_API_KEY']}"},
json={"orders": orders, "invoices": invoices, "payments": payments},
)
data = resp.json()
print(data["summary"], data["financial_exposure"])