---
title: "Reserve for an order | Docs | Inventory by R&D Copilot"
description: "Promise stock to a sales order, deal with a shortage, release a reservation and deliver from it."
canonical: "https://inventory.rdcopilot.com/docs/guides/reserve-for-an-order/"
language: en
updated: 2026-11-22
---

# Reserve for an order

Promise stock to a sales order, deal with a shortage, release a reservation and deliver from it.

A reservation lowers what is available and leaves what is on hand as it is, so a second order cannot be promised the same goods. Your ERP sends it when an order is confirmed.

## One command for the order

Put every line of the order in one command, each with the revision you read for its item and location, and name the order as the `source` document. The command applies completely or not at all, so a half-reserved order is never left behind.

Reserve the lines that are available

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "de64affa-6837-4535-9f4a-6f7b0e92d0f5",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}'
```

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": "de64affa-6837-4535-9f4a-6f7b0e92d0f5",
    "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
      },
      {
        "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "60",
        "expectedRevision": 4
      },
      {
        "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
        "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
        "quantity": "36",
        "expectedRevision": 3
      },
      {
        "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "12",
        "expectedRevision": 2
      },
      {
        "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "9",
        "expectedRevision": 2
      }
    ]
  }),
});
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': 'de64affa-6837-4535-9f4a-6f7b0e92d0f5',
        '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,
            },
            {
                'productId': '23a094cb-e749-43ec-8511-1efc07cd1898',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '60',
                'expectedRevision': 4,
            },
            {
                'productId': '38fe460a-7ee6-4567-8107-1411bcb13101',
                'locationId': '8c8dcdb9-531e-496f-8f12-aadf9acd1eef',
                'quantity': '36',
                'expectedRevision': 3,
            },
            {
                'productId': '15f915de-4c01-4b18-97cc-51e4f38788c3',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '12',
                'expectedRevision': 2,
            },
            {
                'productId': 'e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '9',
                'expectedRevision': 2,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "de64affa-6837-4535-9f4a-6f7b0e92d0f5",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}
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": "de64affa-6837-4535-9f4a-6f7b0e92d0f5",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "de64affa-6837-4535-9f4a-6f7b0e92d0f5",
  "status": "completed",
  "aggregateRevision": 6,
  "movementIds": [
    "c082d294-3226-4c0b-86d7-8a75b4d050bb",
    "d361dfb0-d024-4eae-9174-3f4f47f814e4",
    "7c15f5c1-d0a2-45a3-acd5-51654d45d442",
    "549ba67e-f498-46e3-b228-083b889f1a70",
    "934b24f8-4dfe-4dbb-bf1a-fe0359caaa2d"
  ]
}
```

## When a line is short

If one line asks for more than is available, the answer is a 422 with `insufficient_available_stock` and not one line of the command is reserved. Here the same order with 80 bags of sugar, of which 55 are available:

A command with a short line

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "a1db0690-4000-4bcd-b672-69dc5ee2e789",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "80",
      "expectedRevision": 7
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}'
```

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": "a1db0690-4000-4bcd-b672-69dc5ee2e789",
    "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
      },
      {
        "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "60",
        "expectedRevision": 4
      },
      {
        "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "80",
        "expectedRevision": 7
      },
      {
        "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
        "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
        "quantity": "36",
        "expectedRevision": 3
      },
      {
        "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "12",
        "expectedRevision": 2
      },
      {
        "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "9",
        "expectedRevision": 2
      }
    ]
  }),
});
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': 'a1db0690-4000-4bcd-b672-69dc5ee2e789',
        '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,
            },
            {
                'productId': '23a094cb-e749-43ec-8511-1efc07cd1898',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '60',
                'expectedRevision': 4,
            },
            {
                'productId': '11079e9a-344b-409c-8da5-e8335a7846b1',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '80',
                'expectedRevision': 7,
            },
            {
                'productId': '38fe460a-7ee6-4567-8107-1411bcb13101',
                'locationId': '8c8dcdb9-531e-496f-8f12-aadf9acd1eef',
                'quantity': '36',
                'expectedRevision': 3,
            },
            {
                'productId': '15f915de-4c01-4b18-97cc-51e4f38788c3',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '12',
                'expectedRevision': 2,
            },
            {
                'productId': 'e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '9',
                'expectedRevision': 2,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "a1db0690-4000-4bcd-b672-69dc5ee2e789",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "80",
      "expectedRevision": 7
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}
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": "a1db0690-4000-4bcd-b672-69dc5ee2e789",
  "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
    },
    {
      "productId": "23a094cb-e749-43ec-8511-1efc07cd1898",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "60",
      "expectedRevision": 4
    },
    {
      "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "80",
      "expectedRevision": 7
    },
    {
      "productId": "38fe460a-7ee6-4567-8107-1411bcb13101",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "quantity": "36",
      "expectedRevision": 3
    },
    {
      "productId": "15f915de-4c01-4b18-97cc-51e4f38788c3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "12",
      "expectedRevision": 2
    },
    {
      "productId": "e47ce7d0-7bb7-428b-9ca4-6e7f9b911d4e",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "9",
      "expectedRevision": 2
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 422

```json
{
  "code": "insufficient_available_stock",
  "message": "There is not enough available stock for this change.",
  "requestId": "req_4f9d2a7c1b6e8035"
}
```

Read the availability of the short line and decide: reserve what is available now, wait for a receipt, or tell the customer. Reserve the other lines in their own command so one shortage does not hold up the rest.

## Release a reservation

There is no release command. When an order is cancelled or changed before delivery, reverse the reservation movement. The reserved quantity falls by what the movement added, and the stock is available again. See [Reverse a movement](https://inventory.rdcopilot.com/docs/guides/reverse-a-movement/).

Release the reservation of order CV-1042

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/reversals" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "98dd4854-2b55-4630-bceb-3e9088576497",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19: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": [
    {
      "movementId": "771d53db-5d2c-4a12-b9a6-bb3c86e5eeea",
      "expectedRevision": 6
    }
  ]
}'
```

