Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Claims

Take supply, settle an estimated quantity, or read claim records.

Paths are relative to https://api.agentpost.tools/v1/resources. Who may call explains each credential.

Consume supply

POST /consume

Takes each line from what is available, for good, all or nothing. Several lines may name a resource counted in buckets, with disjoint spans in each scope, or a resource with identity: instance, each naming a different unit. A line naming a unit that isn’t free refuses the request with assignment_infeasible. Repeating the same request with its sourceKey answers with the first result.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.claims.consume(body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Body

Name Type Required Description
lines object[] Yes 1–50 items.
lines[].resourceId string Yes 1–256 characters.
lines[].scope object No
lines[].scope.placeId string No
lines[].scope.condition string No 1–64 characters.
lines[].scope.holderRef string No 1–256 characters.
lines[].scope.instanceId string No
lines[].quantity number Yes
lines[].from object No
lines[].from.batchId string No 1–256 characters.
lines[].from.supplyId string No 1–256 characters.
lines[].span object No
lines[].span.start string Yes An ISO 8601 date and time.
lines[].span.end string Yes An ISO 8601 date and time.
estimate boolean No
evidence object Yes
evidence.kind string Yes 1–256 characters.
evidence.ref string Yes 1–256 characters.
sourceKey string Yes 1–200 characters.

Response

201 Created, with ConsumeResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Settle an estimated claim

POST /settle

Settles estimated consumptions at their real quantities, each once, all or nothing: gives back the difference or takes more, in a settle movement on each claim. An identical repeat under the same sourceKey answers with the first result and duplicate: true. A different request that reuses that sourceKey on one of its resources answers duplicate_source. A new sourceKey for a claim that is already settled answers invalid_request.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.claims.settle(body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Body

Name Type Required Description
lines object[] Yes 1–50 items.
lines[].claimId string Yes 1–256 characters.
lines[].quantity number Yes
evidence object No
evidence.kind string Yes 1–256 characters.
evidence.ref string Yes 1–256 characters.
sourceKey string Yes 1–200 characters.

Response

200 OK, with SettleResponse.

Errors

Any operation can also answer with the codes Conventions lists.

List claims

GET /claims

Lists claims, optionally filtered by resource, holder, status, and kind, and by a range their span overlaps, so a resource’s claims from and to are its hours booked then. 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 dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.claims.list(query)
  • Pages: limit, 1 to 500, default 100, with next and after. Lists has the rule.

Query parameters

Name Type Required Description
resourceId string No 1–256 characters.
holderRef string No 1–256 characters.
status string No One of "held", "committed", "released", "expired", or "cancelled".
kind string No One of "hold", "consumption", or "booking".
from string No An ISO 8601 date and time.
to string No An ISO 8601 date and time.
after string No 1–200 characters.
limit integer No 1–500; default 100.

Response

200 OK, with ClaimsPage.

Errors

Any operation can also answer with the codes Conventions lists.

Get a claim

GET /claims/:id

Reads a claim. 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 dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.claims.get(id)

Path parameters

Name Type Required Description
id string Yes Claim ID, clm_…. The id of a Claim.

Response

200 OK, with ClaimResponse.

Errors

Any operation can also answer with the codes Conventions lists.

The ConsumeResponse object

Name Type Present Description
claims Claim array Always One per line, in the order of the lines.
movements Movement array Always One per line in the same order. On a bucketed resource, this is the first bucket’s movement.
duplicate true When set Set when the sourceKey already named this request: nothing was taken again.

The SettleResponse object

What a settle wrote.

Name Type Present Description
claims Claim array Always One per line, settled, in the order of the lines.
movements Movement array Always The settle movements, in the order of the lines, one for each claim whose real quantity differs from its estimate. Each names its claim.
duplicate true When set Set when the sourceKey already named this request: nothing was settled again.

The ClaimsPage object

One page of claims, with the cursor for the next page when there is one.

Name Type Present Description
claims Claim array Always
next string When set

The ClaimResponse object

The claim read by ID.

Name Type Present Description
claim Claim Always

The Claim object

What one line held or took from a resource.

Name Type Present Description
id string Always Claim ID, clm_….
resourceId string Always Resource ID, res_….
scope Scope Always The scope it takes from.
span Span Always Half-open, UTC. A consumption starts when it was taken and never ends; so does a hold’s claim, from when it was placed. A claim on a resource counted in buckets has the span its line asked for, with an end.
quantity number Always What it takes. For a hold’s claim, what it holds, or held until its hold was resolved.
kind string Always A claim with a span that ends, on a resource counted in buckets, is a booking once it is taken: a consumption there, or a hold’s line once its hold is committed. A hold’s line is hold until then. One of "hold", "consumption", or "booking".
status string Always One of "held", "committed", "released", "expired", or "cancelled".
holdId string When set The hold it is a line of, for a claim of kind hold.
committed number When set What its hold’s commit took for good; the rest of quantity was released.
pegs Peg array When set The entries it drew from, when the resource keeps its supply apart. On a resource that lets its balance go below zero, they can cover less than the claim: the rest was owed, or a hold’s line holds it with no entry until its commit takes it.
transformationId string When set The conversion that took this claim’s quantity.
estimate number When set What an estimate first took, kept once it is settled; quantity is then the real quantity.
settled number When set The real quantity an estimate was settled at. Set once, by the settle.
holderRef string When set Your app’s name for the holder, such as principal:external:u_maya.
evidence Evidence When set What it was taken for. A claim taken by a hold commit carries the commit’s evidence.
sourceKey string When set For a consume or hold commit, kept on the first claim that takes from each resource.
actor PrincipalRef Always
onBehalfOf PrincipalRef When set
createdAt string Always An ISO 8601 date and time.
updatedAt string Always An ISO 8601 date and time.

The Span object

Half-open, [start, end), in UTC. A null end is open-ended.

Name Type Present Description
start string Always An ISO 8601 date and time.
end string or null Always