# Triggers ## Salesforce Trigger Webhook - [POST /v1/triggers/salesforce](https://developers.withlantern.com/openapi/triggers/salesforce_trigger_v1_triggers_salesforce_post.md): Handles instant enrichment on Salesforce record creation/updates via webhook. ## Overview The Salesforce Trigger API provides instant enrichment capabilities for Salesforce records through webhook-based triggers. It supports both real-time webhook processing and polling-based enrichment for comprehensive coverage of record changes. ## Request Body - object: Salesforce object type that triggered the event (Lead, Contact, Account, Opportunity) - ids: List of Salesforce record IDs that changed - event: Salesforce trigger event type (after_insert, after_update, after_undelete) - org_id: Salesforce organization ID ## Trigger Events - after_insert: Triggered when new records are created - after_update: Triggered when existing records are updated - after_undelete: Triggered when records are undeleted ## Response Fields - success: Boolean indicating request success - processed_count: Number of records processed - enrichment_jobs: List of enrichment job IDs created - workflow_status: Status of the enrichment workflow (started, queued, failed) - credits_consumed: Number of credits used - credits_remaining: Credits remaining in account - processing_time_ms: Processing time in milliseconds - cached: Whether result was from cache ## Enrichment Options ### Webhook Processing (Real-time) - Immediate Processing: Records are processed immediately upon webhook receipt - Platform Events: Uses Salesforce Platform Events for reliable delivery - Apex Callouts: Triggered via Apex callouts from Salesforce triggers - Low Latency: Near real-time enrichment with minimal delay ### Polling Processing (Fallback) - SOQL Queries: Polls Salesforce every 2 minutes for new/changed records - Watermark Tracking: Uses SystemModstamp and Id for efficient filtering - Batch Processing: Processes records in batches for optimal performance - Reliable Coverage: Ensures no records are missed even if webhooks fail ## Features - Dual Processing: Both webhook and polling support for comprehensive coverage - Automatic Enrichment: Triggers enrichment workflows based on object type - Job Tracking: Creates enrichment jobs for monitoring and debugging - Credit Management: Tracks credit consumption per enrichment job - Error Handling: Robust error handling with retry mechanisms - Audit Trail: Comprehensive logging for compliance and debugging ## Credit Usage Trigger processing consumes credits based on enrichment type: - Lead Enrichment: 2 credits per lead - Contact Enrichment: 1 credit per contact - Account Enrichment: 3 credits per account - Opportunity Enrichment: 1 credit per opportunity ## Polling Status - [GET /v1/triggers/polling/status](https://developers.withlantern.com/openapi/triggers/get_polling_status_v1_triggers_polling_status_get.md): Get the current status of polling-based enrichment. ## Overview This endpoint provides information about the current polling status, including last poll time, records processed, watermark value, and next scheduled poll. ## Response Fields - last_poll_time: ISO timestamp of last poll - records_processed: Number of records processed in last poll - watermark_value: Current watermark value - next_poll_time: ISO timestamp of next scheduled poll ## Use Cases - Monitor polling performance - Debug enrichment issues - Verify watermark progression - Check polling schedule