---
title: "Quickstart | Docs | ERP by R&D Copilot"
description: "Take one sales order from entry to a part-paid invoice: find the customer, create the order, confirm it, reserve stock, deliver, invoice and record a payment."
canonical: "https://erp.rdcopilot.com/docs/get-started/quickstart/"
language: en
updated: 2026-11-22
---

# Quickstart

Take one sales order from entry to a part-paid invoice: find the customer, create the order, confirm it, reserve stock, deliver, invoice and record a payment.

You need the client credentials and the base address of your test company. The samples read them from the environment: `$RDC_BASE_URL` and `$RDC_TOKEN`. See [Authentication](https://erp.rdcopilot.com/docs/get-started/authentication/) for the token and [Sandbox and live](https://erp.rdcopilot.com/docs/get-started/sandbox-and-live/) for the test company.

## Find the customer

A sales order belongs to a customer. List the partners that are customers and keep the `id` of the one you sell to.

curl

```bash
curl "$RDC_BASE_URL/erp/v1/partners?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/partners?limit=20`, {
  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"]}/erp/v1/partners?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/partners?limit=20');
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")}/erp/v1/partners?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 200

```json
{
  "items": [
    {
      "id": "88e177c6-55ac-4cd5-90af-70c333498d2b",
      "name": "Hanul Ozana SRL",
      "roles": [
        "customer"
      ],
      "city": "Târgu Neamț",
      "country": "RO",
      "vatId": "RO39172541",
      "paymentTermsDays": 30,
      "creditLimit": "15000.00"
    },
    {
      "id": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
      "name": "Cofetăria Vălul Alb SRL",
      "roles": [
        "customer"
      ],
      "city": "Roman",
      "country": "RO",
      "vatId": "RO39172614",
      "paymentTermsDays": 15,
      "creditLimit": "8000.00"
    }
  ],
  "nextCursor": null
}
```

## Create the order

Choose a new `operationId` and send the lines by item code. Quantities are whole units written as decimal strings. Each line takes the sales price of its item now. The answer says that the change was accepted.

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/sales-orders" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
  "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
  "lines": [
    {
      "code": "ZA-0201",
      "quantity": "20"
    },
    {
      "code": "UL-0101",
      "quantity": "12"
    }
  ]
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/sales-orders`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
    "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
    "lines": [
      {
        "code": "ZA-0201",
        "quantity": "20"
      },
      {
        "code": "UL-0101",
        "quantity": "12"
      }
    ]
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/sales-orders',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'ae72c8b0-f759-4c6e-a790-09971f6379e4',
        'customerId': '59ebc921-4507-4c03-b6ee-9801f14e7b09',
        'lines': [
            {
                'code': 'ZA-0201',
                'quantity': '20',
            },
            {
                'code': 'UL-0101',
                'quantity': '12',
            },
        ],
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
  "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
  "lines": [
    {
      "code": "ZA-0201",
      "quantity": "20"
    },
    {
      "code": "UL-0101",
      "quantity": "12"
    }
  ]
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/sales-orders');
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")}/erp/v1/sales-orders");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
  "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
  "lines": [
    {
      "code": "ZA-0201",
      "quantity": "20"
    },
    {
      "code": "UL-0101",
      "quantity": "12"
    }
  ]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
  "status": "accepted",
  "aggregateId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "aggregateRevision": 1
}
```

## Read the result

Look the operation up with the `operationId` you sent. When `status` is `completed`, the order exists as a draft and `aggregateId` is its id.

curl

```bash
curl "$RDC_BASE_URL/erp/v1/operations/ae72c8b0-f759-4c6e-a790-09971f6379e4" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/operations/ae72c8b0-f759-4c6e-a790-09971f6379e4`, {
  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"]}/erp/v1/operations/ae72c8b0-f759-4c6e-a790-09971f6379e4',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/operations/ae72c8b0-f759-4c6e-a790-09971f6379e4');
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")}/erp/v1/operations/ae72c8b0-f759-4c6e-a790-09971f6379e4");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 200

```json
{
  "operationId": "ae72c8b0-f759-4c6e-a790-09971f6379e4",
  "status": "completed",
  "aggregateId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "aggregateRevision": 1
}
```

| Status | Meaning |
| --- | --- |
| accepted | The request was recorded and is being applied. |
| completed | The change was applied. |
| rejected | The request was refused. Nothing was changed. |

## Confirm and reserve

Confirming checks the credit of the customer. Send the revision you read as `expectedRevision`: the draft is revision 1.

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/confirm" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "bcf8f768-d67b-47aa-a7af-25b74eb53991",
  "expectedRevision": 1
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/confirm`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "bcf8f768-d67b-47aa-a7af-25b74eb53991",
    "expectedRevision": 1
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/confirm',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'bcf8f768-d67b-47aa-a7af-25b74eb53991',
        'expectedRevision': 1,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "bcf8f768-d67b-47aa-a7af-25b74eb53991",
  "expectedRevision": 1
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/confirm');
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")}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/confirm");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "bcf8f768-d67b-47aa-a7af-25b74eb53991",
  "expectedRevision": 1
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "bcf8f768-d67b-47aa-a7af-25b74eb53991",
  "status": "accepted",
  "aggregateId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "aggregateRevision": 2
}
```

Reserving sets aside the free stock for each line. Here every line is covered, so the order becomes `reserved`. When a line is short, the order stays `confirmed`; see [Take an order to delivery](https://erp.rdcopilot.com/docs/guides/take-an-order-to-delivery/).

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/reserve" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "cd26f38e-8527-4023-adc9-5899886fd3c0",
  "expectedRevision": 2
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/reserve`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "cd26f38e-8527-4023-adc9-5899886fd3c0",
    "expectedRevision": 2
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/reserve',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'cd26f38e-8527-4023-adc9-5899886fd3c0',
        'expectedRevision': 2,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "cd26f38e-8527-4023-adc9-5899886fd3c0",
  "expectedRevision": 2
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/reserve');
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")}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c/reserve");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "cd26f38e-8527-4023-adc9-5899886fd3c0",
  "expectedRevision": 2
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "cd26f38e-8527-4023-adc9-5899886fd3c0",
  "status": "accepted",
  "aggregateId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "aggregateRevision": 3
}
```

Get the order

curl

```bash
curl "$RDC_BASE_URL/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c`, {
  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"]}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c');
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")}/erp/v1/sales-orders/74bf6304-7842-41e8-9928-f4420004d89c");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 200

```json
{
  "id": "74bf6304-7842-41e8-9928-f4420004d89c",
  "number": "CV-1048",
  "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
  "customerName": "Cofetăria Vălul Alb SRL",
  "date": "2026-11-23",
  "status": "reserved",
  "lines": [
    {
      "code": "ZA-0201",
      "name": "Sugar, 1 kg",
      "quantity": "20",
      "unit": "bag",
      "unitPrice": "4.29",
      "vatRate": "11",
      "net": "85.80",
      "reserved": "20",
      "short": "0"
    },
    {
      "code": "UL-0101",
      "name": "Sunflower oil, 1 l",
      "quantity": "12",
      "unit": "bottle",
      "unitPrice": "7.84",
      "vatRate": "11",
      "net": "94.08",
      "reserved": "12",
      "short": "0"
    }
  ],
  "net": "179.88",
  "vat": "19.79",
  "total": "199.67",
  "vatBreakdown": [
    {
      "rate": "11",
      "base": "179.88",
      "vat": "19.79"
    }
  ],
  "currency": "RON",
  "deliveryId": null,
  "deliveryNumber": null,
  "invoiceId": null,
  "invoiceNumber": null,
  "revision": 3
}
```

## Deliver and invoice

Delivering takes the reserved units out of the warehouse and gives the delivery its number, LIV-2026-01844. The order is now revision 4.

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/deliveries" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "a2c43bc6-4592-49bb-a0d4-ea72f62d73e7",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 3,
  "warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/deliveries`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "a2c43bc6-4592-49bb-a0d4-ea72f62d73e7",
    "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
    "expectedRevision": 3,
    "warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/deliveries',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'a2c43bc6-4592-49bb-a0d4-ea72f62d73e7',
        'salesOrderId': '74bf6304-7842-41e8-9928-f4420004d89c',
        'expectedRevision': 3,
        'warehouseId': '418d35c2-d9c8-4021-917a-04c8ebe593a7',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "a2c43bc6-4592-49bb-a0d4-ea72f62d73e7",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 3,
  "warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/deliveries');
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")}/erp/v1/deliveries");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "a2c43bc6-4592-49bb-a0d4-ea72f62d73e7",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 3,
  "warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "a2c43bc6-4592-49bb-a0d4-ea72f62d73e7",
  "status": "accepted",
  "aggregateId": "484f788c-71dc-48c2-864a-187d82d44488",
  "aggregateRevision": 1
}
```

Invoicing a delivered order issues FCT-2026-00419 for 199.67 RON, VAT included. Read [Taxes and rounding](https://erp.rdcopilot.com/docs/concepts/taxes-and-rounding/) for how the total is built.

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/invoices" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "9c3d84db-dea0-40c0-aa8c-1c01f68536c9",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 4
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/invoices`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "9c3d84db-dea0-40c0-aa8c-1c01f68536c9",
    "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
    "expectedRevision": 4
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/invoices',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '9c3d84db-dea0-40c0-aa8c-1c01f68536c9',
        'salesOrderId': '74bf6304-7842-41e8-9928-f4420004d89c',
        'expectedRevision': 4,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "9c3d84db-dea0-40c0-aa8c-1c01f68536c9",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 4
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/invoices');
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")}/erp/v1/invoices");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "9c3d84db-dea0-40c0-aa8c-1c01f68536c9",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "expectedRevision": 4
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "9c3d84db-dea0-40c0-aa8c-1c01f68536c9",
  "status": "accepted",
  "aggregateId": "b0cb7b8b-9dec-448d-8cd1-23989708e6ec",
  "aggregateRevision": 1
}
```

## Record a payment

A payment is recorded on the invoice with the invoice's own revision, which is 1 when it is issued. 100.00 RON leaves the invoice `partly_paid`; the amount that brings the balance to zero makes the invoice and the order `paid`.

curl

```bash
curl -X POST "$RDC_BASE_URL/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec/payments" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "d5b89ed8-042f-4ede-aa49-be4df91b3308",
  "expectedRevision": 1,
  "amount": "100.00"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec/payments`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "d5b89ed8-042f-4ede-aa49-be4df91b3308",
    "expectedRevision": 1,
    "amount": "100.00"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec/payments',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'd5b89ed8-042f-4ede-aa49-be4df91b3308',
        'expectedRevision': 1,
        'amount': '100.00',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "d5b89ed8-042f-4ede-aa49-be4df91b3308",
  "expectedRevision": 1,
  "amount": "100.00"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec/payments');
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")}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec/payments");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "d5b89ed8-042f-4ede-aa49-be4df91b3308",
  "expectedRevision": 1,
  "amount": "100.00"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "d5b89ed8-042f-4ede-aa49-be4df91b3308",
  "status": "accepted",
  "aggregateId": "b0cb7b8b-9dec-448d-8cd1-23989708e6ec",
  "aggregateRevision": 2
}
```

Get the invoice

curl

```bash
curl "$RDC_BASE_URL/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec`, {
  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"]}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec');
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")}/erp/v1/invoices/b0cb7b8b-9dec-448d-8cd1-23989708e6ec");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 200

```json
{
  "id": "b0cb7b8b-9dec-448d-8cd1-23989708e6ec",
  "number": "FCT-2026-00419",
  "salesOrderId": "74bf6304-7842-41e8-9928-f4420004d89c",
  "salesOrderNumber": "CV-1048",
  "customerId": "59ebc921-4507-4c03-b6ee-9801f14e7b09",
  "issueDate": "2026-11-23",
  "dueDate": "2026-12-08",
  "net": "179.88",
  "vat": "19.79",
  "total": "199.67",
  "vatBreakdown": [
    {
      "rate": "11",
      "base": "179.88",
      "vat": "19.79"
    }
  ],
  "paid": "100.00",
  "balance": "99.67",
  "currency": "RON",
  "status": "partly_paid",
  "payments": [
    {
      "paidOn": "2026-11-23",
      "amount": "100.00"
    }
  ],
  "revision": 2
}
```

Repeat a request with the same `operationId` after a timeout. The order, the delivery and the invoice are each created once.
