This document outlines all live REST endpoints exposed by the RecoverX FastAPI backend (/api/v1).
- Purpose: Liveness probe verifying the API server is up and responsive.
- Request: None
- Response (200 OK):
{ "status": "ok", "environment": "development" }
- Purpose: Readiness probe verifying PostgreSQL and Redis connections and latencies.
- Request: None
- Response (200 OK):
{ "status": "ok", "database": { "status": "ok", "latency_ms": 1.2 }, "redis": { "status": "ok", "latency_ms": 0.8 } }
- Purpose: Daemon liveness and heartbeat checks for IDE / background worker monitoring.
- Query Params:
device_id(optional string) - Response (200 OK):
{ "status": "ok", "device_id": "73e9facf-...", "message": "RecoverX agent checkin acknowledged." }
- Purpose: Lists all detected recovery opportunities with associated orders, customer metadata, and payment attempts.
- Response (200 OK): Array of
RecoveryOpportunityobjects.
- Purpose: Retrieves full opportunity detail. Accepts UUIDs or canonical demo string aliases (
opp_demo_01throughopp_demo_04). - Response (200 OK):
RecoveryOpportunityobject with nested order, customer, and payment attempts. - Errors:
404 Not Foundif opportunity does not exist.
- Purpose: Dispatches sanitized failure context to the AI Diagnostic Agent (
recovery-diagnostic-v1) to generate an advisory proposal. - Response (200 OK):
{ "opportunity_id": "opp_demo_01", "proposal": { "diagnosis_category": "TRANSIENT_PAYMENT_FAILURE", "diagnosis_summary": "NPCI switch timeout during UPI authorization. Low customer friction risk.", "recommended_action": "CREATE_RECOVERY_PAYMENT_LINK", "confidence": 0.94, "fallback_action": "ESCALATE_TO_MERCHANT", "decision_factors": ["High customer lifetime value", "First attempt failure", "Payment gateway timeout code"] }, "provider": "mock", "evaluated_at": "2026-09-04T00:00:00Z" }
- Purpose: Evaluates deterministic Policy Gate rules and dispatches bounded financial action (e.g. Razorpay Payment Link) if allowed.
- Response (200 OK):
{ "action_id": "act_...", "opportunity_id": "opp_demo_01", "action_type": "CREATE_RECOVERY_PAYMENT_LINK", "execution_status": "SUCCEEDED", "payment_link_url": "https://rzp.io/i/rec_mock_...", "idempotency_key": "recovery:opp_demo_01:attempt:1" } - Errors:
400 Bad Requestif order is already paid or terminal state reached.
- Purpose: Lists all dispatched payment links, retries, and gateway executions.
- Response (200 OK): Array of
RecoveryActionrecords.
- Purpose: Returns the append-only cryptographic audit ledger of all domain events, policy decisions, and webhook settlements.
- Response (200 OK): Array of
AuditEventobjects.
- Purpose: Retrieves active configurable policy parameters alongside the 10 immutable safety invariants.
- Response (200 OK):
{ "rules": [ { "id": "max_recovery_amount", "name": "Maximum Autonomous Recovery Amount", "value": 15000, "unit": "INR" }, { "id": "min_recovery_score", "name": "Minimum Score for Auto-Recovery", "value": 60, "unit": "points" }, { "id": "max_recovery_attempts", "name": "Maximum Recovery Attempts per Order", "value": 2, "unit": "attempts" }, { "id": "cooldown_period_minutes", "name": "Cooldown Period Between Attempts", "value": 30, "unit": "minutes" } ], "immutable_invariants": [ "No recovery on paid orders", "No recovery on cancelled/refunded orders", "Deterministic idempotency on payment creation", "Cryptographic HMAC verification on all webhooks" ] }
- Purpose: Updates configurable policy thresholds (e.g. maximum autonomous amount cap or score threshold).
- Request Body:
{ "max_recovery_amount": 20000, "min_recovery_score": 65, "max_recovery_attempts": 2, "cooldown_period_minutes": 30 }
- Purpose: Ingests live Razorpay payment, order, and payment link webhooks.
- Headers Required:
X-Razorpay-Signature,X-Razorpay-Event-Id(optional) - Supported Events:
payment.failed(InitializesRecoveryOpportunityinDETECTEDstatus)payment.captured(Reconciles order and transitions opportunity toRECOVERED)order.paid(Transitions order and prevents any future recovery attempts)payment_link.paid(Reconciles dispatched payment link and settles recovered revenue)
- Response (200 OK):
{ "status": "processed", "event_id": "evt_...", "event_type": "payment_link.paid", "message": "Event successfully processed and synchronized." } - Errors:
401 Unauthorized: Missing or invalid HMAC-SHA256 signature.400 Bad Request: Empty body or malformed JSON payload.
Note: These endpoints are reserved for local evaluation, pitch demonstrations, and test harness execution.
- Purpose: Restores database opportunities, orders, and action ledgers to a clean pre-recovery baseline state.
- Response (200 OK):
{"status": "reset_completed", "message": "Demo environment state reset to clean baseline."}
- Purpose: Synthesizes and ingests an authentic
payment_link.paidwebhook for a target opportunity to simulate payment capture without external network calls. - Request Body:
{"opportunity_id": "opp_demo_01"} - Response (200 OK):
{ "status": "simulated_success", "opportunity_id": "opp_demo_01", "recovered_amount_inr": 8499.0 }
- Purpose: Returns the Phase 7A 25,000 synthetic transaction benchmark results and threshold frontier.