{"openapi":"3.1.0","info":{"title":"CrossStax API","version":"1.0.0","description":"Business intelligence APIs for your software. Four APIs share one key, one account, and one account-level monthly record allowance: Lead Recovery (prioritize stale leads), Reconciliation (compare datasets), Verification (check claims against evidence), and Revenue Leakage (detect commercial discrepancies). Every financial conclusion traces to supplied numeric evidence; customer text is always treated as data. CrossStax by Staxaxis.","contact":{"name":"CrossStax","url":"https://www.crossstax.com"}},"servers":[{"url":"https://www.crossstax.com"}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Lead Recovery","description":"Lead recovery scoring"},{"name":"Reconciliation","description":"Dataset reconciliation and financial exposure"},{"name":"Verification","description":"Claim verification against supplied evidence"},{"name":"Revenue Leakage","description":"Revenue-leakage detection across commercial records"},{"name":"System","description":"Health and status"}],"paths":{"/api/v1/leads/recovery":{"post":{"tags":["Lead Recovery"],"summary":"Score a single lead","description":"Analyze a single lead (or a { leads: [] } batch as a convenience) and return a Recovery Score with a recommended next action.","operationId":"recoverLead","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadInput"},"examples":{"single":{"summary":"High-value roofing estimate","value":{"lead_id":"lead_123","industry":"roofing","status":"estimate_sent","lead_age_days":28,"last_contact_days":19,"estimate_value":12000,"explicit_rejection":false}}}}}},"responses":{"200":{"description":"Recovery result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoveryResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/api/v1/leads/recovery/batch":{"post":{"tags":["Lead Recovery"],"summary":"Score a batch of leads","description":"Analyze up to 1000 leads and return per-lead results plus an aggregated summary.","operationId":"recoverLeadsBatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchInput"}}}},"responses":{"200":{"description":"Batch recovery result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/api/v1/reconcile":{"post":{"tags":["Reconciliation"],"summary":"Reconcile two datasets","description":"Compare two datasets (e.g. CRM vs billing) using configurable primary/secondary keys and comparison fields. Returns exact/probable/unmatched classifications, conflicts, duplicates, needs_review items, and evidence-backed financial exposure. Metered by total records processed (source_a + source_b).","operationId":"reconcile","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReconcileInput"},"examples":{"crmVsInvoices":{"summary":"CRM opportunities vs issued invoices","value":{"source_a":{"name":"crm","records":[{"email":"acme@example.com","customer":"Acme Co","amount":25000,"status":"won"}]},"source_b":{"name":"billing","records":[{"email":"acme@example.com","customer":"Acme Co","amount":22000,"status":"paid"}]},"matching":{"primary_keys":["email"],"secondary_keys":["customer"],"compare_fields":["amount","status"],"amount_field":"amount"}}}}}}},"responses":{"200":{"description":"Reconciliation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReconcileResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/api/v1/verify":{"post":{"tags":["Verification"],"summary":"Verify a claim against evidence","description":"Determine whether a claim is supported by supplied evidence. Deterministic (no LLM required); customer text is treated strictly as data and injection attempts are ignored. Returns verified | unsupported | contradicted | insufficient_evidence with the supporting/contradicting evidence and a confidence score.","operationId":"verify","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyInput"},"examples":{"verifiedBalance":{"summary":"A balance claim confirmed by an invoice amount","value":{"claim":"Customer owes $47,250","evidence":[{"source":"billing","record_id":"inv_881","field":"amount","value":47250}]}}}}}},"responses":{"200":{"description":"Verification result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/api/v1/revenue-leak":{"post":{"tags":["Revenue Leakage"],"summary":"Detect possible revenue leakage","description":"Analyze orders, invoices, payments, and credits for possible revenue leakage: missing invoices, amount mismatches, underpayments, duplicates, and status conflicts. Every monetary conclusion traces to supplied numbers; exposure is reported cautiously as potential vs verified.","operationId":"revenueLeak","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevenueLeakInput"},"examples":{"orderWithoutInvoice":{"summary":"A won order that was never invoiced","value":{"orders":[{"order_id":"ORD-1","amount":18000,"status":"won"}],"invoices":[],"payments":[]}}}}}},"responses":{"200":{"description":"Revenue-leak analysis result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevenueLeakResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/api/health":{"get":{"tags":["System"],"summary":"Health check","operationId":"getHealth","security":[],"responses":{"200":{"description":"Service health","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Provide your API key as a Bearer token: `Authorization: Bearer stx_live_...`"}},"schemas":{"LeadInput":{"type":"object","required":["status","lead_age_days"],"properties":{"lead_id":{"type":"string","maxLength":200,"description":"Your identifier, echoed back on the response."},"industry":{"type":"string","enum":["hvac","plumbing","electrical","roofing","automotive","b2b_sales","generic"],"default":"generic"},"status":{"type":"string","enum":["new","contacted","quote_requested","estimate_sent","proposal_sent","negotiating","no_response","closed_won","closed_lost","opted_out"]},"lead_age_days":{"type":"integer","minimum":0,"description":"Days since the lead was created."},"last_contact_days":{"type":"integer","minimum":0},"contact_attempts":{"type":"integer","minimum":0},"estimate_value":{"type":"number","minimum":0},"source":{"type":"string","maxLength":120},"explicit_rejection":{"type":"boolean"},"opted_out":{"type":"boolean"},"previous_customer":{"type":"boolean"},"prior_engagement":{"type":"boolean"},"invalid_contact":{"type":"boolean"},"duplicate":{"type":"boolean"},"closed_lost_reason":{"type":"string","maxLength":500},"repeat_service":{"type":"boolean"},"first_name":{"type":"string","maxLength":120}}},"BatchInput":{"type":"object","required":["leads"],"properties":{"leads":{"type":"array","minItems":1,"maxItems":1000,"items":{"$ref":"#/components/schemas/LeadInput"}}}},"RecoveryResult":{"type":"object","properties":{"request_id":{"type":"string"},"lead_id":{"type":["string","null"]},"recovery_score":{"type":"integer","minimum":0,"maximum":100},"priority":{"type":"string","enum":["high","medium","low"]},"recommended_action":{"type":"string","enum":["follow_up","nurture","deprioritize","archive"]},"recommended_channel":{"type":"string","enum":["sms","email","phone","none"]},"recommended_timing":{"type":"string","enum":["today","this_week","this_month","none"]},"reason":{"type":"string"},"suggested_message":{"type":"string"},"confidence":{"type":"number","minimum":0,"maximum":1},"factors":{"type":"array","items":{"type":"object","properties":{"factor":{"type":"string"},"impact":{"type":"string","enum":["positive","negative","neutral"]},"score_effect":{"type":"integer"},"detail":{"type":"string"}}}},"scoring_version":{"type":"string"}}},"ReconcileInput":{"type":"object","required":["source_a","source_b","matching"],"properties":{"source_a":{"$ref":"#/components/schemas/ReconcileSource"},"source_b":{"$ref":"#/components/schemas/ReconcileSource"},"matching":{"type":"object","required":["primary_keys"],"properties":{"primary_keys":{"type":"array","items":{"type":"string"},"minItems":1},"secondary_keys":{"type":"array","items":{"type":"string"}},"compare_fields":{"type":"array","items":{"type":"string"}},"amount_field":{"type":"string","description":"Field used to compute financial exposure."},"date_fields":{"type":"array","items":{"type":"string"}},"status_fields":{"type":"array","items":{"type":"string"}}}}}},"ReconcileSource":{"type":"object","required":["name","records"],"properties":{"name":{"type":"string"},"records":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"ReconcileResult":{"type":"object","properties":{"request_id":{"type":"string"},"status":{"type":"string","enum":["completed"]},"summary":{"type":"object","properties":{"source_a_name":{"type":"string"},"source_b_name":{"type":"string"},"source_a_count":{"type":"integer"},"source_b_count":{"type":"integer"},"records_processed":{"type":"integer"},"exact_matches":{"type":"integer"},"probable_matches":{"type":"integer"},"conflicts":{"type":"integer"},"duplicates":{"type":"integer"},"unmatched_source_a":{"type":"integer"},"unmatched_source_b":{"type":"integer"},"needs_review":{"type":"integer"},"processing_time_ms":{"type":"integer"}}},"matches":{"type":"array","items":{"type":"object","properties":{"classification":{"type":"string","enum":["exact_match","probable_match","unmatched","conflict","duplicate","needs_review"]},"confidence":{"type":"number","minimum":0,"maximum":1},"matched_on":{"type":"string","enum":["primary","secondary","none"]},"keys":{"type":"array","items":{"type":"string"}},"key_value":{"type":["string","null"]},"source_a_index":{"type":["integer","null"]},"source_b_index":{"type":["integer","null"]},"field_diffs":{"type":"array","items":{"type":"object"}}}}},"findings":{"type":"array","items":{"type":"object"}},"financial_exposure":{"type":["object","null"],"properties":{"field":{"type":"string"},"currency":{"type":["string","null"]},"net_difference":{"type":"number"},"absolute_exposure":{"type":"number"},"items":{"type":"array","items":{"type":"object"}}}},"usage":{"type":"object","properties":{"records_processed":{"type":"integer"}}}}},"BatchResult":{"type":"object","properties":{"request_id":{"type":"string"},"results":{"type":"array","items":{"$ref":"#/components/schemas/RecoveryResult"}},"summary":{"type":"object","properties":{"total_leads":{"type":"integer"},"high_priority_count":{"type":"integer"},"medium_priority_count":{"type":"integer"},"low_priority_count":{"type":"integer"},"total_pipeline_value":{"type":"number"},"high_priority_pipeline_value":{"type":"number"},"processing_time_ms":{"type":"integer"}}}}},"VerifyInput":{"type":"object","required":["claim"],"properties":{"claim":{"type":"string","maxLength":5000,"description":"The claim to verify. Treated as data, never as instructions."},"evidence":{"type":"array","description":"Supplied evidence items. Only these values are ever used; nothing is fabricated.","items":{"type":"object","required":["value"],"properties":{"source":{"type":"string"},"record_id":{"type":["string","null"]},"field":{"type":"string"},"value":{}}}}}},"VerifyResult":{"type":"object","properties":{"request_id":{"type":"string"},"result":{"type":"string","enum":["verified","unsupported","contradicted","insufficient_evidence"]},"supported":{"type":"boolean"},"confidence":{"type":"number","minimum":0,"maximum":1},"evidence":{"type":"array","items":{"type":"object"}},"contradictions":{"type":"array","items":{"type":"object"}},"missing_evidence":{"type":"array","items":{"type":"string"}},"injection_detected":{"type":"boolean","description":"True when injection-like content was seen and ignored."},"reasoning":{"type":"string"}}},"RevenueLeakInput":{"type":"object","description":"Provide at least one of orders, invoices, payments, or credits.","properties":{"orders":{"type":"array","items":{"type":"object","additionalProperties":true}},"invoices":{"type":"array","items":{"type":"object","additionalProperties":true}},"payments":{"type":"array","items":{"type":"object","additionalProperties":true}},"credits":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"RevenueLeakResult":{"type":"object","properties":{"request_id":{"type":"string"},"status":{"type":"string","enum":["completed"]},"summary":{"type":"object","properties":{"records_analyzed":{"type":"integer"},"findings":{"type":"integer"},"processing_time_ms":{"type":"integer"}}},"financial_exposure":{"type":["object","null"],"properties":{"potential":{"type":"number"},"verified":{"type":"number"},"currency":{"type":["string","null"]}}},"findings":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"message":{"type":"string"},"monetary_class":{"type":["string","null"]},"amount":{"type":["number","null"]},"currency":{"type":["string","null"]},"confidence":{"type":"number"},"evidence":{"type":"array","items":{"type":"object"}},"challenges":{"type":"array","items":{"type":"string"}}}}}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"request_id":{"type":"string"}}}}}},"responses":{"Error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}