The naive approach — call the API once per record in a loop — fails fast: governor limit of 100 callouts per transaction.
Better patterns:
- Batch API on the external side — if the external API supports batch endpoints, send all 100 in one call. Done.
- Async chunking via Batch Apex — implement
Database.Batchable<sObject>, Database.AllowsCallouts. Eachexecute()chunk has its own callout limit. Use batch size 100 or less.
- Composite API on the Salesforce side — if external systems are calling Salesforce, Composite API bundles multiple subrequests as one HTTP call.
- Queueable chain — a Queueable that processes a chunk and chains the next, processing 50 records per chain link. Good when Batch interface doesn't fit.
- Platform Events to decouple — publish an event per record; an external subscriber processes asynchronously. Decouples Salesforce from external availability.
Always: mark Database.AllowsCallouts for async; handle errors per-record (log to custom object); don't make blocking callouts in trigger context (use @future(callout=true) or queue to async); respect external rate limits.
