ApexIntermediatebatchcalloutsintegration
Implement Database.Batchable with AllowsCallouts for external enrichment
Real World Scenario
Nightly job enriches 100k Lead records with external firmographic API. Batch execute must callout per chunk without exceeding callout limits.
Expected Answer
• implements Database.Batchable<SObject>, Database.AllowsCallouts
• Scope size tuned to callout limit: max 100 callouts per execute
• Batch callouts in execute only—not in start or finish without AllowsCallouts
• HttpCalloutMock in test with Test.setMock before execute simulation
• Partial success: log failed Lead IDs for retry batch filtering Failed__c=true
• Named Credential for API auth; timeout and retry in callout utility
• Finish method emails summary: enriched, failed, skipped counts
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. implements Database.Batchable<SObject>, Database.AllowsCallouts. Scope size tuned to callout limit: max 100 callouts per execute. Pick based on your integration pattern and team capability. Batch callouts need scope math: callout limit divided by callouts per record equals max scope. Balance speed of delivery with maintainability.
Architect Perspective
Batch callouts need scope math: callout limit divided by callouts per record equals max scope.