Buy and receive goods
Place a purchase order, record what arrives, and follow what is still open.
On this page
Place the order
A purchase order names a supplier and lines with the price agreed for each. Only items that are bought can be ordered; asking for a made item is refused with not_purchasable, and an item may appear on one line only.
curl
curl -X POST "$RDC_BASE_URL/erp/v1/purchase-orders" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "678d16d1-51ce-4f0f-838b-584b62e61789",
"supplierId": "14b3279c-01f1-464f-bad7-ff50dadac05f",
"lines": [
{
"code": "FA-0010",
"quantity": "4",
"unitPrice": "32.50"
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/purchase-orders`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "678d16d1-51ce-4f0f-838b-584b62e61789",
"supplierId": "14b3279c-01f1-464f-bad7-ff50dadac05f",
"lines": [
{
"code": "FA-0010",
"quantity": "4",
"unitPrice": "32.50"
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/purchase-orders',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '678d16d1-51ce-4f0f-838b-584b62e61789',
'supplierId': '14b3279c-01f1-464f-bad7-ff50dadac05f',
'lines': [
{
'code': 'FA-0010',
'quantity': '4',
'unitPrice': '32.50',
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "678d16d1-51ce-4f0f-838b-584b62e61789",
"supplierId": "14b3279c-01f1-464f-bad7-ff50dadac05f",
"lines": [
{
"code": "FA-0010",
"quantity": "4",
"unitPrice": "32.50"
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/purchase-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#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/purchase-orders");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "678d16d1-51ce-4f0f-838b-584b62e61789",
"supplierId": "14b3279c-01f1-464f-bad7-ff50dadac05f",
"lines": [
{
"code": "FA-0010",
"quantity": "4",
"unitPrice": "32.50"
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "678d16d1-51ce-4f0f-838b-584b62e61789",
"status": "accepted",
"aggregateId": "fb086179-5513-43e2-a802-1a277c3b0d01",
"aggregateRevision": 1
} Until the goods arrive, the units count as incoming on the item. That is how you avoid buying the same shortage twice.
Receive
A receipt names the purchase order and the quantities that arrived, by item code. The units go into onHand at once, and each line’s open quantity falls by what came in.
curl
curl -X POST "$RDC_BASE_URL/erp/v1/receipts" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "59655cae-f4d3-4844-99eb-50f999e798aa",
"purchaseOrderId": "fb086179-5513-43e2-a802-1a277c3b0d01",
"warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7",
"lines": [
{
"code": "FA-0010",
"quantity": "4"
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/receipts`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "59655cae-f4d3-4844-99eb-50f999e798aa",
"purchaseOrderId": "fb086179-5513-43e2-a802-1a277c3b0d01",
"warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7",
"lines": [
{
"code": "FA-0010",
"quantity": "4"
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/receipts',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '59655cae-f4d3-4844-99eb-50f999e798aa',
'purchaseOrderId': 'fb086179-5513-43e2-a802-1a277c3b0d01',
'warehouseId': '418d35c2-d9c8-4021-917a-04c8ebe593a7',
'lines': [
{
'code': 'FA-0010',
'quantity': '4',
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "59655cae-f4d3-4844-99eb-50f999e798aa",
"purchaseOrderId": "fb086179-5513-43e2-a802-1a277c3b0d01",
"warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7",
"lines": [
{
"code": "FA-0010",
"quantity": "4"
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/receipts');
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#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/receipts");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "59655cae-f4d3-4844-99eb-50f999e798aa",
"purchaseOrderId": "fb086179-5513-43e2-a802-1a277c3b0d01",
"warehouseId": "418d35c2-d9c8-4021-917a-04c8ebe593a7",
"lines": [
{
"code": "FA-0010",
"quantity": "4"
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "59655cae-f4d3-4844-99eb-50f999e798aa",
"status": "accepted",
"aggregateId": "da12393a-27f3-47f4-adc2-e29c9c937f5a",
"aggregateRevision": 1
} - A receipt may be smaller than the open quantity. The order stays
openand a later receipt takes the rest. - A receipt cannot be larger than the open quantity of a line. It is refused with
over_receiptand nothing is received. - A line that is not on the order is refused with
item_not_on_order.
Follow what is open
This order was placed for 96 units and 90 arrived. It stays open with 6 units still to come:
A purchase order that came short
curl
curl "$RDC_BASE_URL/erp/v1/purchase-orders/403660ee-f721-4e98-b224-59e59e245387" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/purchase-orders/403660ee-f721-4e98-b224-59e59e245387`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/purchase-orders/403660ee-f721-4e98-b224-59e59e245387',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/purchase-orders/403660ee-f721-4e98-b224-59e59e245387');
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#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/purchase-orders/403660ee-f721-4e98-b224-59e59e245387");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"id": "403660ee-f721-4e98-b224-59e59e245387",
"number": "CA-0729",
"supplierId": "e649fbee-e600-4db7-ab58-94e251d0fe9a",
"supplierName": "Brânzeturi Obcina SRL",
"date": "2026-11-10",
"status": "open",
"lines": [
{
"code": "LA-0307",
"name": "Cheese, 400 g",
"quantity": "96",
"unitPrice": "15.20",
"received": "90",
"open": "6"
}
],
"net": "1459.20",
"vat": "160.51",
"total": "1619.71",
"vatBreakdown": [
{
"rate": "11",
"base": "1459.20",
"vat": "160.51"
}
],
"currency": "RON",
"revision": 2
} listPurchaseOrders with status=open returns every order that still waits for something. A receipt sends the event com.rdcopilot.erp.receipt.recorded.v1; subscribe to it to reserve stock for waiting orders as soon as goods arrive. See Subscriptions.