Skip to content
Docs
API 1.0.0 · 22 Nov 2026

Search the docs

    Română

    Idempotency and concurrency

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

    On this page

    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

    curl -X POST "$RDC_BASE_URL/etva/v1/periods" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "1c9ec2c0-b193-4230-afa2-187fd51040ce",
      "companyId": "b61159f8-9c0b-4cdb-ac61-afb49517aae6",
      "month": "2026-10",
      "scheme": "standard"
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/etva/v1/periods`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "1c9ec2c0-b193-4230-afa2-187fd51040ce",
        "companyId": "b61159f8-9c0b-4cdb-ac61-afb49517aae6",
        "month": "2026-10",
        "scheme": "standard"
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/etva/v1/periods',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '1c9ec2c0-b193-4230-afa2-187fd51040ce',
            'companyId': 'b61159f8-9c0b-4cdb-ac61-afb49517aae6',
            'month': '2026-10',
            'scheme': 'standard',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "1c9ec2c0-b193-4230-afa2-187fd51040ce",
      "companyId": "b61159f8-9c0b-4cdb-ac61-afb49517aae6",
      "month": "2026-10",
      "scheme": "standard"
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/etva/v1/periods');
    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")}/etva/v1/periods");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "1c9ec2c0-b193-4230-afa2-187fd51040ce",
      "companyId": "b61159f8-9c0b-4cdb-ac61-afb49517aae6",
      "month": "2026-10",
      "scheme": "standard"
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 202

    {
      "operationId": "1c9ec2c0-b193-4230-afa2-187fd51040ce",
      "status": "accepted",
      "aggregateId": "74859c26-2e95-422e-bfbd-fe95f1d0851d",
      "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 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

    SituationStatusCode
    The same operationId and the same request.202The first outcome, again
    The same operationId with a different request.409operation_reused
    An expectedRevision that is no longer current.409revision_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