Work orders
Plan, start and finish the making of an item from its components.
On this page
List work orders
GET /erp/v1/work-orders
Parameters
| Name | In | Type | Required | Meaning |
|---|---|---|---|---|
status | query | string | Nooptional | Only work orders in this status. One of not_started, in_progress, done |
limit | query | integer | Nooptional | Records per page, from 1 to 500. Default 100 Range 1 – 500 |
cursor | query | string | Nooptional | The nextCursor of the previous page. |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | A page of work orders. | WorkOrderPage |
401 | The token is missing, has expired or is not ours. | Error |
403 | The token does not give access to this company or operation. | Error |
429 | There were too many requests. Nothing was processed. The header Retry-After gives the seconds to wait. | Error |
503 | The service cannot answer now. | Error |
Request
curl
curl "$RDC_BASE_URL/erp/v1/work-orders?limit=20" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders?limit=20`, {
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/work-orders?limit=20',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders?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#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/work-orders?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
{
"items": [
{
"id": "6c1303af-001b-4b52-9464-819e318a244b",
"number": "OP-0212",
"itemCode": "CO-0900",
"itemName": "Gift basket, Neamț selection",
"planned": "20",
"produced": "0",
"status": "in_progress",
"components": [
{
"code": "CT-0610",
"name": "Gift box, 30 × 20 cm",
"needed": "20",
"available": "18",
"short": "2"
},
{
"code": "UL-0101",
"name": "Sunflower oil, 1 l",
"needed": "40",
"available": "92",
"short": "0"
},
{
"code": "ZA-0201",
"name": "Sugar, 1 kg",
"needed": "40",
"available": "210",
"short": "0"
},
{
"code": "LA-0307",
"name": "Cheese, 400 g",
"needed": "40",
"available": "72",
"short": "0"
}
],
"operations": [
{
"name": "Pick components",
"minutes": 60
},
{
"name": "Pack the basket",
"minutes": 120
},
{
"name": "Label and seal",
"minutes": 40
}
],
"revision": 2
},
{
"id": "6b13021c-fb0b-4169-b41d-3415bf219529",
"number": "OP-0213",
"itemCode": "CO-0900",
"itemName": "Gift basket, Neamț selection",
"planned": "12",
"produced": "0",
"status": "not_started",
"components": [
{
"code": "CT-0610",
"name": "Gift box, 30 × 20 cm",
"needed": "12",
"available": "18",
"short": "0"
},
{
"code": "UL-0101",
"name": "Sunflower oil, 1 l",
"needed": "24",
"available": "92",
"short": "0"
},
{
"code": "ZA-0201",
"name": "Sugar, 1 kg",
"needed": "24",
"available": "210",
"short": "0"
},
{
"code": "LA-0307",
"name": "Cheese, 400 g",
"needed": "24",
"available": "72",
"short": "0"
}
],
"operations": [
{
"name": "Pick components",
"minutes": 36
},
{
"name": "Pack the basket",
"minutes": 72
},
{
"name": "Label and seal",
"minutes": 24
}
],
"revision": 1
}
],
"nextCursor": null
} Create a work order
POST /erp/v1/work-orders
Plans the making of a quantity of a made item. The components are taken from its bill of materials when the work order is finished.
Request body
| Field | Type | Required | Meaning |
|---|---|---|---|
operationId | string (uuid) | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
itemCode | string | Yesrequired | Code of an item that is made. |
planned | string | Yesrequired | Units to make. |
Responses
| Status | Meaning | Body |
|---|---|---|
202 | The change was accepted. The body is the operation result: aggregateId is the record that was created or changed. | OperationResult |
401 | The token is missing, has expired or is not ours. | Error |
403 | The token does not give access to this company or operation. | Error |
404 | The item does not exist. | Error |
409 | The operationId was used before with a different request. | Error |
422 | not_made: The item has no bill of materials, so it cannot be made. invalid_quantity: A quantity is not a whole number from 1 to 1000000. | Error |
429 | There were too many requests. Nothing was processed. The header Retry-After gives the seconds to wait. | Error |
503 | The service cannot answer now. | Error |
Request
curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'd0495011-1877-40ec-b95d-2891ddeffeff',
'itemCode': 'CO-0900',
'planned': '8',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-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/work-orders");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); Response 202
{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"status": "accepted",
"aggregateId": "6a130089-fa08-45d4-b720-66dab824bbfa",
"aggregateRevision": 1
} Get a work order
GET /erp/v1/work-orders/{workOrderId}
Parameters
| Name | In | Type | Required | Meaning |
|---|---|---|---|---|
workOrderId | path | string (uuid) | Yesrequired | The work order. |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | The work order with its components and operations. | WorkOrder |
401 | The token is missing, has expired or is not ours. | Error |
403 | The token does not give access to this company or operation. | Error |
404 | The work order does not exist. | Error |
429 | There were too many requests. Nothing was processed. The header Retry-After gives the seconds to wait. | Error |
503 | The service cannot answer now. | Error |
Request
curl
curl "$RDC_BASE_URL/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b`, {
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/work-orders/6c1303af-001b-4b52-9464-819e318a244b',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b');
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/work-orders/6c1303af-001b-4b52-9464-819e318a244b");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); Response 200
{
"id": "6c1303af-001b-4b52-9464-819e318a244b",
"number": "OP-0212",
"itemCode": "CO-0900",
"itemName": "Gift basket, Neamț selection",
"planned": "20",
"produced": "0",
"status": "in_progress",
"components": [
{
"code": "CT-0610",
"name": "Gift box, 30 × 20 cm",
"needed": "20",
"available": "18",
"short": "2"
},
{
"code": "UL-0101",
"name": "Sunflower oil, 1 l",
"needed": "40",
"available": "92",
"short": "0"
},
{
"code": "ZA-0201",
"name": "Sugar, 1 kg",
"needed": "40",
"available": "210",
"short": "0"
},
{
"code": "LA-0307",
"name": "Cheese, 400 g",
"needed": "40",
"available": "72",
"short": "0"
}
],
"operations": [
{
"name": "Pick components",
"minutes": 60
},
{
"name": "Pack the basket",
"minutes": 120
},
{
"name": "Label and seal",
"minutes": 40
}
],
"revision": 2
} Start a work order
POST /erp/v1/work-orders/{workOrderId}/start
Parameters
| Name | In | Type | Required | Meaning |
|---|---|---|---|---|
workOrderId | path | string (uuid) | Yesrequired | The work order. |
Request body
| Field | Type | Required | Meaning |
|---|---|---|---|
operationId | string (uuid) | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
expectedRevision | integer | Yesrequired | The revision of the work order you read. |
Responses
| Status | Meaning | Body |
|---|---|---|
202 | The change was accepted. The body is the operation result: aggregateId is the record that was created or changed. | OperationResult |
401 | The token is missing, has expired or is not ours. | Error |
403 | The token does not give access to this company or operation. | Error |
404 | The work order does not exist. | Error |
409 | operation_reused: The operationId was used before with a different request. revision_conflict: The record has changed since the revision you sent as expectedRevision. wrong_status: The record is not in a status that allows this change. | Error |
429 | There were too many requests. Nothing was processed. The header Retry-After gives the seconds to wait. | Error |
503 | The service cannot answer now. | Error |
Request
curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'ea412b87-44e9-4f49-bb35-277c6013c9b9',
'expectedRevision': 1,
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start');
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/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); Response 202
{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"status": "accepted",
"aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
"aggregateRevision": 2
} Finish a work order
POST /erp/v1/work-orders/{workOrderId}/finish
Reports the quantity made, at most the planned quantity. The components for that quantity leave stock and the made items enter it. Components reserved for sales orders are not free and cannot be used.
Parameters
| Name | In | Type | Required | Meaning |
|---|---|---|---|---|
workOrderId | path | string (uuid) | Yesrequired | The work order. |
Request body
| Field | Type | Required | Meaning |
|---|---|---|---|
operationId | string (uuid) | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
expectedRevision | integer | Yesrequired | The revision of the work order you read. |
produced | string | Yesrequired | Units made, at most the planned quantity. |
Responses
| Status | Meaning | Body |
|---|---|---|
202 | The change was accepted. The body is the operation result: aggregateId is the record that was created or changed. | OperationResult |
401 | The token is missing, has expired or is not ours. | Error |
403 | The token does not give access to this company or operation. | Error |
404 | The work order does not exist. | Error |
409 | operation_reused: The operationId was used before with a different request. revision_conflict: The record has changed since the revision you sent as expectedRevision. wrong_status: The record is not in a status that allows this change. component_short: A component is not free in the quantity the work order needs. | Error |
422 | invalid_quantity: A quantity is not a whole number from 1 to 1000000. over_plan: The produced quantity is more than the work order plans. | Error |
429 | There were too many requests. Nothing was processed. The header Retry-After gives the seconds to wait. | Error |
503 | The service cannot answer now. | Error |
Request
curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'd66fade7-3459-4a34-8450-dc6912036bef',
'expectedRevision': 2,
'produced': '12',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish');
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/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); Response 202
{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"status": "accepted",
"aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
"aggregateRevision": 3
}