Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Stock

Transfer, count, adjust, or convert stock.

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

Transfer stock

POST /transfers

Moves stock between two scopes, such as two places, two condition labels, or two holders, writing both movements in one change. Only what is free moves. On a resource with identity: instance, both scopes name the same unit. A repeat under the same 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.transfers.create(body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Body

Name Type Required Description
resourceId string Yes 1–256 characters.
from object Yes
from.placeId string No
from.condition string No 1–64 characters.
from.holderRef string No 1–256 characters.
from.instanceId string No
from.batchId string No 1–256 characters.
from.supplyId string No 1–256 characters.
to object Yes
to.placeId string No
to.condition string No 1–64 characters.
to.holderRef string No 1–256 characters.
to.instanceId string No
quantity number Yes
sourceKey string Yes 1–200 characters.
evidence object No
evidence.kind string Yes 1–256 characters.
evidence.ref string Yes 1–256 characters.
note string No 1–200 characters.

Response

201 Created, with TransferResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Record a count

POST /counts

Records a stock count against the balance version the counter read.

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

Body

Name Type Required Description
resourceId string Yes 1–256 characters.
scope object No
scope.placeId string No
scope.condition string No 1–64 characters.
scope.holderRef string No 1–256 characters.
scope.instanceId string No
quantity number Yes
from object No
from.batchId string No 1–256 characters.
from.supplyId string No 1–256 characters.
version integer Yes At least 0.
evidence object No
evidence.kind string Yes 1–256 characters.
evidence.ref string Yes 1–256 characters.
note string No 1–200 characters.

Response

201 Created, with CountResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Adjust stock

POST /adjustments

Records a signed adjustment with a reason, or reverses a movement. A repeat under the same 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.adjustments.create(body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Body

Name Type Required Description
resourceId string No 1–256 characters.
scope object No
scope.placeId string No
scope.condition string No 1–64 characters.
scope.holderRef string No 1–256 characters.
scope.instanceId string No
quantity number No
from object No
from.batchId string No 1–256 characters.
from.supplyId string No 1–256 characters.
evidence object No
evidence.kind string Yes 1–256 characters.
evidence.ref string Yes 1–256 characters.
note string No 1–200 characters.
sourceKey string Yes 1–200 characters.
reverses string No 1–256 characters.

Response

201 Created, with AdjustmentResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Record a conversion

POST /transformations

Takes several quantities and adds several others in one change. 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.transformations.create(body, { idempotencyKey })
  • Idempotency-Key: required. Retrying a write has the rule.

Body

Name Type Required Description
takes object[] Yes 1–50 items.
takes[].resourceId string Yes 1–256 characters.
takes[].scope object No
takes[].scope.placeId string No
takes[].scope.condition string No 1–64 characters.
takes[].scope.holderRef string No 1–256 characters.
takes[].scope.instanceId string No
takes[].quantity number Yes
takes[].from object No
takes[].from.batchId string No 1–256 characters.
takes[].from.supplyId string No 1–256 characters.
takes[].span object No
takes[].span.start string Yes An ISO 8601 date and time.
takes[].span.end string Yes An ISO 8601 date and time.
adds object[] Yes 1–50 items.
adds[].resourceId string Yes 1–256 characters.
adds[].scope object No
adds[].scope.placeId string No
adds[].scope.condition string No 1–64 characters.
adds[].scope.holderRef string No 1–256 characters.
adds[].scope.instanceId string No
adds[].quantity number Yes
adds[].batchId string No 1–256 characters.
adds[].batch object No
adds[].batch.code string Yes 1–200 characters.
adds[].batch.expiresAt string No An ISO 8601 date and time.
adds[].batch.attributes object No Each value is a string.
adds[].expiresAt string No An ISO 8601 date and time.
adds[].attributes object No Each value is a string.
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 TransformationResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Get a conversion

GET /transformations/:id

Reads a conversion with its movements and the supply it added.

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

Path parameters

Name Type Required Description
id string Yes Transformation ID, tfm_…. The id of a Transformation.

Response

200 OK, with TransformationResponse.

Errors

Any operation can also answer with the codes Conventions lists.

The TransferResponse object

Name Type Present Description
transferId string Always Transfer ID, trf_….
movements Movement array Always The movement out, then the movement in; 2–2 items.
duplicate true When set Set when the source key already named this request.

The CountResponse object

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.
version number Always
movement Movement When set

The AdjustmentResponse object

Name Type Present Description
movement Movement Always
duplicate true When set

The TransformationResponse object

A conversion with the movements and the supply it added.

Name Type Present Description
transformation Transformation Always
movements Movement array Always
supply SupplyEntry array Always
duplicate true When set Set when the source key already named this request.

The Transformation object

The record that links a conversion’s inputs, outputs, and evidence.

Name Type Present Description
id string Always Transformation ID, tfm_….
takes object[] Always
takes[].claimId string Always Claim ID, clm_….
takes[].movementId string Always Movement ID, mov_….
adds object[] Always
adds[].supplyId string Always Supply ID, sup_….
adds[].movementId string Always Movement ID, mov_….
evidence Evidence Always
sourceKey string Always
actor PrincipalRef Always
onBehalfOf PrincipalRef When set
createdAt string Always An ISO 8601 date and time.