---
title: "Idempotency and concurrency | Docs | e-Transport Gateway 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://etransport.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/etransport/v1/declarations" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "e8c04ac1-44dd-49e2-bc09-9666dec1d95b",
  "companyId": "9a893b65-2286-477f-8eab-61c12f7d6b3e",
  "operationType": "TTN",
  "startDate": "2026-11-24",
  "reference": "LIV-2026-01847",
  "partner": {
    "country": "RO",
    "code": "39172789",
    "name": "Pensiunea Stânca Corbului SRL"
  },
  "transporter": {
    "country": "RO",
    "code": "48290619",
    "name": "Brumar Distribuție SRL"
  },
  "vehicle": "ZZ21BRM",
  "trailers": [],
  "from": {
    "kind": "address",
    "county": 27,
    "locality": "Piatra-Neamț",
    "street": "Str. Depozitelor",
    "number": null,
    "notes": "Rampa 4"
  },
  "to": {
    "kind": "address",
    "county": 27,
    "locality": "Bicaz",
    "street": "Str. Principală",
    "number": null,
    "notes": null
  },
  "goods": [
    {
      "code": "CA-0010",
      "name": "Cartofi albi, sac de 25 kg",
      "tariffCode": "070190",
      "purposeCode": 101,
      "quantity": "20",
      "unit": "XBG",
      "netMass": "500.00",
      "grossMass": "506.00",
      "value": "1100.00"
    },
    {
      "code": "ME-0307",
      "name": "Mere Golden, ladă de 12 kg",
      "tariffCode": "080810",
      "purposeCode": 101,
      "quantity": "10",
      "unit": "XCR",
      "netMass": "120.00",
      "grossMass": "129.00",
      "value": "480.00"
    }
  ],
  "documents": [
    {
      "type": "delivery_note",
      "number": "AV-1047",
      "date": "2026-11-24"
    },
    {
      "type": "invoice",
      "number": "BRD-2026-00426",
      "date": "2026-11-24"
    }
  ],
  "afterOutage": false
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/etransport/v1/declarations`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "e8c04ac1-44dd-49e2-bc09-9666dec1d95b",
    "companyId": "9a893b65-2286-477f-8eab-61c12f7d6b3e",
    "operationType": "TTN",
    "startDate": "2026-11-24",
    "reference": "LIV-2026-01847",
    "partner": {
      "country": "RO",
      "code": "39172789",
      "name": "Pensiunea Stânca Corbului SRL"
    },
    "transporter": {
      "country": "RO",
      "code": "48290619",
      "name": "Brumar Distribuție SRL"
    },
    "vehicle": "ZZ21BRM",
    "trailers": [],
    "from": {
      "kind": "address",
      "county": 27,
      "locality": "Piatra-Neamț",
      "street": "Str. Depozitelor",
      "number": null,
      "notes": "Rampa 4"
    },
    "to": {
      "kind": "address",
      "county": 27,
      "locality": "Bicaz",
      "street": "Str. Principală",
      "number": null,
      "notes": null
    },
    "goods": [
      {
        "code": "CA-0010",
        "name": "Cartofi albi, sac de 25 kg",
        "tariffCode": "070190",
        "purposeCode": 101,
        "quantity": "20",
        "unit": "XBG",
        "netMass": "500.00",
        "grossMass": "506.00",
        "value": "1100.00"
      },
      {
        "code": "ME-0307",
        "name": "Mere Golden, ladă de 12 kg",
        "tariffCode": "080810",
        "purposeCode": 101,
        "quantity": "10",
        "unit": "XCR",
        "netMass": "120.00",
        "grossMass": "129.00",
        "value": "480.00"
      }
    ],
    "documents": [
      {
        "type": "delivery_note",
        "number": "AV-1047",
        "date": "2026-11-24"
      },
      {
        "type": "invoice",
        "number": "BRD-2026-00426",
        "date": "2026-11-24"
      }
    ],
    "afterOutage": false
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/etransport/v1/declarations',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'e8c04ac1-44dd-49e2-bc09-9666dec1d95b',
        'companyId': '9a893b65-2286-477f-8eab-61c12f7d6b3e',
        'operationType': 'TTN',
        'startDate': '2026-11-24',
        'reference': 'LIV-2026-01847',
        'partner': {
            'country': 'RO',
            'code': '39172789',
            'name': 'Pensiunea Stânca Corbului SRL',
        },
        'transporter': {
            'country': 'RO',
            'code': '48290619',
            'name': 'Brumar Distribuție SRL',
        },
        'vehicle': 'ZZ21BRM',
        'trailers': [],
        'from': {
            'kind': 'address',
            'county': 27,
            'locality': 'Piatra-Neamț',
            'street': 'Str. Depozitelor',
            'number': None,
            'notes': 'Rampa 4',
        },
        'to': {
            'kind': 'address',
            'county': 27,
            'locality': 'Bicaz',
            'street': 'Str. Principală',
            'number': None,
            'notes': None,
        },
        'goods': [
            {
                'code': 'CA-0010',
                'name': 'Cartofi albi, sac de 25 kg',
                'tariffCode': '070190',
                'purposeCode': 101,
                'quantity': '20',
                'unit': 'XBG',
                'netMass': '500.00',
                'grossMass': '506.00',
                'value': '1100.00',
            },
            {
                'code': 'ME-0307',
                'name': 'Mere Golden, ladă de 12 kg',
                'tariffCode': '080810',
                'purposeCode': 101,
                'quantity': '10',
                'unit': 'XCR',
                'netMass': '120.00',
                'grossMass': '129.00',
                'value': '480.00',
            },
        ],
        'documents': [
            {
                'type': 'delivery_note',
                'number': 'AV-1047',
                'date': '2026-11-24',
            },
            {
                'type': 'invoice',
                'number': 'BRD-2026-00426',
                'date': '2026-11-24',
            },
        ],
        'afterOutage': False,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "e8c04ac1-44dd-49e2-bc09-9666dec1d95b",
  "companyId": "9a893b65-2286-477f-8eab-61c12f7d6b3e",
  "operationType": "TTN",
  "startDate": "2026-11-24",
  "reference": "LIV-2026-01847",
  "partner": {
    "country": "RO",
    "code": "39172789",
    "name": "Pensiunea Stânca Corbului SRL"
  },
  "transporter": {
    "country": "RO",
    "code": "48290619",
    "name": "Brumar Distribuție SRL"
  },
  "vehicle": "ZZ21BRM",
  "trailers": [],
  "from": {
    "kind": "address",
    "county": 27,
    "locality": "Piatra-Neamț",
    "street": "Str. Depozitelor",
    "number": null,
    "notes": "Rampa 4"
  },
  "to": {
    "kind": "address",
    "county": 27,
    "locality": "Bicaz",
    "street": "Str. Principală",
    "number": null,
    "notes": null
  },
  "goods": [
    {
      "code": "CA-0010",
      "name": "Cartofi albi, sac de 25 kg",
      "tariffCode": "070190",
      "purposeCode": 101,
      "quantity": "20",
      "unit": "XBG",
      "netMass": "500.00",
      "grossMass": "506.00",
      "value": "1100.00"
    },
    {
      "code": "ME-0307",
      "name": "Mere Golden, ladă de 12 kg",
      "tariffCode": "080810",
      "purposeCode": 101,
      "quantity": "10",
      "unit": "XCR",
      "netMass": "120.00",
      "grossMass": "129.00",
      "value": "480.00"
    }
  ],
  "documents": [
    {
      "type": "delivery_note",
      "number": "AV-1047",
      "date": "2026-11-24"
    },
    {
      "type": "invoice",
      "number": "BRD-2026-00426",
      "date": "2026-11-24"
    }
  ],
  "afterOutage": false
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/etransport/v1/declarations');
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")}/etransport/v1/declarations");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "e8c04ac1-44dd-49e2-bc09-9666dec1d95b",
  "companyId": "9a893b65-2286-477f-8eab-61c12f7d6b3e",
  "operationType": "TTN",
  "startDate": "2026-11-24",
  "reference": "LIV-2026-01847",
  "partner": {
    "country": "RO",
    "code": "39172789",
    "name": "Pensiunea Stânca Corbului SRL"
  },
  "transporter": {
    "country": "RO",
    "code": "48290619",
    "name": "Brumar Distribuție SRL"
  },
  "vehicle": "ZZ21BRM",
  "trailers": [],
  "from": {
    "kind": "address",
    "county": 27,
    "locality": "Piatra-Neamț",
    "street": "Str. Depozitelor",
    "number": null,
    "notes": "Rampa 4"
  },
  "to": {
    "kind": "address",
    "county": 27,
    "locality": "Bicaz",
    "street": "Str. Principală",
    "number": null,
    "notes": null
  },
  "goods": [
    {
      "code": "CA-0010",
      "name": "Cartofi albi, sac de 25 kg",
      "tariffCode": "070190",
      "purposeCode": 101,
      "quantity": "20",
      "unit": "XBG",
      "netMass": "500.00",
      "grossMass": "506.00",
      "value": "1100.00"
    },
    {
      "code": "ME-0307",
      "name": "Mere Golden, ladă de 12 kg",
      "tariffCode": "080810",
      "purposeCode": 101,
      "quantity": "10",
      "unit": "XCR",
      "netMass": "120.00",
      "grossMass": "129.00",
      "value": "480.00"
    }
  ],
  "documents": [
    {
      "type": "delivery_note",
      "number": "AV-1047",
      "date": "2026-11-24"
    },
    {
      "type": "invoice",
      "number": "BRD-2026-00426",
      "date": "2026-11-24"
    }
  ],
  "afterOutage": false
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "e8c04ac1-44dd-49e2-bc09-9666dec1d95b",
  "status": "accepted",
  "aggregateId": "0776bc3f-c5ed-4aa8-8f25-40152eee2b42",
  "aggregateRevision": 1
}
```

-   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://etransport.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/)
