Skip to content
Docs
API 1.0.0 · 22 Nov 2026

Search the docs

    Română

    Reverse a movement

    Correct a mistake, release a reservation or undo a transfer with a new movement that is linked to the old one.

    On this page

    A movement is never edited. A reversal records the opposite quantities as a new movement and links it to the first with reversesMovementId. The first movement stays in the history, and the stock card shows both.

    Send a reversal

    1. Find the movement

      Read the stock card of the item and take the movementId. The operationId and the source of a movement tell you which command and which document it came from.

    2. Read the balance

      Read the availability of the item at the location of the movement. Its revision is the expectedRevision of the line, as the balance is now, not as it was when the movement was recorded.

    3. Send it

      One line per movement. Several movements can be reversed in one command.

    curl

    curl -X POST "$RDC_BASE_URL/inventory/v1/reversals" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "40808f70-a0b4-4c08-a7d5-c044f87dc492",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:54:00Z",
      "source": {
        "service": "erp",
        "documentId": "4260e572-9d0e-4f8d-b559-5a31081823cb",
        "documentType": "sales-return",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "1c17aa8d-9929-42a5-8b31-340db603d4fc",
          "expectedRevision": 9
        }
      ]
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/reversals`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "40808f70-a0b4-4c08-a7d5-c044f87dc492",
        "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
        "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
        "occurredAt": "2026-11-23T07:54:00Z",
        "source": {
          "service": "erp",
          "documentId": "4260e572-9d0e-4f8d-b559-5a31081823cb",
          "documentType": "sales-return",
          "documentRevision": 1
        },
        "actor": {
          "serviceId": "brumar-erp",
          "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
        },
        "lines": [
          {
            "movementId": "1c17aa8d-9929-42a5-8b31-340db603d4fc",
            "expectedRevision": 9
          }
        ]
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/inventory/v1/reversals',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '40808f70-a0b4-4c08-a7d5-c044f87dc492',
            'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
            'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
            'occurredAt': '2026-11-23T07:54:00Z',
            'source': {
                'service': 'erp',
                'documentId': '4260e572-9d0e-4f8d-b559-5a31081823cb',
                'documentType': 'sales-return',
                'documentRevision': 1,
            },
            'actor': {
                'serviceId': 'brumar-erp',
                'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
            },
            'lines': [
                {
                    'movementId': '1c17aa8d-9929-42a5-8b31-340db603d4fc',
                    'expectedRevision': 9,
                },
            ],
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "40808f70-a0b4-4c08-a7d5-c044f87dc492",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:54:00Z",
      "source": {
        "service": "erp",
        "documentId": "4260e572-9d0e-4f8d-b559-5a31081823cb",
        "documentType": "sales-return",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "1c17aa8d-9929-42a5-8b31-340db603d4fc",
          "expectedRevision": 9
        }
      ]
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/reversals');
    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/reversals");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "40808f70-a0b4-4c08-a7d5-c044f87dc492",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:54:00Z",
      "source": {
        "service": "erp",
        "documentId": "4260e572-9d0e-4f8d-b559-5a31081823cb",
        "documentType": "sales-return",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "1c17aa8d-9929-42a5-8b31-340db603d4fc",
          "expectedRevision": 9
        }
      ]
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 202

    {
      "operationId": "40808f70-a0b4-4c08-a7d5-c044f87dc492",
      "status": "completed",
      "aggregateRevision": 10,
      "movementIds": [
        "a77acc7f-ee37-4001-8f72-d5e9270ab07e"
      ]
    }

    What can be reversed

    StatusCodeWhen
    422movement_already_reversedThe movement already has a reversal. A movement is reversed once.
    422invalid_reversalThe movement is itself a reversal. Record the change again as a new movement.
    422insufficient_available_stockThe opposite quantities would leave a balance with less on hand than reserved. For example, a receipt cannot be reversed after its goods were sold.
    409revision_conflictThe balance moved since you read it.
    404movement_not_foundThe movement does not exist, is in a location the token does not cover, or is named twice in the command.

    A reservation

    Reverse the reservation movement. reservedDelta of the reversal is the opposite of the reservation, so the stock is available again. See Reserve for an order.

    A transfer

    A transfer is two movements and is reversed as one. Name both in one command, each with the revision of its own balance.

    Reverse both movements of a transfer

    curl

    curl -X POST "$RDC_BASE_URL/inventory/v1/reversals" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "a90290ca-6638-49b2-a3e2-de1cf6ae1fc3",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        },
        {
          "movementId": "cec159cc-3aa3-498f-ae0a-efdb5d0cfe49",
          "expectedRevision": 5
        }
      ]
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/reversals`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "a90290ca-6638-49b2-a3e2-de1cf6ae1fc3",
        "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
        "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
        "occurredAt": "2026-11-23T08:01:00Z",
        "source": {
          "service": "erp",
          "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
          "documentType": "stock-transfer",
          "documentRevision": 1
        },
        "actor": {
          "serviceId": "brumar-erp",
          "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
        },
        "lines": [
          {
            "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
            "expectedRevision": 5
          },
          {
            "movementId": "cec159cc-3aa3-498f-ae0a-efdb5d0cfe49",
            "expectedRevision": 5
          }
        ]
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/inventory/v1/reversals',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': 'a90290ca-6638-49b2-a3e2-de1cf6ae1fc3',
            'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
            'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
            'occurredAt': '2026-11-23T08:01:00Z',
            'source': {
                'service': 'erp',
                'documentId': '2bd25099-3b4b-4a8a-9f3a-beb62ca79072',
                'documentType': 'stock-transfer',
                'documentRevision': 1,
            },
            'actor': {
                'serviceId': 'brumar-erp',
                'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
            },
            'lines': [
                {
                    'movementId': '6c5e91a6-ee64-4652-8768-44120551279d',
                    'expectedRevision': 5,
                },
                {
                    'movementId': 'cec159cc-3aa3-498f-ae0a-efdb5d0cfe49',
                    'expectedRevision': 5,
                },
            ],
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "a90290ca-6638-49b2-a3e2-de1cf6ae1fc3",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        },
        {
          "movementId": "cec159cc-3aa3-498f-ae0a-efdb5d0cfe49",
          "expectedRevision": 5
        }
      ]
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/reversals');
    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/reversals");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "a90290ca-6638-49b2-a3e2-de1cf6ae1fc3",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        },
        {
          "movementId": "cec159cc-3aa3-498f-ae0a-efdb5d0cfe49",
          "expectedRevision": 5
        }
      ]
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 202

    {
      "operationId": "a90290ca-6638-49b2-a3e2-de1cf6ae1fc3",
      "status": "completed",
      "aggregateRevision": 6,
      "movementIds": [
        "7a65bc9f-93c7-4bcf-ba8c-0654f821308a",
        "638bbaaf-a15e-42f0-99ad-24974126895d"
      ]
    }

    Naming only one of the two is refused:

    Only one movement of the transfer

    curl

    curl -X POST "$RDC_BASE_URL/inventory/v1/reversals" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "d5ccd564-2496-44b7-bd3f-d9ca3e1a23d6",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        }
      ]
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/reversals`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "d5ccd564-2496-44b7-bd3f-d9ca3e1a23d6",
        "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
        "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
        "occurredAt": "2026-11-23T08:01:00Z",
        "source": {
          "service": "erp",
          "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
          "documentType": "stock-transfer",
          "documentRevision": 1
        },
        "actor": {
          "serviceId": "brumar-erp",
          "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
        },
        "lines": [
          {
            "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
            "expectedRevision": 5
          }
        ]
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/inventory/v1/reversals',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': 'd5ccd564-2496-44b7-bd3f-d9ca3e1a23d6',
            'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
            'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
            'occurredAt': '2026-11-23T08:01:00Z',
            'source': {
                'service': 'erp',
                'documentId': '2bd25099-3b4b-4a8a-9f3a-beb62ca79072',
                'documentType': 'stock-transfer',
                'documentRevision': 1,
            },
            'actor': {
                'serviceId': 'brumar-erp',
                'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
            },
            'lines': [
                {
                    'movementId': '6c5e91a6-ee64-4652-8768-44120551279d',
                    'expectedRevision': 5,
                },
            ],
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "d5ccd564-2496-44b7-bd3f-d9ca3e1a23d6",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        }
      ]
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/reversals');
    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/reversals");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "d5ccd564-2496-44b7-bd3f-d9ca3e1a23d6",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T08:01:00Z",
      "source": {
        "service": "erp",
        "documentId": "2bd25099-3b4b-4a8a-9f3a-beb62ca79072",
        "documentType": "stock-transfer",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "movementId": "6c5e91a6-ee64-4652-8768-44120551279d",
          "expectedRevision": 5
        }
      ]
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 422

    {
      "code": "transfer_reversal_needs_both_movements",
      "message": "A transfer is reversed with both of its movements.",
      "requestId": "req_4f9d2a7c1b6e8035"
    }