Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Holds

Reserve supply until a hold expires. Extend or release a hold, commit what it reserves, or cancel or reschedule lines where allowed.

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

Place a hold

POST /holds

Sets each line aside, all or nothing, until the hold is committed, released, or runs out at expiresAt. 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 in scope.instanceId. A refusal names each short line and how much is available for it, and is assignment_infeasible when a unit a line names isn’t free. Send the hold length in ttl, such as “1h”. A line on a resource held per holder names its holder in scope.holderRef. A repeat under a sourceKey already used in the project answers with the same hold, for ever.

  • 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.holds.create(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.
ttl string Yes A duration, such as “10m” or “7d”.
label string No 1–200 characters.
holderRef string No 1–256 characters.
reference object No
reference.kind string Yes 1–256 characters.
reference.ref string Yes 1–256 characters.
sourceKey string Yes 1–200 characters.

Response

201 Created, with HoldResponse.

Errors

Any operation can also answer with the codes Conventions lists.

List holds

GET /holds

Lists holds, optionally filtered by holder, label, and status. A caller constrained to one holder lists only its own. A hold whose detail retention removed is not listed.

  • 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.holds.list(query)
  • Pages: limit, 1 to 500, default 100, with next and after. Lists has the rule.

Query parameters

Name Type Required Description
holderRef string No 1–256 characters.
label string No 1–200 characters.
status string No One of "open", "committed", "partially_committed", "released", "expired", or "cancelled".
after string No 1–200 characters.
limit integer No 1–500; default 100.

Response

200 OK, with HoldsPage.

Errors

Any operation can also answer with the codes Conventions lists.

Get a hold

GET /holds/:id

Reads a hold with its lines. A caller constrained to one holder reads only its own. Once retention has removed a hold’s detail, it reads as its RetainedHold, and only to a caller constrained to no holder.

  • 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.holds.get(id)

Path parameters

Name Type Required Description
id string Yes Hold ID, hld_…. The id of a Hold.

Response

200 OK, with HoldResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Extend a hold

POST /holds/:id/extend

Extends the hold from now by the required ttl, such as “15m”. The expiry can only move later.

  • 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.holds.extend(id, body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes Hold ID, hld_…. The id of a Hold.

Body

Name Type Required Description
ttl string Yes A duration, such as “10m” or “7d”.

Response

200 OK, with HoldResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Commit a hold

POST /holds/:id/commit

Takes every line in full when lines is omitted or empty. A nonempty list names each line and the quantity to take, and the rest is released. An expired hold is refused with hold_expired and the available quantity on each line the service still retains. Use POST /consume to make a separate purchase with the same lines. A repeat under a sourceKey that already committed the hold 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.holds.commit(id, body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes Hold ID, hld_…. The id of a Hold.

Body

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

Response

200 OK, with HoldCommitResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Release a hold

POST /holds/:id/release

Lets go of everything the hold holds. A hold already released is returned as it is.

  • 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.holds.release(id, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes Hold ID, hld_…. The id of a Hold.

Response

200 OK, with HoldResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Cancel a committed hold

POST /holds/:id/cancel

Gives back the committed lines it names, or all of them, all or nothing: a span’s buckets return, and what a used-up line took goes back where its pegs say. The hold reads cancelled once every line its commit took from is. A repeat under a sourceKey already used in the project 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.holds.cancel(id, body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes Hold ID, hld_…. The id of a Hold.

Body

Name Type Required Description
lines string[] No 1–50 items.
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 HoldCancelResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Reschedule a hold

POST /reschedule

Moves hold lines on resources counted in buckets, from one hold or several, to another resource, another unit, another span, or any mix, in one write: every old position is given back and every new one taken, or nothing changes, so two bookings on two full resources can swap. Each line stays held or committed. A line that omits resourceId keeps its resource and scope. A line that names a resource gives its full scope there. If the destination differs from the original resource in unit code or precision, the API answers invalid_request. A short move is refused with what each short line has available, and a unit that isn’t free with assignment_infeasible. A line already where it is asked to be is left alone. The answer shows each hold a line belongs to in full, so authorize is asked about each claim, each resource a line names, and each hold. A repeat under a sourceKey already used in the project answers with the first result, with each hold as it now is.

  • 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.holds.reschedule(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[].resourceId string No 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[].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.
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 HoldRescheduleResponse.

Errors

Any operation can also answer with the codes Conventions lists.

The HoldResponse object

Name Type Present Description
hold Hold or RetainedHold Always A RetainedHold, with retainedAt, once retention has removed the hold’s detail.
duplicate true When set Set when the sourceKey already named this request: nothing was held again.

The HoldsPage object

Name Type Present Description
holds Hold array Always
next string When set

The HoldCommitResponse object

Name Type Present Description
hold Hold or RetainedHold Always A RetainedHold, with retainedAt, when the commit is repeated after retention has removed the hold’s detail.
movements Movement array Always What the commit moved, in the order of the lines: one for each line it took from or let go.
duplicate true When set Set when the sourceKey already named this commit: nothing was taken again.

The HoldCancelResponse object

Name Type Present Description
hold Hold or RetainedHold Always A RetainedHold, with retainedAt, when the cancel is repeated after retention has removed the hold’s detail.
movements Movement array Always What the cancel gave back, one for each line, in the order the hold lists them: on buckets, its first bucket’s.
duplicate true When set Set when the sourceKey already named this cancel: nothing was given back again.

The HoldRescheduleResponse object

Name Type Present Description
holds array of Hold or RetainedHold Always Each hold a line belongs to, in the order first named, in full and as it now is, which the caller is asked to be allowed to reschedule as a whole. A repeat under the sourceKey shows each as it is at the repeat, after any later change, and a RetainedHold once retention has removed its detail.
lines RescheduledLine array Always The lines that moved, in request order, as they moved then, a repeat included; a line already where it was asked to be isn’t listed.
duplicate true When set Set when the sourceKey already named this reschedule: nothing moved again.

The Hold object

Name Type Present Description
id string Always Hold ID, hld_….
label string When set A label supplied by the app for grouping holds.
expiresAt string Always When it runs out, set by the server.
holderRef string When set Whom it holds for.
reference Evidence When set What it was placed for, such as the checkout or the order.
lines HoldLine array Always One per line asked for, in the same order.
status string Always expired from expiresAt on if the hold was still open. One of "open", "committed", "partially_committed", "released", "expired", or "cancelled".
resolution HoldResolution When set Set once the hold is no longer open.
cancellations HoldCancellation array When set Each cancel of the committed hold, in order.
sourceKey string Always
actor PrincipalRef Always The principal that placed it with its own credential.
onBehalfOf PrincipalRef When set
createdAt string Always An ISO 8601 date and time.
updatedAt string Always An ISO 8601 date and time.

The RetainedHold object

A resolved hold once retention has removed its detail: what its sourceKey and its commit’s still answer with. Its lines are the ones a commit took from, which stay as the record of what was taken.

Name Type Present Description
id string Always Hold ID, hld_….
status string Always How it ended. One of "committed", "partially_committed", "released", "expired", or "cancelled".
resolution HoldResolution Always
sourceKey string Always
lines HoldLine array Always
retainedAt string Always When retention removed the rest, including the label, holder, and lines that took nothing.

The RescheduledLine object

One line a reschedule moved: its hold, and where it sat before and after.

Name Type Present Description
claimId string Always Claim ID, clm_….
holdId string Always Hold ID, hld_….
before LinePosition Always
after LinePosition Always

The HoldLine object

One line of a hold, as its claim stands.

Name Type Present Description
claimId string Always Claim ID, clm_….
resourceId string Always Resource ID, res_….
scope Scope Always The scope it holds from.
span FiniteSpan When set On a resource counted in buckets: the time the line holds, [start, end).
quantity number Always What the line holds, or held until the hold was resolved.
status string Always cancelled once a cancel gave back what its commit took. One of "held", "committed", "released", "expired", or "cancelled".
committed number When set What the commit took for good; the rest of quantity was released.
pegs Peg array When set The supply entries the line holds from, or took from once committed, on a resource whose supply is told apart.

The HoldResolution object

How a hold ended.

Name Type Present Description
at string Always When: the commit or the release, or, for an expiry, the expiresAt it ran out at.
evidence Evidence When set What a commit was made for, such as the order.
sourceKey string When set The commit’s sourceKey.

The HoldCancellation object

One cancel of a committed hold: the lines it gave back.

Name Type Present Description
at string Always An ISO 8601 date and time.
claimIds string[] Always
evidence Evidence When set
sourceKey string Always

The LinePosition object

Where a hold line sits: its resource, its scope there, and its span.

Name Type Present Description
resourceId string Always Resource ID, res_….
scope Scope Always
span FiniteSpan Always