Update Menu Item
PATCH /v1/nextrestaurant/menu-items/{itemId}
Change an item's base price or publish it
Needs menu:write. Validated by the same form rules as the admin menu
screen. Answers with the item's availability at location_id (default: the
first location); the ETag is the item's, for a following If-Match on
this path. Refused in demo mode.
Request
PATCH https://your-site.example/api/index.php/v1/nextrestaurant/menu-items/{itemId}?location_id=<integer>
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
itemId |
integer |
path |
Yes | (min 1) |
location_id |
integer |
query |
No | |
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 |
|---|---|---|---|
base_price |
number |
No | (min 0) |
published |
boolean |
No |
{
"base_price": 12.5
}
Responses
200 — The item, as it now stands at the location.
{
"data": {
"item_id": 1,
"location_id": 1,
"title": "string",
"base_price": 1.5,
"price": 1.5,
"price_override": 1.5,
"published": true,
"available": true,
"is_86": true,
"eighty_six_until": "string",
"eighty_six_reason": "string",
"updated_at": "string"
}
}
| Field | Type | Meaning |
|---|---|---|
data.item_id |
integer |
|
data.location_id |
integer |
|
data.title |
string |
|
data.base_price |
number |
|
data.price |
number |
What the item sells for here. |
data.price_override |
number|null |
|
data.published |
boolean |
|
data.available |
boolean |
Can be ordered at this location right now. |
data.is_86 |
boolean |
|
data.eighty_six_until |
string|null |
|
data.eighty_six_reason |
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/menu-items/1" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"base_price":12.5}'
PHP
<?php
$ch = curl_init('https://your-site.example/api/index.php/v1/nextrestaurant/menu-items/1?location_id=<integer>');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('API_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"base_price":12.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/menu-items/1?location_id=<integer>", {
method: 'PATCH',
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"base_price": 12.5
}),
});
const data = await response.json();