Worked example & advice
A worked example
Placing an order end to end, in the order a kiosk would do it. The key needs menu:read and
orders:write.
BASE="https://your-site.example/api/index.php/v1/nextrestaurant"
AUTH="Authorization: Bearer $NR_KEY"
# 1. Which branches exist?
curl -s "$BASE/locations" -H "$AUTH" | jq '.data[] | {id, title, currency}'
# 2. What can branch 2 sell right now?
curl -s "$BASE/locations/2/menu" -H "$AUTH" \
| jq '.data.categories[].items[] | {id, title, price, has_variations}'
# 3. What are the options on item 16?
curl -s "$BASE/locations/2/menu" -H "$AUTH" \
| jq '.data.categories[].items[] | select(.id == 16) | {variations, modifier_groups}'
# 4. Place the order (201 Created). The key makes a retry safe.
curl -s -X POST "$BASE/orders" -H "$AUTH" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: kiosk3-2026-12-24-0042" \
-d '{"location_id":2,"items":[{"item_id":16,"variation_id":2,"qty":1}]}' \
| jq '.data | {id, order_number, grand_total, status}'
# 5. Later: where is it now? (needs orders:read)
curl -s "$BASE/orders/591" -H "$AUTH" | jq '.data | {status, fulfillment_status, payments}'
Retrying safely: Idempotency-Key
A request can time out after the server did the work. Retried blindly, a POST /orders that
actually succeeded creates a second order, and the kitchen cooks it twice.
Send an Idempotency-Key header on every POST and PATCH: any unique string up to 255
characters, such as a UUID you generate once per action and keep until you have a response.
- Same key, same request → the first response is sent again, unchanged, with the header
Idempotent-Replayed: true. Nothing happens a second time. - Same key, different request →
422 IDEMPOTENCY_MISMATCH. A key belongs to one request. - Same key while the first is still running →
409 IDEMPOTENCY_IN_PROGRESSwithRetry-After: 1. Wait and retry with the same key. - The first attempt failed with a 5xx → the key is freed, so the retry runs for real.
Keys are kept for 24 hours and belong to the API key that sent them, so two integrations can never collide. Generate a new key for each new action; reuse it only to retry that action.
Concurrent edits: ETag and If-Match
Staff and your integration can change the same booking at the same moment. Without care, the last write silently wins.
Every single-record response carries an ETag header. Send it back as If-Match on your PATCH:
ETAG=$(curl -sI "$BASE/reservations/109" -H "$AUTH" | grep -i '^etag:' | cut -d' ' -f2- | tr -d '\r')
curl -s -X PATCH "$BASE/reservations/109" -H "$AUTH" \
-H "Content-Type: application/json" -H "If-Match: $ETAG" \
-d '{"party_size": 6}'
If the booking changed since you read it, the answer is 412 PRECONDITION_FAILED and nothing is
written: read it again, decide, and retry with the new ETag. Without If-Match, the change simply
applies. The ETag is derived from the record's content, so two edits in the same second still get
different tags.
Rate limits
| Limit | Default | Applies to |
|---|---|---|
| Reads | 300 per minute | Each key |
| Changes | 60 per minute | Each key |
| Placing orders | 60 per 5 minutes | Each address |
| Booking tables | 30 per 5 minutes | Each address |
| Wrong keys | 20 per 5 minutes, then 5 minutes refused | Each address, both lanes |
The per-key limits can be changed on the REST API screen. Every response carries
RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds until a request frees
up). Slow down as RateLimit-Remaining approaches zero rather than waiting for the 429.
A 429 RATE_LIMITED always has a Retry-After header in seconds, and nothing ran, so the request
is safe to repeat after the wait.
The wrong-key lockout refuses every request from that address, a valid key included: a guesser must not be able to tell a hit from a miss by the status code. An integration that is misconfigured in a loop locks itself out the same way; fix the key and wait five minutes.
Practical advice
- One key per integration, least privilege. A key that can only read availability and create bookings is a small loss if it leaks. Name keys after the integration so the audit log and the key list make sense.
- Cache the menu, briefly. It changes when staff 86 an item, so a 30–60 second cache keeps the kiosk responsive without selling something the kitchen ran out of ten minutes ago.
- Re-fetch the menu before submitting a long-lived basket. A
400 One of the items is no longer availableat checkout is the item having gone off sale while the customer was deciding. - Use webhooks to learn that something changed, and the API to read it. Polling a list on a
timer is slower and heavier; use
updated_sinceto catch up after downtime instead. - Book from the slots you were offered. Read
/locations/{id}/availabilityand send one of its times; anything else is likely to come back409 SLOT_UNAVAILABLE.
Security notes
- Treat a key as a credential. Anyone holding it can do what its permissions allow.
- Keep it server-side. Never put a key in browser JavaScript or a mobile app bundle. See the CORS warning in Conventions & errors.
- Use HTTPS. The key travels on every request.
- Revoke on suspicion. One click on the REST API screen; the key's next request is refused.
- Retire the pre-6.1 token once every integration has its own key. It can only read the menu and place orders, as in 6.0.
- Turn the API app off if you're not using it. An unused enabled API is a surface for no benefit.
See also
- Webhooks — outbound events
- Troubleshooting — when a request is refused
- Apps & Modules — enabling the apps
- Online Ordering — what an API order becomes
- Reservations — the booking rules the API follows