Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Totals

A totals report reads several resources in one request. Each row gives the resource’s current balance across its scopes and, when you ask for a period, its movements summed by reason. Your server reads totals with the project’s secret key.

Selection and balance

Select resources by resourceId, tag, or attribute.<name>. The report includes every resource that matches all the filters, including archived ones. holderRef limits the totals to that holder’s scopes.

A row gives the resource’s unit and the sum of onHand, held, and available over its selected scopes. The report uses asOf to decide which supply has started and which supply or holds have expired, regardless of the movement period. A write that commits during the read can appear in a row. For a resource that counts time in buckets, balance is null because each bucket has its own balance.

Movement period

from and to come together. The report includes movements at from and excludes those at to. For each reason, it adds the signed changes to on hand. A movement that changes only held or expected contributes zero. A movement over time counts one bucket, so taking one room for three nights contributes three units across the bucket movements.

Your app chooses which reasons count as usage. It adds rows only when their unit codes and precision match.

Groups

With groupBy, a resource that keeps supply entries apart breaks its totals down by the value of one attribute on those entries. A movement contributes to the groups of the supply entries it names. An entry without the attribute falls in the group with value: null. So does what a balance owes, and what a hold holds with no entry. On a balance with either, the null group also counts all of that balance’s available. On a running balance or a resource that counts time in buckets, groups is null.

Limits

A totals request selects at most 100 resources and covers a movement period of at most 366 days.

Where to act on it