Skip to content

checkApiBudget

checkApiBudget(connection, plannedRequests, options): Promise<ApiBudgetResult>

Defined in: packages/simply-core/src/org/apiBudget.ts:113

Work out whether a run fits inside a share of the org’s remaining API requests.

The budget is a percentage of what the org has left, not of its daily maximum: an org that has already burned most of its allocation should get a proportionally smaller budget, which is the point of checking at all.

Every Salesforce API call counts toward the daily allocation, including the /limits call this may make to answer the question. When that fallback is used its own request is added to plannedRequests so the accounting stays honest.

This never throws for an unreadable allocation. Reading /limits requires a permission the calling command does not otherwise need, and an advisory check must not turn that into a hard requirement — callers get status: 'unavailable' and decide what to do.

Connection

The org connection.

number

How many API requests the run is about to make.

CheckApiBudgetOptions

The budget configuration.

Promise<ApiBudgetResult>

The check result. Callers decide whether exceeded is fatal.