On hand, reserved, available
The three quantities of a balance, which command moves which, and the rule that keeps them honest.
On this page
A balance has two stored quantities and one derived from them.
| Field | Meaning |
|---|---|
onHand | What is physically at the location. |
reserved | The part of it promised to orders. It is still on the shelf. |
available | onHand minus reserved: what can still be promised, sold or moved. |
The rule
After every command, for every balance it touched, reserved is not below zero and not above onHand. So available is never negative. A command that would break the rule on any line is refused with a 422 and insufficient_available_stock, and none of its lines is applied.
What moves what
| Command | `onHand` | `reserved` | Needs |
|---|---|---|---|
| Receipt | plus | no change | nothing |
| Reservation | no change | plus | quantity available |
| Sale | minus the quantity | minus reservedQuantity | what is not reserved is available |
| Return | plus | no change | nothing |
| Transfer | minus at the source, plus at the destination | no change | quantity available at the source |
| Count | set to the counted quantity | no change | counted quantity not below reserved |
| Reversal | the opposite of the movement | the opposite of the movement | the result stays within the rule |
Reserved goods that are sold
When an order is delivered, send the sale with reservedQuantity set to the part that was reserved for it. That part leaves onHand and reserved in the same step, so the stock promised to other orders stays promised. A sale without reservedQuantity takes only from what is available.
curl
curl -X POST "$RDC_BASE_URL/inventory/v1/sales" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
"documentType": "delivery",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "24",
"expectedRevision": 6,
"reservedQuantity": "24"
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/sales`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
"documentType": "delivery",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "24",
"expectedRevision": 6,
"reservedQuantity": "24"
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/inventory/v1/sales',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '87e846f9-6aaa-4b7c-b145-f59827ed2ae6',
'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
'occurredAt': '2026-11-23T07:19:00Z',
'source': {
'service': 'erp',
'documentId': '1e341639-829d-43ef-a1c9-10edb27894b4',
'documentType': 'delivery',
'documentRevision': 1,
},
'actor': {
'serviceId': 'brumar-erp',
'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
},
'lines': [
{
'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
'quantity': '24',
'expectedRevision': 6,
'reservedQuantity': '24',
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
"documentType": "delivery",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "24",
"expectedRevision": 6,
"reservedQuantity": "24"
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/sales');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/inventory/v1/sales");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
"documentType": "delivery",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "24",
"expectedRevision": 6,
"reservedQuantity": "24"
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
"status": "completed",
"aggregateRevision": 7,
"movementIds": [
"e3b706f6-4600-4e18-9e43-1e9469adc3be"
]
}