Sub topic 9
Monitoring in Setup and API usage notifications
This chapter covers the browser-based tools for watching API usage in a Salesforce org. They need no code, so they are the fastest way to get a first alert in place. It assumes you know what an org, a connected app, and an integration user are. It also assumes you have read the earlier chapters on the daily API request limit and the REST Limits resource. This chapter builds on those two.
What Setup can and cannot tell you
Setup is the administrative area of an org. For API limits it answers two questions well:
- How much of the 24-hour rolling API allowance is used right now?
- Who should be told when usage gets high?
It answers a third question only partly: which user or app is responsible. For per-call detail you need Event Monitoring, which a later chapter covers. Setup gives you totals, a login trail, and connected app information.
| Question | Where to look in Setup | Granularity |
|---|---|---|
| How much of the daily limit is used? | System Overview, Company Information | One org-wide number |
| Who gets warned at a threshold? | API Usage Notifications | One rule per threshold |
| Which users connect through the API? | Login History | One row per login |
| Which connected apps hold tokens? | Connected Apps OAuth Usage | One row per app |
| Are bulk jobs stuck or heavy? | Bulk Data Load Jobs | One row per job |
Menu names and locations change between releases. Use the Quick Find box at the top of Setup and type the page name instead of navigating menus.
Reading the daily limit in Setup
Two pages show the daily request count. Both are read-only.
- System Overview. Open Setup and search for "System Overview". The page has a usage card for API requests in the last 24 hours. It shows the count, the maximum, and a percentage. The same page shows other org limits, such as data and file storage, so it is a good first stop when something is close to a limit.
- Company Information. Search for "Company Information". The limits section lists "API Requests, Last 24 Hours" with the used count and the maximum.
Both pages show the same figure the REST Limits resource returns for DailyApiRequests. The limit is a rolling 24-hour window, not a calendar day. Usage falls gradually as old requests age out, and it does not reset at midnight. If the page says 90% at 3 pm, you will not get a clean slate at midnight. Requests made 24 hours earlier have to age out first.
API usage notifications
An API usage notification is an email rule. When the org's daily API usage crosses a percentage you choose, Salesforce emails the recipients you pick. It is the built-in alert, so set it up before writing any monitoring code.
Creating a notification
- In Setup, search for "API Usage Notifications".
- Click New.
- Choose the recipient. This is normally a shared mailbox or a distribution list. A single person's address will be missed when that person is away.
- Choose a usage threshold as a percentage of the daily limit.
- Choose how often the notification may repeat while usage stays above the threshold.
- Save the rule.
The available threshold values and repeat intervals are chosen from fixed lists in the form. Read the options in your org rather than assuming a particular set. Create more than one rule for the same org, each with its own threshold.
Choosing thresholds
One rule is not enough. A single alert at 95% usually arrives when there are only minutes left. Use staged thresholds that match different responses:
| Threshold | Meaning | Suggested response |
|---|---|---|
| 50% | Informational. Good for spotting a trend. | Read the email. No action needed. |
| 75% | Usage is higher than normal for this point in the window. | Check which integration changed. |
| 90% | The limit is likely within hours. | Pause non-critical jobs. |
The right numbers depend on your traffic pattern. If a nightly sync uses 60% of the allowance every night, a 50% alert is noise. Set the first threshold above your normal peak, and review the rules every quarter.
What notifications do not do
- They do not say who or what caused the usage. The email reports the org total only.
- They do not stop anything. Salesforce keeps accepting calls until the limit is reached, then returns
REQUEST_LIMIT_EXCEEDED. - They cover the daily API request limit. They do not warn about concurrent long-running request limits or Apex governor limits.
- Email can be delayed, filtered as spam, or sent to a mailbox nobody reads.
Finding who is calling the API
When an alert fires, the next question is who made the calls. Setup offers three partial answers.
Login History
Login History records each login, including API logins. Search for "Login History" in Setup. Each row shows the user, the time, the application, the login type, and the source IP address. A user who appears hundreds of times in an hour from a server IP is a strong suspect for an integration that logs in on every run.
You can also query the same data with SOQL, which is easier to filter and sort:
SELECT UserId, Application, LoginType, SourceIp, LoginTime, Status
FROM LoginHistory
WHERE LoginTime = LAST_N_DAYS:1
ORDER BY LoginTime DESC
LIMIT 200Login History shows logins, not individual API calls. A client that logs in once and then makes 50,000 calls looks like one row. Use it to identify integrations, then compare against usage totals.
Connected Apps OAuth Usage
Search for "Connected Apps OAuth Usage". The page lists each connected app with the number of users and tokens it holds. It helps you find apps you did not know existed, or an app with many more tokens than expected. A large token count often means an integration is requesting a new token for every run instead of reusing one.
Bulk Data Load Jobs
Search for "Bulk Data Load Jobs". Each Bulk API job appears with its status, object, operation, and record counts. Bulk jobs count against API limits differently from single-record REST calls. A job that retries repeatedly, or a stuck job in progress, is easy to see here.
Matching Setup alerts with your own checks
Setup notifications are email only. If your team works in a chat tool or an on-call system, add a scheduled check that uses the Limits resource. The script below applies the same staged thresholds as the Setup rules, so the two sources agree. It exits with a nonzero status when a threshold is crossed, so a scheduler or CI job can send the alert.
import os
import sys
import requests
THRESHOLDS = [(90, "CRITICAL"), (75, "WARNING"), (50, "INFO")]
def daily_usage_percent(instance_url: str, token: str) -> float:
resp = requests.get(
f"{instance_url}/services/data/v60.0/limits",
headers={"Authorization": f"Bearer {token}"},
timeout=30,
)
resp.raise_for_status()
daily = resp.json()["DailyApiRequests"]
used = daily["Max"] - daily["Remaining"]
return 100 * used / daily["Max"]
def main() -> int:
percent = daily_usage_percent(
os.environ["INSTANCE_URL"], os.environ["ACCESS_TOKEN"]
)
for limit, label in THRESHOLDS:
if percent >= limit:
print(f"{label}: daily API usage is {percent:.1f}% (threshold {limit}%)")
return 1 if label != "INFO" else 0
print(f"OK: daily API usage is {percent:.1f}%")
return 0
if __name__ == "__main__":
sys.exit(main())Remember that this call itself costs one API request. Run it every 5 to 15 minutes, not every second.
Common mistakes
- Treating the percentage as a calendar-day figure. Usage is a rolling 24-hour window. Plan retries and bulk loads with that in mind.
- Sending alerts to one person. Use a shared address.
- Setting only one threshold. A single high threshold leaves no time to react.
- Assuming the alert says who is responsible. It does not. Open Login History and connected app pages next.
- Ignoring the integration user's own usage. A monitoring script that polls too often adds to the load it is trying to measure.
- Never testing the alert path. Confirm the email arrives and is read.
Exercise
Your org's API usage notification at 90% emails one administrator. At 14:00 the email arrives, and System Overview shows 91% used. At 14:30 the integration is paused, but at 15:00 the page still shows 88%, and at midnight it is not zero. Why does usage not drop to zero, and which Setup page would you open first to find the source of the traffic?
Show answer
The daily limit counts requests over a rolling 24-hour window, so requests made yesterday afternoon stay in the count until they are 24 hours old. Pausing the integration stops new requests but does not remove old ones, and midnight does not reset anything. To find the source of the traffic, open Login History first to look for a user or application with an unusual number of API logins. Then check Connected Apps OAuth Usage for apps with many tokens, and Bulk Data Load Jobs for heavy jobs.