Contents
On this page
Update Stock Movement - Plugixa Inventory
PUT /plugixa-inventory/v1/stock-movements/{id}
Change a draft stock movement, or replace its lines. PATCH does the same.
The user needs the plugixa_inventory_edit capability (administrators have every inventory capability). With Pro Roles and permissions enforcing, their role must also allow editing this stock movement.
Note. Only the fields you send change, but
linesis all or nothing: sending it deletes the existing lines and writes the new list.
A finalized document is frozen. Only
reference,detailsandassigned_user_idcan still change. Anything else, including the lines, is refused with409: post a reversing document instead.
Changing movement_type on a draft that has lines needs new lines in the same request, since the old ones were picked for the old type.
Request
PUT https://your-site.example/wp-json/plugixa-inventory/v1/stock-movements/57
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The stock movement’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
movement_type |
string |
No | check_in, check_out, add_stock (the default) or remove_stock. |
warehouse_id |
integer |
No | A live warehouse. |
recipient_id |
integer |
No | A live recipient. Needed to finalize a check_out. |
movement_date |
string |
No | YYYY-MM-DD, optionally followed by a time (HH:MM or HH:MM:SS), in the site’s timezone. Defaults to now. It becomes the date of the ledger rows. |
reference |
string |
No | Your own reference, at most 50 characters. Left empty, the document gets SM-YYYY-NNNN (year of the document date, id padded to four digits) when it is finalized. |
details |
string |
No | HTML. Becomes the reason on the ledger rows. |
assigned_user_id |
integer |
No | A WordPress user id. Not checked. |
lines |
array |
No | When present, replaces every line. Leave it out to keep the lines as they are. |
modified_at |
string |
No | The modified_at you last read. When the stored value differs, the update is refused with 409 because someone else saved in between. Leave it out to skip the check. |
Lines take the same fields as in Create Stock Movement.
{
"lines": [
{
"item_id": 42,
"quantity": 120,
"cost_per_unit": 4.2,
"notes": "Delivery note 4471"
},
{
"item_id": 43,
"quantity": 6,
"cost_per_unit": 18
}
],
"modified_at": "2026-11-12 09:30:00"
}
Responses
200 OK. data is the stock movement with its lines.
{
"success": true,
"data": {
"id": 57,
"reference": "",
"movement_type": "add_stock",
"warehouse_id": 1,
"recipient_id": null,
"recipient": "",
"movement_date": "2026-11-12 10:30:00",
"status": "draft",
"finalized_at": null,
"finalized_by": null,
"batch_id": "",
"line_count": 2,
"total_quantity": 0.0,
"total_cost": 0.0,
"details": "",
"attachments": null,
"assigned_user_id": null,
"created_by": 1,
"modified_by": 1,
"created_at": "2026-11-12 09:30:00",
"modified_at": "2026-11-12 10:15:00",
"deleted_at": null,
"lines": [
{
"id": 211,
"movement_id": 57,
"item_id": 42,
"unit_id": null,
"quantity": 120.0,
"weight": 0.0,
"weight_unit": "",
"weight_base": 0.0,
"cost_per_unit": 4.2,
"total_cost": 0.0,
"transaction_id": 0,
"notes": "Delivery note 4471",
"position": 1,
"created_by": "1",
"modified_by": "1",
"created_at": "2026-11-12 10:15:00",
"modified_at": "2026-11-12 10:15:00",
"deleted_at": null,
"item_name": "Printer paper A4",
"item_sku": "PAP-A4",
"item_type": "consumable",
"unit_code": null
},
{
"id": 212,
"movement_id": 57,
"item_id": 43,
"unit_id": null,
"quantity": 6.0,
"weight": 0.0,
"weight_unit": "",
"weight_base": 0.0,
"cost_per_unit": 18.0,
"total_cost": 0.0,
"transaction_id": 0,
"notes": "",
"position": 2,
"created_by": "1",
"modified_by": "1",
"created_at": "2026-11-12 10:15:00",
"modified_at": "2026-11-12 10:15:00",
"deleted_at": null,
"item_name": "Toner cartridge",
"item_sku": "TON-HP26",
"item_type": "consumable",
"unit_code": null
}
],
"warehouse_name": "Main warehouse",
"recipient_name": null
}
}
| Field | Type | Meaning |
|---|---|---|
data.lines |
array |
The lines as now stored |
data.modified_at |
string |
UTC datetime of this change |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_inventory_not_found |
No document with that id, or it is in the trash. |
409 |
plugixa_inventory_document_finalized |
The document is finalized and the request changes a frozen field or the lines. data.fields lists the frozen fields sent. |
409 |
plugixa_inventory_type_locked |
movement_type changes while the document has lines and no new lines are sent. |
422 |
plugixa_inventory_invalid_choice |
movement_type is not one of the allowed values. data.allowed lists them. |
422 |
plugixa_inventory_invalid_date |
movement_date is not a real date in the accepted form. |
422 |
plugixa_inventory_missing_warehouse |
warehouse_id is missing. |
422 |
plugixa_inventory_unknown_warehouse |
warehouse_id is not a live warehouse. |
422 |
plugixa_inventory_unknown_recipient |
recipient_id is not a live recipient. |
422 |
plugixa_inventory_too_long |
A text field is longer than its column. data.field names it and data.max gives the limit. |
422 |
plugixa_inventory_line_needs_item |
A line has a quantity but no item_id. |
422 |
plugixa_inventory_line_needs_quantity |
A line has an item_id but no quantity above zero. data.item_id names it. |
422 |
plugixa_inventory_not_a_number |
A line’s number is not a number. data.line (from 1) and data.item_id say which. |
422 |
plugixa_inventory_negative_number |
A line’s cost_per_unit (or weight) is negative. |
409 |
plugixa_inventory_conflict |
You sent modified_at and the record has changed since. data.expected and data.current carry both values. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-inventory/v1/stock-movements/57" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"lines":[{"item_id":42,"quantity":120,"cost_per_unit":4.2,"notes":"Delivery note 4471"},{"item_id":43,"quantity":6,"cost_per_unit":18}],"modified_at":"2026-11-12 09:30:00"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-inventory/v1/stock-movements/57');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'lines' => [
[
'item_id' => 42,
'quantity' => 120,
'cost_per_unit' => 4.2,
'notes' => 'Delivery note 4471',
],
[
'item_id' => 43,
'quantity' => 6,
'cost_per_unit' => 18,
],
],
'modified_at' => '2026-11-12 09:30:00',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-inventory/v1/stock-movements/57', {
method: 'PUT',
headers: { 'Authorization': auth, 'Content-Type': 'application/json' },
body: JSON.stringify({
lines: [
{
item_id: 42,
quantity: 120,
cost_per_unit: 4.2,
notes: 'Delivery note 4471',
},
{
item_id: 43,
quantity: 6,
cost_per_unit: 18,
},
],
modified_at: '2026-11-12 09:30:00',
}),
});
const { data } = await response.json();
Quick Links
Share