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
devsecret key,sk_test_…, asAuthorization: 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. |
string |
No | |
from. |
string |
No | 1–64 characters. |
from. |
string |
No | 1–256 characters. |
from. |
string |
No | |
from. |
string |
No | 1–256 characters. |
from. |
string |
No | 1–256 characters. |
to |
object |
Yes | |
to. |
string |
No | |
to. |
string |
No | 1–64 characters. |
to. |
string |
No | 1–256 characters. |
to. |
string |
No | |
quantity |
number |
Yes | |
sourceKey |
string |
Yes | 1–200 characters. |
evidence |
object |
No | |
evidence. |
string |
Yes | 1–256 characters. |
evidence. |
string |
Yes | 1–256 characters. |
note |
string |
No | 1–200 characters. |
Response
201 Created, with TransferResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)duplicate_source(409)insufficient_supply(409)exhausted_until_supply(409)assignment_infeasible(409)
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
devsecret key,sk_test_…, asAuthorization: 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. |
string |
No | |
scope. |
string |
No | 1–64 characters. |
scope. |
string |
No | 1–256 characters. |
scope. |
string |
No | |
quantity |
number |
Yes | |
from |
object |
No | |
from. |
string |
No | 1–256 characters. |
from. |
string |
No | 1–256 characters. |
version |
integer |
Yes | At least 0. |
evidence |
object |
No | |
evidence. |
string |
Yes | 1–256 characters. |
evidence. |
string |
Yes | 1–256 characters. |
note |
string |
No | 1–200 characters. |
Response
201 Created, with CountResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)insufficient_supply(409)stale_version(409)
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
devsecret key,sk_test_…, asAuthorization: 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. |
string |
No | |
scope. |
string |
No | 1–64 characters. |
scope. |
string |
No | 1–256 characters. |
scope. |
string |
No | |
quantity |
number |
No | |
from |
object |
No | |
from. |
string |
No | 1–256 characters. |
from. |
string |
No | 1–256 characters. |
evidence |
object |
No | |
evidence. |
string |
Yes | 1–256 characters. |
evidence. |
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
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)duplicate_source(409)insufficient_supply(409)exhausted_until_supply(409)assignment_infeasible(409)
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
devsecret key,sk_test_…, asAuthorization: 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[]. |
string |
Yes | 1–256 characters. |
takes[]. |
object |
No | |
takes[]. |
string |
No | |
takes[]. |
string |
No | 1–64 characters. |
takes[]. |
string |
No | 1–256 characters. |
takes[]. |
string |
No | |
takes[]. |
number |
Yes | |
takes[]. |
object |
No | |
takes[]. |
string |
No | 1–256 characters. |
takes[]. |
string |
No | 1–256 characters. |
takes[]. |
object |
No | |
takes[]. |
string |
Yes | An ISO 8601 date and time. |
takes[]. |
string |
Yes | An ISO 8601 date and time. |
adds |
object[] |
Yes | 1–50 items. |
adds[]. |
string |
Yes | 1–256 characters. |
adds[]. |
object |
No | |
adds[]. |
string |
No | |
adds[]. |
string |
No | 1–64 characters. |
adds[]. |
string |
No | 1–256 characters. |
adds[]. |
string |
No | |
adds[]. |
number |
Yes | |
adds[]. |
string |
No | 1–256 characters. |
adds[]. |
object |
No | |
adds[]. |
string |
Yes | 1–200 characters. |
adds[]. |
string |
No | An ISO 8601 date and time. |
adds[]. |
object |
No | Each value is a string. |
adds[]. |
string |
No | An ISO 8601 date and time. |
adds[]. |
object |
No | Each value is a string. |
evidence |
object |
Yes | |
evidence. |
string |
Yes | 1–256 characters. |
evidence. |
string |
Yes | 1–256 characters. |
sourceKey |
string |
Yes | 1–200 characters. |
Response
201 Created, with TransformationResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)duplicate_source(409)insufficient_supply(409)exhausted_until_supply(409)assignment_infeasible(409)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)
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[]. |
string |
Always | Claim ID, clm_…. |
takes[]. |
string |
Always | Movement ID, mov_…. |
adds |
object[] |
Always | |
adds[]. |
string |
Always | Supply ID, sup_…. |
adds[]. |
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. |