---
title: "Your first request | Developer guide | R&D Copilot"
lang: en
canonical: https://rdcopilot.com/docs/first-request/
content_version: 2276da60ed3e292539e8a7e39292d3ad280535deba1d229db90258ac5af50162
contact: https://rdcopilot.com/contact/
---

# Your first request

Five steps that work on any product: get a token, read a list, send a change, read its outcome and receive the event.

This page reserves 24 bags of flour for a sales order with the Inventory API, in five requests that work the same way on every product.

You need the client id and the secret of your test company, the token address and the base address. They come with your account: see [Accounts and access](https://rdcopilot.com/docs/accounts/). The samples read them from the environment as `$RDC_TOKEN_URL`, `$RDC_CLIENT_ID`, `$RDC_CLIENT_SECRET`, `$RDC_BASE_URL` and `$RDC_TOKEN`.

## Step 1: get a token

Ask the sign-in service for a token, then keep it in `$RDC_TOKEN`. [API authentication](https://rdcopilot.com/docs/authentication/) has the request in full.

Token request

```bash
curl -X POST "$RDC_TOKEN_URL" \
  -d "grant_type=client_credentials" \
  -d "client_id=$RDC_CLIENT_ID" \
  -d "client_secret=$RDC_CLIENT_SECRET" \
  -d "scope=inventory.access"
```

Answer 200

```json
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.e30.c2lnbmF0dXJl",
  "token_type": "Bearer",
  "expires_in": 300
}
```

## Step 2: read a list

Read the movements of the flour. A list answers `items` and `nextCursor`. The `resultingRevision` of the newest movement, 7, is the revision of the balance now: the change you send next carries it as `expectedRevision`.

Read the movements

curl

```bash
curl "$RDC_BASE_URL/inventory/v1/items/7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40/movements?limit=2" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/items/7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40/movements?limit=2`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/inventory/v1/items/7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40/movements?limit=2',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/items/7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40/movements?limit=2');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$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.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/inventory/v1/items/7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40/movements?limit=2");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Answer 200

```json
{
  "items": [
    {
      "movementId": "0d6f3c91-8a25-4b47-b1e0-4c7a9e2d5f18",
      "kind": "receipt",
      "onHandDelta": "120",
      "reservedDelta": "0",
      "resultingRevision": 6
    },
    {
      "movementId": "6a1e8d52-3c07-4f94-a2b8-e5d0c71f9a36",
      "kind": "receipt",
      "onHandDelta": "60",
      "reservedDelta": "0",
      "resultingRevision": 7
    }
  ],
  "nextCursor": null
}
```

## Step 3: send a change

A change carries an `operationId` that you choose, a UUID, and the revision you read as `expectedRevision`. The answer is a 202 with the result of the operation.

Reserve the flour

curl

```bash
curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "customerOrgId": "a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34",
  "legalCompanyId": "c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68",
  "occurredAt": "2026-11-20T09:41:05Z",
  "source": {
    "service": "erp",
    "documentId": "4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63",
    "documentType": "sales-order",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "erp",
    "userId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25"
  },
  "lines": [
    {
      "productId": "7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40",
      "locationId": "1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164",
      "quantity": "24",
      "expectedRevision": 7
    }
  ]
}'
```

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": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
    "customerOrgId": "a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34",
    "legalCompanyId": "c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68",
    "occurredAt": "2026-11-20T09:41:05Z",
    "source": {
      "service": "erp",
      "documentId": "4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63",
      "documentType": "sales-order",
      "documentRevision": 1
    },
    "actor": {
      "serviceId": "erp",
      "userId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25"
    },
    "lines": [
      {
        "productId": "7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40",
        "locationId": "1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164",
        "quantity": "24",
        "expectedRevision": 7
      }
    ]
  }),
});
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': '3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94',
        'customerOrgId': 'a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34',
        'legalCompanyId': 'c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68',
        'occurredAt': '2026-11-20T09:41:05Z',
        'source': {
            'service': 'erp',
            'documentId': '4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63',
            'documentType': 'sales-order',
            'documentRevision': 1,
        },
        'actor': {
            'serviceId': 'erp',
            'userId': '9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25',
        },
        'lines': [
            {
                'productId': '7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40',
                'locationId': '1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164',
                'quantity': '24',
                'expectedRevision': 7,
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "customerOrgId": "a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34",
  "legalCompanyId": "c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68",
  "occurredAt": "2026-11-20T09:41:05Z",
  "source": {
    "service": "erp",
    "documentId": "4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63",
    "documentType": "sales-order",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "erp",
    "userId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25"
  },
  "lines": [
    {
      "productId": "7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40",
      "locationId": "1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164",
      "quantity": "24",
      "expectedRevision": 7
    }
  ]
}
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": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "customerOrgId": "a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34",
  "legalCompanyId": "c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68",
  "occurredAt": "2026-11-20T09:41:05Z",
  "source": {
    "service": "erp",
    "documentId": "4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63",
    "documentType": "sales-order",
    "documentRevision": 1
  },
  "actor": {
    "serviceId": "erp",
    "userId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25"
  },
  "lines": [
    {
      "productId": "7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40",
      "locationId": "1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164",
      "quantity": "24",
      "expectedRevision": 7
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Answer 202

```json
{
  "operationId": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "status": "completed",
  "aggregateRevision": 8,
  "movementIds": [
    "f2a95c08-6d41-4e7b-83a0-b7d14e92c5a6"
  ]
}
```

## Step 4: read the outcome

Ask for the operation by the `operationId` you sent. You get the outcome each time you ask. After `completed` or `rejected` it no longer changes.

Read the operation

curl

```bash
curl "$RDC_BASE_URL/inventory/v1/operations/3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/operations/3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/inventory/v1/operations/3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/operations/3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$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.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/inventory/v1/operations/3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Answer 200

```json
{
  "operationId": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "status": "completed",
  "aggregateRevision": 8,
  "movementIds": [
    "f2a95c08-6d41-4e7b-83a0-b7d14e92c5a6"
  ]
}
```

## Step 5: receive the event

The reservation is a movement, and a movement is an event. If your account has a subscription for the type, your endpoint receives this delivery. [Webhooks](https://rdcopilot.com/docs/webhooks/) shows how to register the endpoint, and [Verify signatures](https://rdcopilot.com/docs/signatures/) how to check the delivery.

The event

```json
{
  "specversion": "1.0",
  "id": "5e2b9c47-8d13-4a6f-b0e5-71c4a2d93f68",
  "type": "com.rdcopilot.inventory.movement.v1",
  "source": "urn:rdcopilot:service:inventory-runtime",
  "time": "2026-11-20T09:41:07Z",
  "customerOrgId": "a3f1d7c2-64be-4b09-9d58-2c0e7f1a8b34",
  "legalCompanyId": "c8b25e90-1d47-4f3a-a6d2-93e0b51f7c68",
  "aggregateType": "inventory-balance",
  "aggregateId": "e17d3b60-4a98-4c25-9f02-6b8a1d5c7e39",
  "aggregateRevision": 8,
  "correlationId": "3b7e41a8-9c25-4d60-b8f3-1a05e6d27c94",
  "causationId": "4c8a1f72-e6b9-4d35-a0c8-5b2e9d7f1a63",
  "actor": {
    "serviceId": "erp",
    "userId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25"
  },
  "data": {
    "movementId": "f2a95c08-6d41-4e7b-83a0-b7d14e92c5a6",
    "productId": "7d0c4e19-b3a2-4f65-8e91-2a6f5c8d3b40",
    "locationId": "1b9e6a35-d4c7-4082-b5f3-9e0a7c2d8164",
    "onHandDelta": "0",
    "reservedDelta": "24"
  }
}
```

| Step | Request | What you keep |
| --- | --- | --- |
| 1 | `POST` to the token address | `access_token`, until `expires_in` has passed |
| 2 | `GET /items/{productId}/movements` | The revision of the balance, `7` |
| 3 | `POST /reservations` | The `operationId` and `aggregateRevision`, `8` |
| 4 | `GET /operations/{operationId}` | The outcome |
| 5 | A `POST` of the event to your endpoint | The `id` of the event, so a repeat is skipped |

## Now in your product

Every product has the same five steps with its own resources. The Quickstart of each live product repeats them with its own requests.

## In the product docs

-   [ERP: Quickstart](https://erp.rdcopilot.com/docs/get-started/quickstart/)
-   [Inventory: Quickstart](https://inventory.rdcopilot.com/docs/get-started/quickstart/)
-   [WMS: Quickstart](https://warehouse.rdcopilot.com/docs/get-started/quickstart/)
-   [POS: Quickstart](https://pos.rdcopilot.com/docs/get-started/quickstart/)
-   [Self-Checkout: Quickstart](https://checkout.rdcopilot.com/docs/get-started/quickstart/)
-   [Accounting: Quickstart](https://accounting.rdcopilot.com/docs/get-started/quickstart/)
-   [Treasury: Quickstart](https://banking.rdcopilot.com/docs/get-started/quickstart/)
-   [HR: Quickstart](https://hr.rdcopilot.com/docs/get-started/quickstart/)
-   [Payroll: Quickstart](https://payroll.rdcopilot.com/docs/get-started/quickstart/)
-   [eLearning: Quickstart](https://elearning.rdcopilot.com/docs/get-started/quickstart/)
-   [CRM: Quickstart](https://crm.rdcopilot.com/docs/get-started/quickstart/)
-   [AI Assistant: Quickstart](https://ai.rdcopilot.com/docs/get-started/quickstart/)
-   [Private AI Workspace: Quickstart](https://private-ai.rdcopilot.com/docs/get-started/quickstart/)
-   [DMS: Quickstart](https://documents.rdcopilot.com/docs/get-started/quickstart/)
-   [BI: Quickstart](https://reports.rdcopilot.com/docs/get-started/quickstart/)
-   [IoT: Quickstart](https://iot.rdcopilot.com/docs/get-started/quickstart/)
-   [e-Factura Gateway: Quickstart](https://efactura.rdcopilot.com/docs/get-started/quickstart/)
-   [e-TVA Check: Quickstart](https://etva.rdcopilot.com/docs/get-started/quickstart/)
-   [e-Transport Gateway: Quickstart](https://etransport.rdcopilot.com/docs/get-started/quickstart/)
-   [Tax Filing: Quickstart](https://declarations.rdcopilot.com/docs/get-started/quickstart/)
-   [REGES Gateway: Quickstart](https://reges.rdcopilot.com/docs/get-started/quickstart/)
-   [Integrations: Quickstart](https://integrations.rdcopilot.com/docs/get-started/quickstart/)

## Related pages

-   [Requests and responses](https://rdcopilot.com/docs/requests/): addresses, headers and formats.
-   [Idempotency and retries](https://rdcopilot.com/docs/idempotency/): what to do when an answer is lost.

[Previous · **API authentication**](https://rdcopilot.com/docs/authentication/) [Next · **Test and live**](https://rdcopilot.com/docs/environments/)

---

R&D Copilot · Made in EU · Contact: https://rdcopilot.com/contact/
