### Install LendIQ Node.js SDK Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Install the LendIQ SDK using npm. This package has zero runtime dependencies and requires Node.js version 20 or higher. ```bash npm install @lendworks/lendiq ``` -------------------------------- ### Quick Start Workflow: Create Deal and Upload Document Source: https://context7.com/thornebridge/lendiq-node/llms.txt This snippet demonstrates a one-step process for creating a deal and uploading a document simultaneously. It's ideal for rapid onboarding and initial data ingestion. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // One-step deal creation with document upload const result = await client.deals.quickStart({ business_name: "Quick Test LLC", file: "./statement.pdf", document_type: "bank_statement", idempotency_key: "quick-start-test-1", }); console.log(result.deal_id); // New deal created console.log(result.document_id); // Document queued for processing console.log(result.status); // "processing" ``` -------------------------------- ### Client Initialization Source: https://context7.com/thornebridge/lendiq-node/llms.txt Initialize the LendIQ client with your API key and optional configuration for timeout, retries, and logging. ```APIDOC ## Client Initialization Initialize the LendIQ client with your API key and optional configuration for timeout, retries, and logging. ```typescript import { LendIQ } from "@lendworks/lendiq"; // Basic initialization const client = new LendIQ({ apiKey: "liq_live_your_api_key" }); // Advanced configuration const advancedClient = new LendIQ({ apiKey: "liq_live_your_api_key", baseUrl: "https://api.lendiq.com", // default API endpoint timeout: 30_000, // request timeout in ms maxRetries: 2, // retry count for transient errors logger: console, // enable debug logging geminiModel: "gemini-2.0-flash-exp", // override extraction model }); // Timeout constants for different operation types console.log(LendIQ.TIMEOUT_READ); // 10_000ms for reads console.log(LendIQ.TIMEOUT_WRITE); // 30_000ms for writes console.log(LendIQ.TIMEOUT_UPLOAD); // 120_000ms for uploads console.log(LendIQ.TIMEOUT_REPORT); // 300_000ms for reports ``` ``` -------------------------------- ### Initialize LendIQ Client Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Configure the LendIQ client with your API key and optional settings like base URL, timeouts, and retry counts. Debugging can be enabled with a logger. ```typescript const client = new LendIQ({ apiKey: "liq_live_...", // required baseUrl: "https://iq.lend.works", // default timeout: 30_000, // default (ms) maxRetries: 2, // default logger: console, // optional debug logging }); ``` -------------------------------- ### Create Deal and Upload Statement with LendIQ SDK Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Instantiate the client with your API key, create a new deal, upload a bank statement PDF, and retrieve the underwriting results. Requires Node.js 20+ and the @lendworks/lendiq package. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live..." }); const deal = await client.deals.create({ business_name: "Acme Trucking LLC" }); await client.documents.upload(deal.id, "./statements/chase_jan.pdf"); const result = await client.deals.get(deal.id); console.log(result.recommendation.decision); // "approved" ``` -------------------------------- ### Initialize LendIQ Client Source: https://context7.com/thornebridge/lendiq-node/llms.txt Initialize the LendIQ client with your API key. Advanced configuration options include baseUrl, timeout, maxRetries, logger, and geminiModel. Timeout constants for different operation types are also available. ```typescript import { LendIQ } from "@lendworks/lendiq"; // Basic initialization const client = new LendIQ({ apiKey: "liq_live_your_api_key" }); // Advanced configuration const advancedClient = new LendIQ({ apiKey: "liq_live_your_api_key", baseUrl: "https://api.lendiq.com", // default API endpoint timeout: 30_000, // request timeout in ms maxRetries: 2, // retry count for transient errors logger: console, // enable debug logging geminiModel: "gemini-2.0-flash-exp", // override extraction model }); // Timeout constants for different operation types console.log(LendIQ.TIMEOUT_READ); // 10_000ms for reads console.log(LendIQ.TIMEOUT_WRITE); // 30_000ms for writes console.log(LendIQ.TIMEOUT_UPLOAD); // 120_000ms for uploads console.log(LendIQ.TIMEOUT_REPORT); // 300_000ms for reports ``` -------------------------------- ### Accessing Deal Sub-Resources Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Demonstrates how to access and interact with sub-resources associated with a deal, such as comments, assignments, and documents. ```typescript client.deals.comments.list(dealId); // threaded discussion ``` ```typescript client.deals.assignments.create(dealId); // assign reviewers ``` ```typescript client.deals.docRequests.create(dealId); // request missing docs ``` ```typescript client.deals.timeline.list(dealId); // full activity history ``` ```typescript client.deals.users.search({ q: "jane" }); // find team members ``` -------------------------------- ### Retrieve Deal Details with LendIQ SDK Source: https://context7.com/thornebridge/lendiq-node/llms.txt Fetches comprehensive deal analysis including financial metrics, health scores, and underwriting recommendations. Requires a valid API key for client initialization. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); const detail = await client.deals.get(12345); // Business information console.log(detail.business.business_name); // "Acme Trucking LLC" console.log(detail.business.industry); // "Transportation" console.log(detail.ai_summary); // AI-generated summary // Financial metrics console.log(detail.financials.avg_monthly_deposits); // 48500.00 console.log(detail.financials.avg_daily_balance); // 16215.30 console.log(detail.financials.total_deposits); // 145500.00 console.log(detail.financials.negative_balance_days); // 2 // NSF/Overdraft analysis console.log(detail.nsf_overdraft.nsf_fee_count); // 1 console.log(detail.nsf_overdraft.overdraft_fee_total); // 35.00 // Health scoring (12 sub-factors) console.log(detail.health.health_score); // 78.5 console.log(detail.health.health_grade); // "B" for (const [name, factor] of Object.entries(detail.health.factors || {})) { console.log(`${name}: ${factor.score}/${factor.max} (weight: ${factor.weight})`); } // Underwriting recommendation console.log(detail.recommendation?.decision); // "approved" console.log(detail.recommendation?.confidence); // 0.87 console.log(detail.recommendation?.risk_tier); // "tier_2" console.log(detail.recommendation?.advance_amount); // 50000 console.log(detail.recommendation?.factor_rate); // 1.35 console.log(detail.recommendation?.est_daily_payment); // 375.00 console.log(detail.recommendation?.risk_factors); // ["high_mca_exposure"] console.log(detail.recommendation?.strengths); // ["consistent_deposits"] // MCA position detection console.log(detail.mca?.positions_detected); // 2 console.log(detail.mca?.total_daily_obligation); // 450.00 console.log(detail.mca?.mca_credit_score); // 72 console.log(detail.mca?.fundability_grade); // "B" ``` -------------------------------- ### Create a New Deal Source: https://context7.com/thornebridge/lendiq-node/llms.txt Create a new deal by providing business information. Deals act as containers for documents and analysis results. An idempotency key is recommended for preventing duplicate requests. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); const deal = await client.deals.create({ business_name: "Acme Trucking LLC", dba_name: "Acme Transport", owner_name: "John Smith", industry: "Transportation", entity_type: "LLC", ein: "12-3456789", business_start_date: "2018-06-15", business_address_street: "123 Main Street", business_address_city: "Chicago", business_address_state: "IL", business_address_zip: "60601", funding_amount_requested: 75000, self_reported_monthly_revenue: 45000, existing_mca_positions: 2, source_type: "broker", broker_name: "Jane Doe", broker_email: "jane@brokerco.com", idempotency_key: "unique-request-id-123", }); console.log(deal.id); // 12345 console.log(deal.business_name); // "Acme Trucking LLC" console.log(deal.status); // "pending_documents" console.log(deal.health_grade); // null (no documents yet) ``` -------------------------------- ### Perform Admin Operations with LendIQ SDK Source: https://context7.com/thornebridge/lendiq-node/llms.txt Use this snippet to access system health, view error logs, retrieve usage analytics, manage DLQ entries, and configure pipeline settings. Ensure the LendIQ client is initialized with a valid API key. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Check system health const health = await client.admin.health(); console.log(health.status); // "healthy" console.log(health.api_version); console.log(health.services); // {database: "ok", queue: "ok", ...} // View error logs const errors = await client.admin.errors({ severity: "error", page: 1, per_page: 100, }); for (const err of errors.data) { console.log(err.timestamp, err.message, err.request_id); } // Usage analytics const summary = await client.admin.usageSummary({ days: 30 }); console.log(summary.total_documents); console.log(summary.total_pages); console.log(summary.total_cost_usd); const daily = await client.admin.usageDaily({ days: 7 }); for (const day of daily.data) { console.log(day.date, day.documents, day.cost_usd); } const models = await client.admin.usageModels({ days: 30 }); for (const model of models.data) { console.log(model.model_name, model.requests, model.tokens); } // DLQ (Dead Letter Queue) management const dlq = await client.admin.dlqList({ status: "failed", task_name: "document_processing", }); for (const entry of dlq.data) { console.log(entry.id, entry.task_name, entry.error_message); } // Retry a DLQ entry await client.admin.dlqRetry(12345); // Discard a DLQ entry await client.admin.dlqDiscard(12345); // Pipeline settings const settings = await client.admin.pipelineSettings(); console.log(settings.default_gemini_model); console.log(settings.auto_classify); await client.admin.updatePipelineSettings({ default_gemini_model: "gemini-2.0-flash-exp", auto_classify: true, parallel_extraction: true, }); // Constraints management const constraints = await client.admin.getConstraints(); await client.admin.updateConstraints({ max_file_size_mb: 50, max_pages_per_document: 100, }); ``` -------------------------------- ### Creating a Deal Source: https://context7.com/thornebridge/lendiq-node/llms.txt Create a new deal with business information to begin the underwriting process. Deals serve as containers for documents and analysis results. ```APIDOC ## Creating a Deal Create a new deal with business information to begin the underwriting process. Deals serve as containers for documents and analysis results. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); const deal = await client.deals.create({ business_name: "Acme Trucking LLC", dba_name: "Acme Transport", owner_name: "John Smith", industry: "Transportation", entity_type: "LLC", ein: "12-3456789", business_start_date: "2018-06-15", business_address_street: "123 Main Street", business_address_city: "Chicago", business_address_state: "IL", business_address_zip: "60601", funding_amount_requested: 75000, self_reported_monthly_revenue: 45000, existing_mca_positions: 2, source_type: "broker", broker_name: "Jane Doe", broker_email: "jane@brokerco.com", idempotency_key: "unique-request-id-123", }); console.log(deal.id); // 12345 console.log(deal.business_name); // "Acme Trucking LLC" console.log(deal.status); // "pending_documents" console.log(deal.health_grade); // null (no documents yet) ``` ``` -------------------------------- ### Upload Documents to a Deal Source: https://context7.com/thornebridge/lendiq-node/llms.txt Upload financial documents such as bank statements, tax returns, or voided checks to a deal. Documents can be uploaded from a file path, a Buffer, or in bulk. Options include specifying document type, idempotency key, and extraction model. ```typescript import { LendIQ } from "@lendworks/lendiq"; import { readFileSync } from "fs"; const client = new LendIQ({ apiKey: "liq_live_..." }); const dealId = 12345; // Upload from file path const doc1 = await client.documents.upload( dealId, "./statements/chase_jan_2024.pdf" ); console.log(doc1.id); // 67890 console.log(doc1.status); // "classifying" // Upload with options const doc2 = await client.documents.upload( dealId, "./statements/bofa_feb_2024.pdf", { documentType: "bank_statement", idempotencyKey: "upload-bofa-feb", geminiModel: "gemini-2.0-flash-exp", } ); // Upload from Buffer const pdfBuffer = readFileSync("./tax_return_2023.pdf"); const doc3 = await client.documents.upload(dealId, pdfBuffer, { filename: "tax_return_2023.pdf", documentType: "tax_return", }); // Bulk upload multiple files const bulkResult = await client.documents.uploadBulk(dealId, [ "./statements/march.pdf", "./statements/april.pdf", "./statements/may.pdf", ]); console.log(bulkResult.total); // 3 console.log(bulkResult.queued); // 3 console.log(bulkResult.results); // [{filename, status, document_id}...] ``` -------------------------------- ### Perform Bulk Ingest of Deals Source: https://context7.com/thornebridge/lendiq-node/llms.txt Upload files and metadata to ingest deals from external systems. Use an idempotency key to prevent duplicate processing. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Create ingest batch with files and metadata const ingest = await client.ingest.create({ filePaths: [ "./uploads/acme_statement_1.pdf", "./uploads/acme_statement_2.pdf", "./uploads/acme_tax_return.pdf", ], metadata: { external_reference: "CRM-12345", business_name: "Acme Trucking LLC", owner_name: "John Smith", funding_amount_requested: 75000, source_type: "salesforce", }, documentType: "bank_statement", // override auto-classification idempotencyKey: "ingest-acme-batch-1", }); console.log(ingest.batch_id); // "batch_xyz789" console.log(ingest.deal_id); // 12345 (matched or created) console.log(ingest.documents_queued); // 3 // Check batch status const status = await client.ingest.getBatch(ingest.batch_id); console.log(status.status); // "processing" | "completed" | "failed" console.log(status.documents_completed); console.log(status.documents_failed); ``` -------------------------------- ### Export Reports with LendIQ SDK Source: https://context7.com/thornebridge/lendiq-node/llms.txt Use these methods to export deal and document data as CSV or PDF files. Ensure the output is converted to a Buffer before writing to the filesystem. ```typescript import { LendIQ } from "@lendworks/lendiq"; import { writeFileSync } from "fs"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Export deal as CSV const dealCsv = await client.exports.dealCsv(12345); writeFileSync("deal_12345.csv", Buffer.from(dealCsv)); // Export deal as PDF report const dealPdf = await client.exports.dealPdf(12345); writeFileSync("deal_12345_report.pdf", Buffer.from(dealPdf)); // Export document transactions as CSV const docCsv = await client.exports.documentCsv(67890); writeFileSync("document_67890_transactions.csv", Buffer.from(docCsv)); // Download original PDF with annotations const docPdf = await client.exports.documentPdf(67890); writeFileSync("document_67890.pdf", Buffer.from(docPdf)); // Bulk export deals const bulkCsv = await client.deals.exportCsv({ status: "ready", q: "trucking", }); writeFileSync("ready_deals.csv", Buffer.from(bulkCsv)); ``` -------------------------------- ### Manage API Keys Source: https://context7.com/thornebridge/lendiq-node/llms.txt Create, list, and revoke API keys. Note that the full API key value is only returned upon creation. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // List all API keys const keys = await client.keys.list(); for (const key of keys.data) { console.log(key.id, key.name, key.prefix, key.last_used_at); } // Create a new API key const newKey = await client.keys.create({ name: "Production Integration", scopes: "deals:read,deals:write,documents:write", expires_in_days: 365, }); console.log(newKey.api_key); // "liq_live_..." - only shown once! console.log(newKey.id); console.log(newKey.expires_at); // Revoke an API key await client.keys.revoke(456); ``` -------------------------------- ### Stream Real-Time Events for Deals and Organization Source: https://context7.com/thornebridge/lendiq-node/llms.txt Watch document processing in real-time using Server-Sent Events (SSE) without polling. Supports streaming events for a specific deal, a document within a deal, the entire organization, or batch processing. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Stream events for a specific deal for await (const event of client.events.stream(12345)) { console.log(`Event: ${event.event}`); switch (event.event) { case "stage": console.log(`Processing stage: ${event.data}`); // "classifying" → "extracting" → "screening" → "scoring" break; case "progress": const progress = event.json(); console.log(`Progress: ${progress.percent}%`); break; case "document_completed": const docData = event.json(); console.log(`Document ${docData.document_id} completed`); break; case "complete": console.log("Analysis complete!"); break; case "error": console.error(`Error: ${event.data}`); break; } } // Stream events for a specific document within a deal for await (const event of client.events.stream(12345, { documentId: 67890 })) { console.log(event.event, event.data); } // Stream all events for the organization for await (const event of client.events.streamOrg()) { const data = event.json(); console.log(`Org event: ${event.event}`, data); } // Stream batch processing progress for await (const event of client.events.streamBatch("batch_abc123")) { console.log(event.event, event.json()); } ``` -------------------------------- ### Track API Usage with LendIQ SDK Source: https://context7.com/thornebridge/lendiq-node/llms.txt Monitor your API usage and processing time statistics. This snippet retrieves usage summaries and detailed processing time metrics for a specified period. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Get usage summary for current user/org const usage = await client.usage.summary(); console.log(usage.documents_processed); console.log(usage.pages_processed); console.log(usage.api_calls); console.log(usage.current_period_start); console.log(usage.current_period_end); console.log(usage.usage_limit); console.log(usage.usage_remaining); // Get processing time statistics const times = await client.usage.processingTimes({ days: 30 }); console.log(times.avg_processing_time_ms); console.log(times.p50_processing_time_ms); console.log(times.p95_processing_time_ms); console.log(times.p99_processing_time_ms); ``` -------------------------------- ### Configure Webhook Endpoints Source: https://context7.com/thornebridge/lendiq-node/llms.txt Manage webhook settings, including URL registration, event subscriptions, and delivery history monitoring. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Configure webhook endpoint const config = await client.webhooks.updateConfig({ url: "https://api.yourapp.com/webhooks/lendiq", secret: "whsec_your_signing_secret", events: [ "deal.created", "deal.ready", "deal.decision_made", "document.completed", "document.failed", ], }); console.log(config.url); console.log(config.events); // Test webhook connectivity const testResult = await client.webhooks.test(); console.log(testResult.success); // true console.log(testResult.status_code); // 200 console.log(testResult.response_time_ms); // Get current configuration const currentConfig = await client.webhooks.getConfig(); // List webhook delivery history const deliveries = await client.webhooks.listDeliveries({ page: 1, per_page: 50, success: false, // show only failed deliveries }); for (const delivery of deliveries.data) { console.log(delivery.id, delivery.event_type, delivery.status_code); } // Retry a failed delivery await client.webhooks.retryDelivery(12345); // Delete webhook configuration await client.webhooks.deleteConfig(); ``` -------------------------------- ### Create and Manage Deal Shares Source: https://context7.com/thornebridge/lendiq-node/llms.txt Generate shareable links for external stakeholders and manage existing shares. View modes can be set to either 'summary' or 'full'. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Create a share link const share = await client.shares.create(12345, { view_mode: "summary", // "summary" | "full" expires_in_days: 7, }); console.log(share.id); // 999 console.log(share.token); // "share_abc123" console.log(share.url); // "https://app.lendiq.com/share/share_abc123" console.log(share.expires_at); // "2024-04-01T00:00:00Z" // List all shares for a deal const shares = await client.shares.list(12345); for (const s of shares.data) { console.log(s.id, s.view_mode, s.created_at, s.expires_at); } // Revoke a share link await client.shares.revoke(12345, 999); ``` -------------------------------- ### Monitor SAM.gov Profiles Source: https://context7.com/thornebridge/lendiq-node/llms.txt Configure search profiles to monitor government contract opportunities and export results to CSV. ```typescript import { LendIQ } from "@lendworks/lendiq"; import { writeFileSync } from "fs"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Create a SAM search profile const profile = await client.samProfiles.create({ name: "Illinois Transportation Contractors", search_criteria: { naics_codes: ["484110", "484121"], states: ["IL"], min_entity_status: "active", }, auto_fetch_enabled: true, fetch_frequency_days: 7, }); // List all profiles const profiles = await client.samProfiles.list(); // Get profile details const detail = await client.samProfiles.get(profile.id); // Update a profile await client.samProfiles.update(profile.id, { search_criteria: { ...profile.search_criteria, states: ["IL", "WI", "IN"], }, }); // Add a watcher to be notified of new entities await client.samProfiles.addWatcher(profile.id, { user_id: 123, notify_email: true, notify_slack: true, }); // Remove a watcher await client.samProfiles.removeWatcher(profile.id, 123); // Trigger a manual SAM fetch const fetchRun = await client.samProfiles.trigger(profile.id); console.log(fetchRun.id); console.log(fetchRun.status); // List fetch runs for a profile const fetchRuns = await client.samProfiles.listRuns(profile.id); // Export profile results as CSV const csv = await client.samProfiles.exportCsv(profile.id); writeFileSync("sam_results.csv", Buffer.from(csv)); // Export all SAM entities const allEntities = await client.samProfiles.exportEntitiesCsv(); writeFileSync("all_sam_entities.csv", Buffer.from(allEntities)); // Delete a profile await client.samProfiles.delete(profile.id); ``` -------------------------------- ### Retrieve Document Details with LendIQ SDK Source: https://context7.com/thornebridge/lendiq-node/llms.txt Fetches detailed document analysis including extraction results, tampering detection, and specific analysis for bank statements, driver's licenses, and voided checks. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); const doc = await client.documents.get(67890); // Basic metadata console.log(doc.id); // 67890 console.log(doc.filename); // "chase_jan_2024.pdf" console.log(doc.document_type); // "bank_statement" console.log(doc.status); // "completed" console.log(doc.extraction_method); // "gemini_native_pdf" console.log(doc.extraction_confidence); // 0.94 // Bank statement extraction console.log(doc.bank_name); // "Chase" console.log(doc.account_holder_name); // "Acme Trucking LLC" console.log(doc.statement_start_date); // "2024-01-01" console.log(doc.statement_end_date); // "2024-01-31" console.log(doc.opening_balance); // 12500.00 console.log(doc.closing_balance); // 18750.00 // Document integrity / tampering detection console.log(doc.integrity?.tampering_risk_level); // "clean" console.log(doc.integrity?.tampering_flags); // [] console.log(doc.integrity?.font_families_detected); // 2 // Financial analysis (bank statements) console.log(doc.analysis?.average_daily_balance); // 16215.30 console.log(doc.analysis?.total_deposits); // 48920.00 console.log(doc.analysis?.deposit_count); // 24 console.log(doc.analysis?.nsf_fee_count); // 0 console.log(doc.analysis?.health_score); // 82.5 console.log(doc.analysis?.health_grade); // "B+" // Driver's license analysis if (doc.driver_license_analysis) { console.log(doc.driver_license_analysis.full_name); // "John Smith" console.log(doc.driver_license_analysis.date_of_birth); // "1985-03-15" console.log(doc.driver_license_analysis.expiration_date); // "2028-06-15" console.log(doc.driver_license_analysis.address_state); // "IL" } // Voided check analysis if (doc.voided_check_analysis) { console.log(doc.voided_check_analysis.bank_name); // "Chase" console.log(doc.voided_check_analysis.routing_number); // "021000021" console.log(doc.voided_check_analysis.is_voided); // true } ``` -------------------------------- ### Configure CRM Integration Source: https://context7.com/thornebridge/lendiq-node/llms.txt Manage bidirectional sync with CRM systems, including field mapping, connection testing, and sync history retrieval. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Configure CRM connection const config = await client.crm.updateConfig("salesforce", { instance_url: "https://mycompany.salesforce.com", client_id: "your_client_id", client_secret: "your_client_secret", refresh_token: "your_refresh_token", sync_direction: "bidirectional", auto_create_deals: true, }); // Test CRM connection const test = await client.crm.test("salesforce"); console.log(test.success); // true console.log(test.latency_ms); // 245 // Configure field mapping await client.crm.updateFieldMapping("salesforce", { mappings: { "business_name": "Account.Name", "owner_name": "Contact.Name", "funding_amount_requested": "Opportunity.Amount", "health_score": "Opportunity.LendIQ_Score__c", "decision": "Opportunity.Stage", }, }); // Get current field mapping const mapping = await client.crm.getFieldMapping("salesforce"); // Trigger manual sync for a deal const sync = await client.crm.sync({ deal_id: 12345 }); console.log(sync.sync_id); console.log(sync.status); // View sync history const syncLog = await client.crm.syncLog({ deal_id: 12345, page: 1, per_page: 50, }); for (const entry of syncLog.data) { console.log(entry.direction, entry.status, entry.records_synced); } // Get and delete config const currentConfig = await client.crm.getConfig("salesforce"); await client.crm.deleteConfig("salesforce"); ``` -------------------------------- ### List Deals with Filtering and Pagination Source: https://context7.com/thornebridge/lendiq-node/llms.txt List deals with support for filtering, sorting, and pagination. Use auto-pagination for iterating over all results. Advanced filtering includes industry, funding amounts, and date ranges. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Basic list with pagination const response = await client.deals.list({ status: "ready", page: 1, per_page: 25, sort: "created_at", order: "desc", }); console.log(response.meta.total); // 156 console.log(response.meta.total_pages); // 7 console.log(response.data.length); // 25 for (const deal of response.data) { console.log(deal.id, deal.business_name, deal.health_grade); } // Advanced filtering const filtered = await client.deals.list({ status: "ready", health_grade: "A", industry: "Transportation", min_funding: 25000, max_funding: 100000, date_from: "2024-01-01", date_to: "2024-03-31", search: "trucking", }); // Auto-pagination - iterate over all deals without page math for await (const deal of client.deals.listAll({ status: "ready" })) { console.log(deal.business_name, deal.health_grade, deal.avg_monthly_deposits); // Automatically fetches next page when needed } // Get deal statistics const stats = await client.deals.stats(); console.log(stats.total); // 1250 console.log(stats.by_status); // {pending: 45, ready: 890, ...} console.log(stats.total_volume); // 52500000.00 console.log(stats.avg_health); // 74.3 ``` -------------------------------- ### Manage LVL Business Validation Source: https://context7.com/thornebridge/lendiq-node/llms.txt Use the LendIQ Validation Layer to create validation runs, manage call queues, and perform specific deal validations. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Create a validation run const run = await client.lvl.createRun({ filters: { min_health_score: 60, industries: ["transportation", "retail"], states: ["IL", "CA", "TX"], }, }); console.log(run.id); console.log(run.status); // "pending" | "running" | "completed" // List validation runs const runs = await client.lvl.listRuns({ page: 1, per_page: 20 }); // Get run details const runDetail = await client.lvl.getRun(run.id); // Cancel a running validation await client.lvl.cancelRun(run.id); // Get call queue - prioritized list of businesses to contact const queue = await client.lvl.callQueue({ tier: "high_priority", state: "IL", industry: "transportation", min_score: 70, include_disqualified: false, }); for (const item of queue.data) { console.log(item.deal_id, item.business_name, item.priority_score); } // Validate a specific deal const result = await client.lvl.validate(12345, { check_sos: true, // Secretary of State check_sam: true, // SAM.gov check_web: true, // Web presence }); console.log(result.status); console.log(result.sos_status); console.log(result.verification_score); // Get validation result for a deal const dealResult = await client.lvl.getResult(12345); // Get LVL statistics const stats = await client.lvl.stats(); console.log(stats.total_validated); console.log(stats.success_rate); ``` -------------------------------- ### Handle Document Reviews Source: https://context7.com/thornebridge/lendiq-node/llms.txt Manage human-in-the-loop workflows for reviewing, approving, or correcting document extractions. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // List documents pending review const reviews = await client.reviews.list({ status: "pending", page: 1, per_page: 50, }); for (const review of reviews.data) { console.log(review.document_id, review.confidence_tier, review.flags); } // Get detailed review for a document const detail = await client.reviews.get(67890); console.log(detail.document); console.log(detail.extracted_data); console.log(detail.confidence_breakdown); console.log(detail.fields_requiring_review); // Approve extraction as correct await client.reviews.approve(67890); // Submit corrections await client.reviews.correct(67890, { corrections: [ { field: "opening_balance", original_value: 12500.00, corrected_value: 12550.00, reason: "OCR misread digit", }, { field: "bank_name", original_value: "Chase Bank", corrected_value: "JPMorgan Chase", reason: "Standardize name", }, ], reviewer_notes: "Minor OCR corrections applied", }); ``` -------------------------------- ### Webhook Configuration API Source: https://context7.com/thornebridge/lendiq-node/llms.txt Endpoints for managing webhook settings, testing connectivity, and retrieving delivery history. ```APIDOC ## POST /webhooks/config ### Description Updates the webhook configuration, including the target URL, signing secret, and subscribed events. ### Method POST ### Endpoint /webhooks/config ### Request Body - **url** (string) - Required - The endpoint URL to receive webhooks. - **secret** (string) - Required - The signing secret for HMAC-SHA256 verification. - **events** (array) - Required - List of event types to subscribe to. ## POST /webhooks/test ### Description Tests the connectivity of the configured webhook endpoint. ### Method POST ### Endpoint /webhooks/test ### Response #### Success Response (200) - **success** (boolean) - Indicates if the test was successful. - **status_code** (number) - The HTTP status code returned by the endpoint. - **response_time_ms** (number) - The time taken for the request in milliseconds. ## GET /webhooks/deliveries ### Description Lists the history of webhook deliveries. ### Method GET ### Endpoint /webhooks/deliveries ### Query Parameters - **page** (number) - Optional - Page number for pagination. - **per_page** (number) - Optional - Number of items per page. - **success** (boolean) - Optional - Filter by delivery success status. ``` -------------------------------- ### Perform Instant PDF Analysis Source: https://context7.com/thornebridge/lendiq-node/llms.txt Analyze a single PDF file instantly without creating a deal. Useful for demos or quick assessments. The `visionFallback` option uses the vision API if native extraction fails. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Analyze a single file instantly (no data persistence) const result = await client.instant.analyze("./statement.pdf", { visionFallback: true, // use vision API if native extraction fails }); // Summary metrics console.log(result.summary.total_deposits); // 284500.00 console.log(result.summary.total_mca_positions); // 3 console.log(result.summary.avg_revenue_quality); // 0.82 // Per-file breakdown for (const file of result.results) { console.log(file.filename); // "statement.pdf" console.log(file.bank_name); // "Chase" console.log(file.nsf_count); // 1 console.log(file.mca_daily_obligation); // 250.00 console.log(file.health_grade); // "B" } // Submit feedback on analysis quality await client.instant.submitFeedback({ sessionId: result.session_id, filename: "statement.pdf", rating: "accurate", issueCategory: null, issueDetail: null, }); ``` -------------------------------- ### Manage Team Members Source: https://context7.com/thornebridge/lendiq-node/llms.txt Handle team invitations, role assignments, and account deactivation. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // List team members const team = await client.team.list(); for (const member of team.data) { console.log(member.id, member.email, member.role, member.status); } // Invite a new team member const invite = await client.team.invite({ email: "newuser@company.com", role: "underwriter", display_name: "Jane Smith", }); console.log(invite.invite_token); console.log(invite.expires_at); // Update a team member's role const updated = await client.team.update(123, { role: "admin", display_name: "Jane Smith (Senior)", }); // Deactivate a team member await client.team.deactivate(123); ``` -------------------------------- ### Uploading Documents Source: https://context7.com/thornebridge/lendiq-node/llms.txt Upload bank statements, tax returns, P&L statements, driver's licenses, or voided checks to a deal for automated analysis. ```APIDOC ## Uploading Documents Upload bank statements, tax returns, P&L statements, driver's licenses, or voided checks to a deal for automated analysis. ```typescript import { LendIQ } from "@lendworks/lendiq"; import { readFileSync } from "fs"; const client = new LendIQ({ apiKey: "liq_live_..." }); const dealId = 12345; // Upload from file path const doc1 = await client.documents.upload( dealId, "./statements/chase_jan_2024.pdf" ); console.log(doc1.id); // 67890 console.log(doc1.status); // "classifying" // Upload with options const doc2 = await client.documents.upload( dealId, "./statements/bofa_feb_2024.pdf", { documentType: "bank_statement", idempotencyKey: "upload-bofa-feb", geminiModel: "gemini-2.0-flash-exp", } ); // Upload from Buffer const pdfBuffer = readFileSync("./tax_return_2023.pdf"); const doc3 = await client.documents.upload(dealId, pdfBuffer, { filename: "tax_return_2023.pdf", documentType: "tax_return", }); // Bulk upload multiple files const bulkResult = await client.documents.uploadBulk(dealId, [ "./statements/march.pdf", "./statements/april.pdf", "./statements/may.pdf", ]); console.log(bulkResult.total); // 3 console.log(bulkResult.queued); // 3 console.log(bulkResult.results); // [{filename, status, document_id}...] ``` ``` -------------------------------- ### Configure Notification Integrations Source: https://context7.com/thornebridge/lendiq-node/llms.txt Manage external notification channels like Slack and Teams, including health checks and credential configuration. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // Check integration health const health = await client.integrations.health(); console.log(health.slack); // {connected: true, last_ping: "..."} console.log(health.teams); // {connected: false, error: "..."} // List all integrations const integrations = await client.integrations.list(); // Configure Slack integration const slack = await client.integrations.upsert("slack", { enabled: true, label: "Underwriting Channel", credentials: { webhook_url: "https://hooks.slack.com/services/T00/B00/xxx", channel: "#underwriting-alerts", }, }); // Test the integration const testResult = await client.integrations.test("slack"); console.log(testResult.success); console.log(testResult.message); // Delete an integration await client.integrations.delete("slack"); ``` -------------------------------- ### Manage Transactions Source: https://context7.com/thornebridge/lendiq-node/llms.txt Retrieve, filter, and correct transaction data associated with documents or deals. Use listAllForDeal for automatic pagination. ```typescript import { LendIQ } from "@lendworks/lendiq"; const client = new LendIQ({ apiKey: "liq_live_..." }); // List transactions for a document const docTxns = await client.transactions.listForDocument(67890, { page: 1, per_page: 100, type: "deposit", flagged: true, start_date: "2024-01-01", end_date: "2024-01-31", }); for (const txn of docTxns.data) { console.log(txn.date, txn.description, txn.amount, txn.category); } // List transactions for a deal (all documents combined) const dealTxns = await client.transactions.listForDeal(12345, { type: "withdrawal", }); // Auto-paginate through all transactions for await (const txn of client.transactions.listAllForDeal(12345)) { if (txn.flagged) { console.log(`Flagged: ${txn.description} - $${txn.amount}`); } } // Correct a transaction const corrected = await client.transactions.correct(67890, 11111, { category: "mca_payment", amount: 450.00, notes: "Confirmed MCA payment to ABC Funding", }); // View correction history const history = await client.transactions.corrections(11111); for (const correction of history.data) { console.log(correction.field, correction.old_value, correction.new_value); } ``` -------------------------------- ### Perform Instant Document Analysis Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Process PDFs instantly without account requirements or data persistence. ```typescript const result = await client.instant.analyze("./statement.pdf"); console.log(result.summary.total_deposits); // 284500.00 console.log(result.summary.total_mca_positions); // 3 console.log(result.summary.avg_revenue_quality); // 0.82 // Per-file breakdown for (const file of result.results) { console.log(file.bank_name, file.nsf_count, file.mca_daily_obligation); } ``` -------------------------------- ### Retrieve Typed Deal Data Source: https://github.com/thornebridge/lendiq-node/blob/main/README.md Access deal details with full IDE autocompletion and type safety for all fields and nested objects. ```typescript const detail = await client.deals.get(dealId); // IDE knows every field, every nested object, every type detail.health.health_score; // number detail.health.health_grade; // string detail.recommendation.decision; // "approved" | "conditional" | "declined" detail.recommendation.risk_factors; // string[] detail.recommendation.strengths; // string[] detail.financials.avg_monthly_deposits; // number detail.mca?.mca_credit_score; // number | undefined // 12 health sub-factors, individually scored and weighted for (const [name, factor] of Object.entries(detail.health.factors)) { console.log(`${name}: ${factor.score}/${factor.max} (weight: ${factor.weight})`); } ```