Reports
Read balance totals and sum movements by reason over a period.
Paths are relative to https://api.agentpost.tools/v1/resources. Who may call explains each credential.
Get totals
GET /reports/totals
Sums for each resource matched by a resource ID, a tag, or attribute.<name> parameters, including archived resources. Each row gives its balance over its scopes and, for a period from from to to, its movements summed by reason. groupBy breaks the totals down by an attribute of the supply entries on a resource that keeps its supply apart, and holderRef totals one holder’s scopes. A write that lands while the read runs may or may not be counted.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.reports.totals(query)
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
resourceId |
string |
No | 1–256 characters. |
tag |
string |
No | 1–200 characters. |
from |
string |
No | An ISO 8601 date and time. |
to |
string |
No | An ISO 8601 date and time. |
groupBy |
string |
No | 1–64 characters. |
holderRef |
string |
No | 1–256 characters. |
Response
200 OK, with TotalsReport.
Errors
invalid_request(400)
Any operation can also answer with the codes Conventions lists.
The TotalsReport object
Sums for each selected resource.
| Name | Type | Present | Description |
|---|---|---|---|
asOf |
string |
Always | When the totals were read. A balance counts what had expired by then; a write that landed while the read ran may or may not be counted. |
from |
string |
When set | The period, when one was asked for. from is in it and to is not. |
to |
string |
When set | An ISO 8601 date and time. |
groupBy |
string |
When set | |
holderRef |
string |
When set | Your app’s name for the holder, such as principal:external:u_maya. |
resources |
ResourceTotals array |
Always | The resources the selection matched, in the order they were created. |
The ResourceTotals object
One resource’s totals.
| Name | Type | Present | Description |
|---|---|---|---|
resourceId |
string |
Always | Resource ID, res_…. |
key |
string |
Always | |
name |
string |
Always | |
unit |
Unit |
Always | |
balance |
TotalsBalance or null |
Always | The resource’s balance over its scopes, or one holder’s. Null on a resource counted in buckets: it has a balance for each bucket of time, and buckets of different times are never added together. |
movements |
object |
When set | When a period was asked for: the resource’s movements in it, by reason. Each value is a number. |
groups |
TotalsGroup array or null |
When set | When groupBy was asked for: the totals for each value of that attribute on the resource’s supply entries, by value and the entries without it last. A unit counts in the group of the entry it sits on, and a movement in the groups of the entries it drew from or added to, so the groups add up to the resource’s totals. What a balance owes, and what holds hold beyond its entries, sit on no entry and count in the null group, and so does what is available on a balance that has either. Null on a resource that keeps one running balance or counts in buckets: it keeps no supply entries apart, so there is nothing to group by. |
The Unit object
A resource’s base unit, with its labels and its precision: the number of decimal places one unit of Quantity stands for.
| Name | Type | Present | Description |
|---|---|---|---|
code |
string |
Always | |
singular |
string |
Always | |
plural |
string |
Always | |
precision |
number |
Always |
The TotalsBalance object
A balance summed over scopes, each scope counted as a balance read counts it: an expired hold holds nothing, and supply past its expiry is not on hand.
| Name | Type | Present | Description |
|---|---|---|---|
onHand |
number |
Always | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with invalid_quantity. |
held |
number |
Always | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with invalid_quantity. |
available |
number |
Always | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with invalid_quantity. |
The TotalsGroup object
The totals of one value of the grouping attribute, or of the entries without it.
| Name | Type | Present | Description |
|---|---|---|---|
value |
string or null |
Always | The attribute’s value on these entries, or null for the entries that don’t carry it. |
balance |
TotalsBalance |
Always | What these entries have, as the resource’s balance counts it. |
movements |
object |
When set | When a period was asked for: what movements in it changed on these entries, by reason. Each value is a number. |