How do rate limiting and throttling mechanisms protect Salesforce endpoints from excessive traffic spikes?
Answer
Basics: Every org has a rolling 24-hour limit on API requests, based on edition and licenses (for example Enterprise Edition gets a base of 100,000 plus an amount per user license, which you should verify for your contract). There is also a limit on concurrent long-running requests (over 20 seconds), commonly 25 in production. Bulk API, event delivery and streaming have their own limits.
How it works:
- Each REST, SOAP, Bulk or Apex REST call is counted.
- Responses include a
Sforce-Limit-Info: api-usage=used/limitheader. - When the allocation is exceeded, calls fail with
REQUEST_LIMIT_EXCEEDED. - The
/limitsREST resource (DailyApiRequests, and other entries) shows remaining capacity. - Clients back off and retry, and heavy loads use Bulk API or composite requests.
Advanced / deep dive: Build throttling in layers. A gateway enforces per-client quotas before traffic reaches Salesforce. Clients use exponential backoff with jitter and stop on persistent errors. Reduce call counts with the Composite API (up to 25 subrequests per call, and allOrNone option), sObject Collections (up to 200 records), Bulk API 2.0 for large loads, and Change Data Capture instead of polling. For custom Apex REST endpoints, Salesforce does not provide per-caller throttling, so implement a counter in Platform Cache or custom logic if needed. Monitor with the Salesforce API Total Usage event and set alert thresholds with Event Monitoring or the /limits endpoint.
Code / config example:
Response header: Sforce-Limit-Info: api-usage=87423/115000
Error body: [{"message":"TotalRequests Limit exceeded.","errorCode":"REQUEST_LIMIT_EXCEEDED"}] (HTTP 403)
Client rule: retry with delay = min(60s, 2^attempt + random(0..1)s); stop after 5 tries