Great discussion on REST API vs Bulk API trade-offs. Here’s my perspective after implementing both for multiple large-scale marketing operations:
Bulk API Batch Processing - When to Use:
Bulk API is optimal when:
- Processing 10K+ records in a single operation
- Import timing is flexible (can tolerate 5-30 minute processing windows)
- Records are relatively clean with low error rates (under 5%)
- You have infrastructure to poll job status and parse result files
For your 10K-50K daily campaign member imports, Bulk API is the right choice. Here’s why:
-
Governor Limits: REST API has a 15K record per 24-hour limit for some operations. At 50K records, you’d exceed this immediately. Bulk API has much higher limits (10K batches, 100M records per 24 hours).
-
Performance: Bulk API processes records in parallel batches of 10K. Your 50K records would split into 5 batches processed simultaneously. Total time: 10-20 minutes typically. REST API with 200-record batches would require 250 sequential API calls - much slower.
Error Handling Strategies for Bulk API:
The asynchronous nature doesn’t mean poor error handling. Here’s a robust approach:
- Job Monitoring: Poll the Bulk API job status every 5-10 seconds until complete
- Result Processing: Download the result CSV which maps each input record to success/failure
- Error Classification: Parse errors into categories (validation, duplicate, field-level, system)
- Retry Logic: Failed records go into a retry queue with exponential backoff
- Reporting: Generate detailed error reports showing exactly which campaign members failed and why
This gives you the same granular error visibility as REST API, just asynchronously.
REST API Governor Limits - When It Still Makes Sense:
REST API remains valuable for:
- Real-time single record operations (under 200 records)
- Operations requiring immediate workflow triggers
- Complex upsert logic with external ID matching
- Scenarios where you need synchronous confirmation before proceeding
For your marketing campaign imports, consider a hybrid:
- Bulk API: Daily batch imports of 10K+ campaign members
- REST API: Real-time campaign member additions from web forms or events (under 100 records)
Campaign Member-Specific Considerations:
For duplicate handling with Bulk API:
// Use External ID matching on composite key
CampaignId + ContactId as External_Campaign_Member_ID__c
This enables upsert behavior in Bulk API, preventing duplicate errors. Create a formula field or use before-insert triggers to populate this composite key.
Recommended Architecture:
- Stage records in a queue/database with metadata (source, timestamp, priority)
- Aggregate records every 15-30 minutes into Bulk API jobs
- Process high-priority/real-time records via REST API immediately
- Monitor both API limit consumption and adjust batch timing dynamically
- Implement circuit breaker pattern if error rates exceed 10%
With proper error handling infrastructure, Bulk API provides superior throughput for your volumes while maintaining the error visibility you need. The 2-hour processing window is more than sufficient for Bulk API to handle 50K records with full error reporting.