---
title: "Idempotency and concurrency | Docs | Inventory by R&D Copilot"
description: "Repeat a request without applying it twice, and refuse a change made on an out-of-date record."
canonical: "https://inventory.rdcopilot.com/docs/reference/idempotency/"
language: en
updated: 2026-11-22
---

# Idempotency and concurrency

Repeat a request without applying it twice, and refuse a change made on an out-of-date record.

## One operationId, one change

Every request that changes data carries an `operationId`, a UUID you choose. A change is accepted once. If you send the same request again with the same `operationId`, you get the original outcome and nothing is applied a second time.

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "90aebca5-208b-47dd-9e6d-c9159d4aab06",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:12:00Z",
  "source": {
    "service": "erp",
    "documentId": "46091949-3c11-414b-9157-994f3048e568",
    "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": "24",
      "expectedRevision": 5
    }
  ]
}'
```

JavaScript

```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": "90aebca5-208b-47dd-9e6d-c9159d4aab06",
    "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
    "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
    "occurredAt": "2026-11-23T07:12:00Z",
    "source": {
      "service": "erp",
      "documentId": "46091949-3c11-414b-9157-994f3048e568",
      "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": "24",
        "expectedRevision": 5
      }
    ]
  }),
});
const result = await response.json();
```

Python

```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': '90aebca5-208b-47dd-9e6d-c9159d4aab06',
        'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
        'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
        'occurredAt': '2026-11-23T07:12:00Z',
        'source': {
            'service': 'erp',
            'documentId': '46091949-3c11-414b-9157-994f3048e568',
            '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': '24',
                'expectedRevision': 5,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "90aebca5-208b-47dd-9e6d-c9159d4aab06",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:12:00Z",
  "source": {
    "service": "erp",
    "documentId": "46091949-3c11-414b-9157-994f3048e568",
    "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": "24",
      "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#

```csharp
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": "90aebca5-208b-47dd-9e6d-c9159d4aab06",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:12:00Z",
  "source": {
    "service": "erp",
    "documentId": "46091949-3c11-414b-9157-994f3048e568",
    "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": "24",
      "expectedRevision": 5
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "90aebca5-208b-47dd-9e6d-c9159d4aab06",
  "status": "completed",
  "aggregateRevision": 6,
  "movementIds": [
    "771d53db-5d2c-4a12-b9a6-bb3c86e5eeea"
  ]
}
```

-   Create the `operationId` when you decide to make the change, and store it before you send the request.
-   After a timeout or a lost answer, send the request again with the same `operationId`.
-   Use a new `operationId` for a new change. [Operations](https://inventory.rdcopilot.com/docs/api-reference/operations/) shows how to read an outcome later.

## Concurrent changes

A record has a revision that grows with every change. To change an existing record, send the revision you read as `expectedRevision`. If the record has changed since, the request is refused and nothing is applied.

## Conflicts

| Situation | Status | Code |
| --- | --- | --- |
| The same `operationId` and the same request. | `202` | The first outcome, again |
| The same `operationId` with a different request. | `409` | `operation_reused` |
| An `expectedRevision` that is no longer current. | `409` | `revision_conflict` |

On a 409 for a revision, read the record again, decide whether your change still applies and send it with a new `operationId`.

The full rule: [Developer guide](https://rdcopilot.com/docs/idempotency/)
