---
title: "Prima cerere | Ghidul dezvoltatorului | R&D Copilot"
lang: ro
canonical: https://rdcopilot.com/ro/docs/first-request/
content_version: 994ddf7f407afb6dd8c39015f7b98425f96df247a5243da0c7e6e02a601d8c61
contact: https://rdcopilot.com/ro/contact/
---

# Prima cerere

Cinci pași care merg pe orice produs: obții un token, citești o listă, trimiți o modificare, îi citești rezultatul și primești evenimentul.

Această pagină rezervă 24 de saci de făină pentru o comandă de vânzare, cu API-ul Inventory, în cinci cereri care funcționează la fel pe orice produs.

Ai nevoie de identificatorul de client și de secretul companiei tale de test, de adresa pentru token și de adresa de bază. Le primești odată cu contul: vezi [Conturi și acces](https://rdcopilot.com/ro/docs/accounts/). Exemplele le citesc din mediu ca `$RDC_TOKEN_URL`, `$RDC_CLIENT_ID`, `$RDC_CLIENT_SECRET`, `$RDC_BASE_URL` și `$RDC_TOKEN`.

## Pasul 1: obține un token

Cere serviciului de autentificare un token, apoi păstrează-l în `$RDC_TOKEN`. [Autentificarea în API](https://rdcopilot.com/ro/docs/authentication/) are cererea completă.

Cererea de token

```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"
```

Răspuns 200

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

## Pasul 2: citește o listă

Citește mișcările făinii. O listă răspunde cu `items` și `nextCursor`. `resultingRevision` al celei mai noi mișcări, 7, este revizia curentă a soldului: modificarea pe care o trimiți apoi o include ca `expectedRevision`.

Citește mișcările

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();
```

Răspuns 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
}
```

## Pasul 3: trimite o modificare

O modificare are un `operationId` ales de tine, un UUID, și revizia citită ca `expectedRevision`. Răspunsul este un 202 cu rezultatul operației.

Rezervă făina

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();
```

Răspuns 202

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

## Pasul 4: citește rezultatul

Cere operația după identificatorul `operationId` trimis. Primești rezultatul de fiecare dată când ceri. După `completed` sau `rejected` nu se mai schimbă.

Citește operația

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();
```

Răspuns 200

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

## Pasul 5: primește evenimentul

Rezervarea este o mișcare, iar o mișcare este un eveniment. Dacă în contul tău există un abonament pentru acest tip, endpoint-ul tău primește livrarea de mai jos. [Webhook-uri](https://rdcopilot.com/ro/docs/webhooks/) arată cum înregistrezi endpoint-ul, iar [Verificarea semnăturilor](https://rdcopilot.com/ro/docs/signatures/) cum verifici livrarea.

Evenimentul

```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"
  }
}
```

| Pasul | Cererea | Ce păstrezi |
| --- | --- | --- |
| 1 | `POST` la adresa pentru token | `access_token`, până trec `expires_in` secunde |
| 2 | `GET /items/{productId}/movements` | Revizia soldului, `7` |
| 3 | `POST /reservations` | `operationId` și `aggregateRevision`, `8` |
| 4 | `GET /operations/{operationId}` | Rezultatul |
| 5 | Un `POST` al evenimentului la endpoint-ul tău | Câmpul `id` al evenimentului, ca o repetare să fie sărită |

## Acum în produsul tău

Fiecare produs are aceiași cinci pași, cu resursele lui. Ghidul rapid al fiecărui produs live îi reia cu propriile cereri.

## În documentația produselor

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

## Pagini înrudite

-   [Cereri și răspunsuri](https://rdcopilot.com/ro/docs/requests/): adrese, anteturi și formate.
-   [Idempotență și reîncercări](https://rdcopilot.com/ro/docs/idempotency/): ce faci când se pierde un răspuns.

[Pagina anterioară · **Autentificarea în API**](https://rdcopilot.com/ro/docs/authentication/) [Pagina următoare · **Test și live**](https://rdcopilot.com/ro/docs/environments/)

---

R&D Copilot · Realizat în UE · Contact: https://rdcopilot.com/ro/contact/
