---
title: "Counts | Docs | Inventory by R&D Copilot"
description: "Set the quantity on hand to what was counted. The movement carries the difference."
canonical: "https://inventory.rdcopilot.com/docs/api-reference/counts/"
language: en
updated: 2026-11-22
---

# Counts

Set the quantity on hand to what was counted. The movement carries the difference.

## Record a count

POST `/inventory/v1/counts`

Sets the quantity on hand of each line to the counted quantity. The movement carries the difference, and is recorded even when the difference is zero. A count below what is reserved is refused.

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this command. Send the same command again with the same `operationId` to get the first outcome. |
| `customerOrgId` | `string (uuid)` | Yesrequired | Your organisation. It must be the one of the token. |
| `legalCompanyId` | `string (uuid)` | Yesrequired | The company the stock belongs to. It must be one of the companies of the token. |
| `occurredAt` | `string (date-time)` | Yesrequired | When the change happened in the world, with a time zone, for example `2026-11-23T07:12:00Z`. |
| `source` | `Source` | Yesrequired | Where the change comes from. It is stored with each movement. |
| `source.service` | `string` | Yesrequired | The system that sends the command, for example `erp` or `pos`. |
| `source.documentId` | `string (uuid)` | Yesrequired | The document that causes the change: the order, the goods receipt, the delivery. |
| `source.documentType` | `string` | Yesrequired | The kind of that document, for example `sales-order` or `goods-receipt`. |
| `source.documentRevision` | `integer` | Yesrequired | The revision of the document, from 1. |
| `actor` | `Actor` | Yesrequired | Who made the change. It is stored with each movement. |
| `actor.serviceId` | `string` | Yesrequired | The client that sends the command. It must be the client of the token. |
| `actor.userId` | `string (uuid)` | Nooptional | The person on whose behalf the client acts, or `null`. It must match the token. |
| `lines` | `CountLine[]` | Yesrequired | One to 100 lines. All lines apply, or none does. An item appears once per location in one command. |
| `lines[].productId` | `string (uuid)` | Yesrequired | The item, by the id your catalogue gives it. |
| `lines[].locationId` | `string (uuid)` | Yesrequired | The location: a warehouse, a cold room or a shop of the company. |
| `lines[].countedQuantity` | `NonnegativeQuantity` | Yesrequired | What was counted, as a decimal string. It cannot be below what is reserved. |
| `lines[].expectedRevision` | `integer` | Yesrequired | The revision of the balance you read. The command is refused when the balance has moved on. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The command was applied once. The body is the operation result: `aggregateRevision` is the highest revision any balance of the command reached, and `movementIds` lists the movements it recorded, in the order of its lines. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict` or `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `insufficient_available_stock` or `quantity_limit_exceeded`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/counts" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "28c671aa-ac3c-42f9-8f8d-b10b6a841893",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:47:00Z",
  "source": {
    "service": "erp",
    "documentId": "6ca66dfa-592c-42b8-a3c8-306c333ac0c1",
    "documentType": "stock-count",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6ab0e654-0031-4eef-8a67-ac3fa8378fe1",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "countedQuantity": "77.5",
      "expectedRevision": 4
    }
  ]
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/counts`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "28c671aa-ac3c-42f9-8f8d-b10b6a841893",
    "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
    "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
    "occurredAt": "2026-11-23T07:47:00Z",
    "source": {
      "service": "erp",
      "documentId": "6ca66dfa-592c-42b8-a3c8-306c333ac0c1",
      "documentType": "stock-count",
      "documentRevision": 1
    },
    "actor": {
      "serviceId": "brumar-erp",
      "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
    },
    "lines": [
      {
        "productId": "6ab0e654-0031-4eef-8a67-ac3fa8378fe1",
        "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
        "countedQuantity": "77.5",
        "expectedRevision": 4
      }
    ]
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/inventory/v1/counts',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '28c671aa-ac3c-42f9-8f8d-b10b6a841893',
        'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
        'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
        'occurredAt': '2026-11-23T07:47:00Z',
        'source': {
            'service': 'erp',
            'documentId': '6ca66dfa-592c-42b8-a3c8-306c333ac0c1',
            'documentType': 'stock-count',
            'documentRevision': 1,
        },
        'actor': {
            'serviceId': 'brumar-erp',
            'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
        },
        'lines': [
            {
                'productId': '6ab0e654-0031-4eef-8a67-ac3fa8378fe1',
                'locationId': '8c8dcdb9-531e-496f-8f12-aadf9acd1eef',
                'countedQuantity': '77.5',
                'expectedRevision': 4,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "28c671aa-ac3c-42f9-8f8d-b10b6a841893",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:47:00Z",
  "source": {
    "service": "erp",
    "documentId": "6ca66dfa-592c-42b8-a3c8-306c333ac0c1",
    "documentType": "stock-count",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6ab0e654-0031-4eef-8a67-ac3fa8378fe1",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "countedQuantity": "77.5",
      "expectedRevision": 4
    }
  ]
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/counts');
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/counts");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "28c671aa-ac3c-42f9-8f8d-b10b6a841893",
  "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
  "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
  "occurredAt": "2026-11-23T07:47:00Z",
  "source": {
    "service": "erp",
    "documentId": "6ca66dfa-592c-42b8-a3c8-306c333ac0c1",
    "documentType": "stock-count",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "brumar-erp",
    "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
  },
  "lines": [
    {
      "productId": "6ab0e654-0031-4eef-8a67-ac3fa8378fe1",
      "locationId": "8c8dcdb9-531e-496f-8f12-aadf9acd1eef",
      "countedQuantity": "77.5",
      "expectedRevision": 4
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "28c671aa-ac3c-42f9-8f8d-b10b6a841893",
  "status": "completed",
  "aggregateRevision": 5,
  "movementIds": [
    "aca7413f-e78f-4193-bca7-0d31e2a0adf7"
  ]
}
```
