> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-beta.marqii.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-beta.marqii.com/_mcp/server.

# Introduction

Public, unauthenticated API that the Marqii embeddable widget (`packages/widget`) calls to load a published widget's data and config.

Served by `packages/express-api` (ECS) behind CloudFront at `https://embed.marqii.com`.

## Endpoint

`GET /api/v2/public/widget/{widgetId}?widgetType={widgetType}`

| Param           | In     | Required | Notes                                                                                                     |
| --------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------- |
| `widgetId`      | path   | yes      | UUID of the published widget                                                                              |
| `widgetType`    | query  | yes      | One of `menus`, `hours`, `reviewForms`, `faq`, `reviews`. Must match the type the widget was published as |
| `If-None-Match` | header | no       | ETag from a previous response. Returns `304` when unchanged                                               |

The widget is read from DynamoDB (pk `id`, sk `type`). Large menus widgets are stored as gzipped partitions (`menus#<menuId>`); the API merges and decompresses them, sorts by `position`, and returns the same shape as an uncompressed widget.

Every 200 response also includes a `geo` object built from CloudFront viewer headers (`latitude`, `longitude`, `ip`, `country`, `city`). All of its fields are `null` when the headers are missing (for example, when the API is called directly instead of through CloudFront).

## Caching

* `ETag` is a strong ETag. `Access-Control-Expose-Headers: etag` lets the browser read it.
* `Cache-Control: s-maxage=3600, stale-while-revalidate=604800, stale-if-error=604800` means CloudFront caches for 1 hour and serves stale content for up to 7 days.
* The widget stores the ETag and body in `localStorage` (`marqii::widget::eTag-<id>` / `marqii::widget::data-<id>`) and sends `If-None-Match` on the next load.

## Errors

| Status | Body                                               | When                                  |
| ------ | -------------------------------------------------- | ------------------------------------- |
| 400    | `{"message":"error missing query"}`                | `widgetType` missing                  |
| 400    | `{"message":"Invalid widget id","errors":[...]}`   | `widgetId` is not a UUID              |
| 400    | `{"message":"Invalid widget type","errors":[...]}` | `widgetType` is not a known type      |
| 400    | `{"message":"validation error","errors":[...]}`    | Stored widget fails schema validation |
| 404    | `{"message":"not found"}`                          | No widget with this id + type         |
| 404    | `{"status":404,"message":"Not Found"}`             | Unknown route                         |
| 500    | `{"message":"..."}`                                | Unexpected error                      |