Update Stock Level
PATCH /v1/nextrestaurant/locations/{locationId}/stock-levels/{stockItemId}
Set a count, par or reorder point, or 86 an ingredient
Needs inventory:write. A new quantity is recorded as an adjustment
movement; dropping to the reorder point fires stock.low. is_86 86es every
menu item whose recipe uses this stock item at the location. Refused in demo
mode.
Request
PATCH https://your-site.example/api/index.php/v1/nextrestaurant/locations/{locationId}/stock-levels/{stockItemId}
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
locationId |
integer |
path |
Yes | (min 1) |
stockItemId |
integer |
path |
Yes | (min 1) |
If-Match |
string |
header |
No | The ETag from your last read. When the record has changed since, the change is refused with 412 PRECONDITION_FAILED instead of overwriting someone else's edit. Without it, the last write wins. |
Idempotency-Key |
string |
header |
No | Any unique string up to 255 characters, e.g. a UUID. Send the same key when retrying after a timeout: the first response is replayed (with Idempotent-Replayed: true) and nothing happens twice. Reusing a key for a different request is 422 IDEMPOTENCY_MISMATCH; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are kept 24 hours, per API key. (max length 255) |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
quantity |
number |
No | |
par_level |
number|null |
No | (min 0) |
reorder_point |
number|null |
No | (min 0) |
is_86 |
boolean |
No |
{
"quantity": 42.5
}
Responses
200 — The level as it now stands.
{
"data": {
"stock_item_id": 1,
"location_id": 1,
"sku": "string",
"title": "string",
"unit": "kg",
"quantity": 1.5,
"par_level": 1.5,
"reorder_point": 1.5,
"low": true,
"is_86": true,
"last_counted_at": "string",
"updated_at": "string"
}
}
| Field | Type | Meaning |
|---|---|---|
data.stock_item_id |
integer |
|
data.location_id |
integer |
|
data.sku |
string|null |
|
data.title |
string |
|
data.unit |
string|null |
|
data.quantity |
number |
|
data.par_level |
number|null |
|
data.reorder_point |
number|null |
|
data.low |
boolean |
At or below the reorder point. |
data.is_86 |
boolean |
|
data.last_counted_at |
string|null |
|
data.updated_at |
string|null |
Errors
| Status | Code | When |
|---|---|---|
400 |
INVALID_JSON |
INVALID_JSON (the body is not a JSON object) or INVALID_IDEMPOTENCY_KEY. |
401 |
INVALID_TOKEN |
The token is missing, wrong, or none has been generated. |
403 |
INSUFFICIENT_SCOPE |
This API key does not have the permission this request needs. |
403 |
MODULE_DISABLED |
This module is disabled. |
403 |
API_DISABLED |
API is disabled |
404 |
NOT_FOUND |
No such record. |
412 |
PRECONDITION_FAILED: the record changed since your If-Match. Read it again. |
|
415 |
UNSUPPORTED_MEDIA_TYPE: send Content-Type: application/json. |
|
422 |
VALIDATION_FAILED |
One error per invalid field, each with source.pointer. |
429 |
RATE_LIMITED |
Too many requests. RATE_LIMITED with a Retry-After header: this key used its budget for the minute, or this address sent 20 bad tokens in 5 minutes. Nothing ran, so the request is safe to retry after the wait. |
Examples
curl
curl -s -X PATCH "https://your-site.example/api/index.php/v1/nextrestaurant/locations/1/stock-levels/1" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"quantity":42.5}'
PHP
<?php
$ch = curl_init('https://your-site.example/api/index.php/v1/nextrestaurant/locations/1/stock-levels/1');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('API_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"quantity":42.5}',
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
JavaScript
const API_TOKEN = process.env.API_TOKEN;
const response = await fetch("https://your-site.example/api/index.php/v1/nextrestaurant/locations/1/stock-levels/1", {
method: 'PATCH',
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"quantity": 42.5
}),
});
const data = await response.json();