Idempotency and concurrency
Repeat a request without applying it twice, and refuse a request built from a document that has moved on.
On this page
Two ids, two jobs
A posting request carries two UUIDs that you choose. operationId identifies one attempt to make the change: repeat the request with the same operationId after a timeout and you get the original outcome. postingRequestId identifies the posting request itself, which is accepted once.
curl
curl -X POST "$RDC_BASE_URL/accounting/v1/posting-requests" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "32a34b30-2203-436d-897c-707b3c3770bd",
"postingRequestId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
"customerOrgId": "bdbc5b26-3f8a-4c1a-8c21-6c396293da32",
"legalCompanyId": "8373a2b0-3239-4aee-b6c8-56d7829a746d",
"sourceDocumentId": "58572830-d5ca-43ff-bd1d-d7ca383d5c65",
"sourceDocumentType": "supplier_invoice",
"sourceRevision": 2,
"eventId": "39d59497-f6f8-4a3f-bdaa-df9d722ff44f",
"effectiveDate": "2026-10-21",
"currency": "RON",
"mappingPolicyVersion": "ro-2026.1",
"correlationId": "716186ba-fb20-458d-a36a-a97717c751c7",
"facts": [
{
"type": "document",
"number": "AC-0094412",
"date": "2026-10-21"
},
{
"type": "partner",
"name": "Ambalaje Carpatin SRL",
"vatId": "RO51603619"
},
{
"type": "amount",
"rate": "21",
"base": "4128.70",
"vat": "867.03"
},
{
"type": "total",
"gross": "4995.73"
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/accounting/v1/posting-requests`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "32a34b30-2203-436d-897c-707b3c3770bd",
"postingRequestId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
"customerOrgId": "bdbc5b26-3f8a-4c1a-8c21-6c396293da32",
"legalCompanyId": "8373a2b0-3239-4aee-b6c8-56d7829a746d",
"sourceDocumentId": "58572830-d5ca-43ff-bd1d-d7ca383d5c65",
"sourceDocumentType": "supplier_invoice",
"sourceRevision": 2,
"eventId": "39d59497-f6f8-4a3f-bdaa-df9d722ff44f",
"effectiveDate": "2026-10-21",
"currency": "RON",
"mappingPolicyVersion": "ro-2026.1",
"correlationId": "716186ba-fb20-458d-a36a-a97717c751c7",
"facts": [
{
"type": "document",
"number": "AC-0094412",
"date": "2026-10-21"
},
{
"type": "partner",
"name": "Ambalaje Carpatin SRL",
"vatId": "RO51603619"
},
{
"type": "amount",
"rate": "21",
"base": "4128.70",
"vat": "867.03"
},
{
"type": "total",
"gross": "4995.73"
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/accounting/v1/posting-requests',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '32a34b30-2203-436d-897c-707b3c3770bd',
'postingRequestId': 'b7007a22-a9ea-4fcb-b535-e0570cdd1f2e',
'customerOrgId': 'bdbc5b26-3f8a-4c1a-8c21-6c396293da32',
'legalCompanyId': '8373a2b0-3239-4aee-b6c8-56d7829a746d',
'sourceDocumentId': '58572830-d5ca-43ff-bd1d-d7ca383d5c65',
'sourceDocumentType': 'supplier_invoice',
'sourceRevision': 2,
'eventId': '39d59497-f6f8-4a3f-bdaa-df9d722ff44f',
'effectiveDate': '2026-10-21',
'currency': 'RON',
'mappingPolicyVersion': 'ro-2026.1',
'correlationId': '716186ba-fb20-458d-a36a-a97717c751c7',
'facts': [
{
'type': 'document',
'number': 'AC-0094412',
'date': '2026-10-21',
},
{
'type': 'partner',
'name': 'Ambalaje Carpatin SRL',
'vatId': 'RO51603619',
},
{
'type': 'amount',
'rate': '21',
'base': '4128.70',
'vat': '867.03',
},
{
'type': 'total',
'gross': '4995.73',
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "32a34b30-2203-436d-897c-707b3c3770bd",
"postingRequestId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
"customerOrgId": "bdbc5b26-3f8a-4c1a-8c21-6c396293da32",
"legalCompanyId": "8373a2b0-3239-4aee-b6c8-56d7829a746d",
"sourceDocumentId": "58572830-d5ca-43ff-bd1d-d7ca383d5c65",
"sourceDocumentType": "supplier_invoice",
"sourceRevision": 2,
"eventId": "39d59497-f6f8-4a3f-bdaa-df9d722ff44f",
"effectiveDate": "2026-10-21",
"currency": "RON",
"mappingPolicyVersion": "ro-2026.1",
"correlationId": "716186ba-fb20-458d-a36a-a97717c751c7",
"facts": [
{
"type": "document",
"number": "AC-0094412",
"date": "2026-10-21"
},
{
"type": "partner",
"name": "Ambalaje Carpatin SRL",
"vatId": "RO51603619"
},
{
"type": "amount",
"rate": "21",
"base": "4128.70",
"vat": "867.03"
},
{
"type": "total",
"gross": "4995.73"
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/accounting/v1/posting-requests');
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")}/accounting/v1/posting-requests");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "32a34b30-2203-436d-897c-707b3c3770bd",
"postingRequestId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
"customerOrgId": "bdbc5b26-3f8a-4c1a-8c21-6c396293da32",
"legalCompanyId": "8373a2b0-3239-4aee-b6c8-56d7829a746d",
"sourceDocumentId": "58572830-d5ca-43ff-bd1d-d7ca383d5c65",
"sourceDocumentType": "supplier_invoice",
"sourceRevision": 2,
"eventId": "39d59497-f6f8-4a3f-bdaa-df9d722ff44f",
"effectiveDate": "2026-10-21",
"currency": "RON",
"mappingPolicyVersion": "ro-2026.1",
"correlationId": "716186ba-fb20-458d-a36a-a97717c751c7",
"facts": [
{
"type": "document",
"number": "AC-0094412",
"date": "2026-10-21"
},
{
"type": "partner",
"name": "Ambalaje Carpatin SRL",
"vatId": "RO51603619"
},
{
"type": "amount",
"rate": "21",
"base": "4128.70",
"vat": "867.03"
},
{
"type": "total",
"gross": "4995.73"
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "32a34b30-2203-436d-897c-707b3c3770bd",
"status": "accepted",
"aggregateId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
"aggregateRevision": 1
} - Create both ids when you decide to post the document, and store them before you send the request.
- After a timeout or a lost answer, send the same request again, byte for byte: the same ids and the same content.
- Derive
postingRequestIdfrom your own document id and its revision, so that one document at one revision always has the same one. - Use a new
operationIdfor every other change: a reversal, a subscription, a replay.
A document that has moved on
A posted entry is never edited, so no request carries an expected revision of an entry. A posting request names instead the revision of the source document it was built from, sourceRevision. If the document has a newer revision in the books, the request is refused and nothing is applied. A reversal needs no revision: an entry can be reversed once.
Conflicts
| Situation | Answer |
|---|---|
The same operationId and the same request. | 202 |
The same operationId with a different request. | 409 operation_reused |
The same postingRequestId with the same content. | 202 |
The same postingRequestId with other content. | 409 payload_conflict |
A sourceRevision older than the document in the books. | 409 stale_source |
| A reversal of an entry that already has one. | 409 reversal_conflict |
On a 409 for a revision, read the source document again, send its current revision with a new postingRequestId and a new operationId. See Error codes.
The full rule: Developer guide