Revisions and concurrency
Each balance has a revision that grows with every movement. A command carries the revision it read and is refused if the balance has moved on.
On this page
Several systems change the same stock: the ERP reserves, the point of sale sells, the warehouse counts. Revisions keep them from overwriting each other.
The revision of a balance
The revision of a balance is the number of movements recorded for that item at that location. A new balance is at revision 0. Read it from the availability, or from resultingRevision of the last movement of the stock card.
expectedRevision
Every line names the balance it changes and the revision it read, as expectedRevision. A transfer line has two: fromExpectedRevision and toExpectedRevision. A reversal line names a movement, and its expectedRevision is that of the balance the movement belongs to, as it is now.
If any balance of the command is at another revision, the answer is a 409 with revision_conflict, and nothing is applied: not that line, not the others.
A reservation that read an older revision of the flour
curl
curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
"documentType": "sales-order",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "10",
"expectedRevision": 5
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/reservations`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
"documentType": "sales-order",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "10",
"expectedRevision": 5
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/inventory/v1/reservations',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'e3f4095f-d443-4219-a81e-abdd81abec57',
'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
'occurredAt': '2026-11-23T07:19:00Z',
'source': {
'service': 'erp',
'documentId': '59bebeb2-d0f4-439c-a445-74c4fa0f971c',
'documentType': 'sales-order',
'documentRevision': 1,
},
'actor': {
'serviceId': 'brumar-erp',
'userId': '4e2f591e-3df0-4f36-8741-3e49134249b0',
},
'lines': [
{
'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
'quantity': '10',
'expectedRevision': 5,
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
"documentType": "sales-order",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "10",
"expectedRevision": 5
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/reservations');
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/reservations");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:19:00Z",
"source": {
"service": "erp",
"documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
"documentType": "sales-order",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
},
"lines": [
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "10",
"expectedRevision": 5
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"code": "revision_conflict",
"message": "A balance has changed since the revision you sent.",
"requestId": "req_4f9d2a7c1b6e8035"
} After a conflict
Read again
Read the availability of each balance of the command. The revision and the quantities are current.
Decide
Whether the change still makes sense: a reservation may now exceed what is available.
Send a new command
Send it with the new revisions and a new
operationId. The refused command changed nothing and left no record.
curl
curl -X POST "$RDC_BASE_URL/inventory/v1/receipts" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:26:00Z",
"source": {
"service": "erp",
"documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
"documentType": "goods-receipt",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "100",
"expectedRevision": 7
},
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "60",
"expectedRevision": 7
},
{
"productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "40",
"expectedRevision": 3
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/receipts`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:26:00Z",
"source": {
"service": "erp",
"documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
"documentType": "goods-receipt",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "100",
"expectedRevision": 7
},
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "60",
"expectedRevision": 7
},
{
"productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "40",
"expectedRevision": 3
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/inventory/v1/receipts',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '4bfa0af7-a8f7-4d84-ae30-792b7a99b286',
'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
'occurredAt': '2026-11-23T07:26:00Z',
'source': {
'service': 'erp',
'documentId': '978dd1f4-5f65-4307-9b96-beb995212227',
'documentType': 'goods-receipt',
'documentRevision': 1,
},
'actor': {
'serviceId': 'brumar-erp',
'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
},
'lines': [
{
'productId': '11079e9a-344b-409c-8da5-e8335a7846b1',
'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
'quantity': '100',
'expectedRevision': 7,
},
{
'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
'quantity': '60',
'expectedRevision': 7,
},
{
'productId': '109ebad9-6627-4ac3-817e-f81ad628676b',
'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
'quantity': '40',
'expectedRevision': 3,
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:26:00Z",
"source": {
"service": "erp",
"documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
"documentType": "goods-receipt",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "100",
"expectedRevision": 7
},
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "60",
"expectedRevision": 7
},
{
"productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "40",
"expectedRevision": 3
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/receipts');
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/receipts");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
"customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
"legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
"occurredAt": "2026-11-23T07:26:00Z",
"source": {
"service": "erp",
"documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
"documentType": "goods-receipt",
"documentRevision": 1
},
"actor": {
"serviceId": "brumar-erp",
"userId": "376a64f7-268a-4f79-808e-0d89162055ac"
},
"lines": [
{
"productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "100",
"expectedRevision": 7
},
{
"productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "60",
"expectedRevision": 7
},
{
"productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
"locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
"quantity": "40",
"expectedRevision": 3
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
"status": "completed",
"aggregateRevision": 8,
"movementIds": [
"cd93538c-9b49-4605-97b7-b9b2eb2ea9d6",
"ead9c438-3b01-4074-8613-c6e7d090fd80",
"b02ec58f-c921-4591-899e-22679fccb209"
]
}