JavaScript

```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": "98dd4854-2b55-4630-bceb-3e9088576497",
    "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
    "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
    "occurredAt": "2026-11-23T07:19: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": [
      {
        "movementId": "771d53db-5d2c-4a12-b9a6-bb3c86e5eeea",
        "expectedRevision": 6
      }
    ]
  }),
});
const result = await response.json();
```

Python

```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': '98dd4854-2b55-4630-bceb-3e9088576497',
        'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
        'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
        'occurredAt': '2026-11-23T07:19: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': [
            {
                'movementId': '771d53db-5d2c-4a12-b9a6-bb3c86e5eeea',
                'expectedRevision': 6,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "98dd4854-2b55-4630-bceb-3e9088576497",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19: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": [
    {
      "movementId": "771d53db-5d2c-4a12-b9a6-bb3c86e5eeea",
      "expectedRevision": 6
    }
  ]
}
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#

```csharp
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": "98dd4854-2b55-4630-bceb-3e9088576497",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19: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": [
    {
      "movementId": "771d53db-5d2c-4a12-b9a6-bb3c86e5eeea",
      "expectedRevision": 6
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "98dd4854-2b55-4630-bceb-3e9088576497",
  "status": "completed",
  "aggregateRevision": 7,
  "movementIds": [
    "27a88314-939f-4940-a2a3-5d3af0f713b8"
  ]
}
```

## Deliver from the reservation

At delivery, send a sale with `reservedQuantity` equal to the reserved part of each line. That part leaves `onHand` and `reserved` together; see [On hand, reserved, available](https://inventory.rdcopilot.com/docs/concepts/on-hand-reserved-available/).

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/sales" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19:00Z",
  "source": {
    "service": "erp",
    "documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
    "documentType": "delivery",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "24",
      "expectedRevision": 6,
      "reservedQuantity": "24"
    }
  ]
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/sales`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
    "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
    "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
    "occurredAt": "2026-11-23T07:19:00Z",
    "source": {
      "service": "erp",
      "documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
      "documentType": "delivery",
      "documentRevision": 1
    },
    "actor": {
      "serviceId": "brumar-erp",
      "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
    },
    "lines": [
      {
        "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
        "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
        "quantity": "24",
        "expectedRevision": 6,
        "reservedQuantity": "24"
      }
    ]
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/inventory/v1/sales',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '87e846f9-6aaa-4b7c-b145-f59827ed2ae6',
        'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
        'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
        'occurredAt': '2026-11-23T07:19:00Z',
        'source': {
            'service': 'erp',
            'documentId': '1e341639-829d-43ef-a1c9-10edb27894b4',
            'documentType': 'delivery',
            'documentRevision': 1,
        },
        'actor': {
            'serviceId': 'brumar-erp',
            'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
        },
        'lines': [
            {
                'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
                'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                'quantity': '24',
                'expectedRevision': 6,
                'reservedQuantity': '24',
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19:00Z",
  "source": {
    "service": "erp",
    "documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
    "documentType": "delivery",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "24",
      "expectedRevision": 6,
      "reservedQuantity": "24"
    }
  ]
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/sales');
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/sales");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:19:00Z",
  "source": {
    "service": "erp",
    "documentId": "1e341639-829d-43ef-a1c9-10edb27894b4",
    "documentType": "delivery",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
      "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
      "quantity": "24",
      "expectedRevision": 6,
      "reservedQuantity": "24"
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "87e846f9-6aaa-4b7c-b145-f59827ed2ae6",
  "status": "completed",
  "aggregateRevision": 7,
  "movementIds": [
    "e3b706f6-4600-4e18-9e43-1e9469adc3be"
  ]
}
```
