Menus
Each menu is served in the Menu shape below.
Items store a typed resource reference; url is computed at read time
from the live handle, so a product/page handle rename never breaks a menu. Items whose referenced resource is deleted or
not storefront-visible (draft page/post/product, inactive or internal
category) are skipped, subtree included: the payload only ever contains
renderable links. Nesting is 3 levels max.
GET /api/store/menus/:handle: one menu
- Purpose: render the storefront navigation (header
main-menu, footer menus, handles are merchant-chosen in admin, Content, Navigation). - Auth: anon (
x-client-id). - Request: path handle only.
- Response:
{
"menu": {
"handle": "main-menu",
"title": "Main menu",
"items": [
{
"title": "Shop",
"type": "collection", // frontpage|collection|product|category|page|blog_post|external
"url": "/collections/all", // computed at read time; "/" for frontpage; verbatim for external
"resourceId": "pcol_<hex>", // null for frontpage/external
"items": [ /* same shape, ≤ 3 levels total */ ]
}
]
}
}- Errors:
404 {code: "not_found"}, unknown OR deleted handle. A store with zero menus 404s every handle; the storefront must handle this gracefully (render no nav), the API never 500s for it. - SDK:
menus.getMenu(client, handle) - Components: header navigation, footer link lists, mobile drawer.
- Settings: menus are authored in admin, Content, Navigation; deleting a referenced resource silently drops its item here.
ETag / caching semantics
- Every 200 carries
ETag(sha1 of the payload) andCache-Control: public, s-maxage=60, stale-while-revalidate=3600. - A request with
If-None-Match: <etag>answers 304 with an empty body when the menu is unchanged. Browsers do this transparently. Next.js RSC callers:menus.getMenu(client, handle)takes no per-callRequestOptions(none of the SDK domain functions forward them yet), cache at the route level (export const revalidate = 60) or supply a cachingfetchinStorefrontClientConfig.fetchinstead of hand-rolling ETag replay. - The
menu.updateddomain event fires on every menu mutation, the future cache-revalidation hook.
# An unknown handle answers the clean 404 contract with the stable code (the state
# every storefront must survive: a deleted menu it still references).
STATUS=$(curl -s -o /dev/null -w '%{http_code}' \
"$BASE/api/store/menus/doc-no-such-menu-$RUN" -H "x-client-id: $CLIENT_ID")
test "$STATUS" = 404
curl -s "$BASE/api/store/menus/doc-no-such-menu-$RUN" -H "x-client-id: $CLIENT_ID" \
| grep -q '"code":"not_found"'Menus are admin-authored, so the happy path (the payload shape, the ETag and 304 round trip) is shown as shapes, and the executable blocks prove what a store with no menus answers.
GET /api/store/menus: every menu at once
- Purpose: the shell's one read. The header, the utility bar, the footer's columns and the legal line take their menus by handle out of this list, and a handle the merchant has not authored is simply absent, so an unauthored slot renders nothing and costs nothing; asking by handle would cost a 404 per slot on every regeneration of the shell's cache.
- Auth: anon (
x-client-id). - Request: nothing.
- Response:
{ "menus": [ /* the Menu shape above, in handle order */ ] }. A store with no menus answers{ "menus": [] }. Never a 404. - SDK:
menus.listMenus(client). - Caching:
ETagandIf-None-Matchanswer 304, as above.
curl -s "$BASE/api/store/menus" -H "x-client-id: $CLIENT_ID" | grep -q '"menus":\['