Availability
Check how much a request could take, or read balances by resource, scope, or holder.
Paths are relative to https://api.agentpost.tools/v1/resources. Who may call explains each credential.
Check availability
POST /availability
Gives the requested and available quantities for each line. Advisory: nothing is reserved. A line on a resource counted in buckets names its span, and one that starts in a bucket that has ended is refused, as a hold refuses it. A hold past its expiry no longer counts as held.
- Who may call: Your server, with your project’s secret key or a signed-in principal, with a user token for their own
principal:<principal>holder. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.availability.query(body) - Idempotency-Key: not taken. undefined
Body
| Name | Type | Required | Description |
|---|---|---|---|
lines |
object[] |
Yes | 1–50 items. |
lines[]. |
string |
Yes | 1–256 characters. |
lines[]. |
object |
No | |
lines[]. |
string |
No | |
lines[]. |
string |
No | 1–64 characters. |
lines[]. |
string |
No | 1–256 characters. |
lines[]. |
string |
No | |
lines[]. |
number |
Yes | |
lines[]. |
object |
No | |
lines[]. |
string |
No | 1–256 characters. |
lines[]. |
string |
No | 1–256 characters. |
lines[]. |
object |
No | |
lines[]. |
string |
Yes | An ISO 8601 date and time. |
lines[]. |
string |
Yes | An ISO 8601 date and time. |
Response
200 OK, with AvailabilityResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)
Any operation can also answer with the codes Conventions lists.
Get a balance
GET /resources/:id/balance
Reads one scope’s balance: on hand, held, expected, and available. On a resource with identity: instance, send the unit’s instanceId. Send by=batch for each batch’s share. A hold past its expiry no longer counts as held. A caller constrained to one holder reads only its own.
- Who may call: Your server, with your project’s secret key or a signed-in principal, with a user token for their own
principal:<principal>holder. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.balances.get(resourceId, query)
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
placeId |
string |
No | 1–256 characters. |
condition |
string |
No | 1–64 characters. |
holderRef |
string |
No | 1–256 characters. |
instanceId |
string |
No | 1–256 characters. |
by |
"batch" |
No |
Response
200 OK, with BalanceResponse.
Errors
invalid_request(400)not_found(404)
Any operation can also answer with the codes Conventions lists.
List a holder’s balances
GET /holders/:ref/balances
Lists a holder’s balances on resources kept without places. Send placeId to list balances at that place, and condition to select a label there. Omitting condition selects unlabeled balances. Lists one balance per resource in resource ID order, with its supply on hand and when more starts. A caller constrained to one holder lists only its own.
- Who may call: Your server, with your project’s secret key or a signed-in principal, with a user token for their own
principal:<principal>holder. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.holderBalances.list(holderRef, query) - Pages:
limit, 1 to 500, default 100, withnextandafter. Lists has the rule.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
ref |
string |
Yes | The holder reference, such as principal:external:u_maya. A signed-in principal can read only their own holder. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
placeId |
string |
No | 1–256 characters. |
condition |
string |
No | 1–64 characters. |
after |
string |
No | 1–200 characters. |
limit |
integer |
No | 1–500; default 100. |
Response
200 OK, with HolderBalancesPage.
Errors
invalid_request(400)not_found(404)
Any operation can also answer with the codes Conventions lists.
Get a holder’s balance
GET /holders/:ref/balances/:resourceId
Reads a holder’s balance on one resource held per holder: on hand, held, and available, its supply on hand, and when its next supply starts. Send placeId for a resource kept by place, and condition to select a label there. Omitting condition selects the unlabeled balance. A caller constrained to one holder reads only its own.
- Who may call: Your server, with your project’s secret key or a signed-in principal, with a user token for their own
principal:<principal>holder. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.holderBalances.get(holderRef, resourceId, query)
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
ref |
string |
Yes | The holder reference, such as principal:external:u_maya. A signed-in principal can read only their own holder. |
resourceId |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
placeId |
string |
No | 1–256 characters. |
condition |
string |
No | 1–64 characters. |
Response
200 OK, with HolderBalanceResponse.
Errors
invalid_request(400)not_found(404)
Any operation can also answer with the codes Conventions lists.
The AvailabilityResponse object
| Name | Type | Present | Description |
|---|---|---|---|
lines |
AvailabilityLine array |
Always | One per line asked about, in the same order. |
The BalanceResponse object
A balance as returned by a scope read.
| Name | Type | Present | Description |
|---|---|---|---|
balance |
Balance |
Always |
The HolderBalancesPage object
One page of a holder’s balances, with the cursor for the next page when there is one.
| Name | Type | Present | Description |
|---|---|---|---|
balances |
HolderBalance array |
Always | |
next |
string |
When set |
The HolderBalanceResponse object
A holder’s balance on one resource.
| Name | Type | Present | Description |
|---|---|---|---|
balance |
HolderBalance |
Always |
The AvailabilityLine object
| Name | Type | Present | Description |
|---|---|---|---|
resourceId |
string |
Always | Resource ID, res_…. |
scope |
Scope |
Always | |
quantity |
number |
Always | The quantity asked about. |
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. |
expected |
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. |
version |
number |
Always | |
asOf |
string |
Always | An ISO 8601 date and time. |
The Balance object
The quantities and freshness of one scope’s balance.
| Name | Type | Present | Description |
|---|---|---|---|
resourceId |
string |
Always | Resource ID, res_…. |
scope |
Scope |
Always | The scope read. |
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. |
expected |
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 | On hand less held, plus expected for backorders. A shortage caused by holds reads as zero. |
version |
number |
Always | Moves with every change to the balance; 0 for a scope that has never had one. |
asOf |
string |
Always | When the answer was true. |
batches |
BalanceBatch array |
When set | Each batch’s share of the balance, included when asked for by batch. |
The HolderBalance object
What one holder has on one resource.
| Name | Type | Present | Description |
|---|---|---|---|
resourceId |
string |
Always | Resource ID, res_…. |
holderRef |
string |
Always | Your app’s name for the holder, such as principal:external:u_maya. |
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. |
version |
number |
Always | Moves with every change to the balance; 0 for one that has never had one. |
supply |
SupplyEntry array |
Always | The holder’s supply on hand, such as added entries and outputs, in the order a take draws from them. |
nextSupplyAt |
string |
When set | When the next of the holder’s supply that starts later starts, when it has some. |
The BalanceBatch object
The portion of one scope’s balance that belongs to a batch.
| Name | Type | Present | Description |
|---|---|---|---|
batchId |
string |
Always | Batch ID, bat_…. |
code |
string |
Always | |
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. |
expiresAt |
string |
When set | An ISO 8601 date and time. |