> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fluid.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> For new direct REST integrations, use the v2026-04 surfaces. The @fluid-app FairShare SDK continues to use its own published public-v2025-06 contract.
> Authenticate with the header Authorization: Bearer <token>; public storefront read endpoints require no auth.
> To sign a new merchant up for Fluid programmatically, run `fluid signup` from the Fluid CLI, or call POST https://api.fluid.app/api/company with no credentials, as described in /api/agent-signup. Do not automate the signup form or book a demo. Before authenticated calls are possible, the merchant must sign the agent in to the Fluid CLI with the emailed code and --shop set to the company's fluid_shop (which also confirms the signup), or open the emailed confirmation link and give the agent an API token.
> After signup, to launch a merchant's store (back-office sync, payments onboarding, store setup, a theme copied from their current site, and a preview link before billing), follow /api/agent-launch.
> Lists use cursor pagination via the page[cursor] and page[limit] query params; follow meta.pagination.next_cursor until it is null.
> When the same operation exists on more than one surface, use the newest: dated API versions are newer than unversioned ones, and later dates win (v2026-04 > v2025-06 > unversioned v0/v1.1). Fall back to a legacy or unversioned operation only when no newer versioned equivalent exists — the company-v0 notes below list the known superseded operations. The same applies to /api/company/v1 and /api/v1/... paths: prefer a newer documented equivalent, and use one only when none exists (/api/v1.1/... is distinct and documented in company-v0). Use page/per_page offset pagination only on an operation whose spec documents those params — mostly the unversioned company-v0 admin surface, plus some lists on other surfaces, versioned ones included; page every other list with cursors.
> Fluid has three navigation APIs; don't mix them up. Storefront website menus (navigation bars, footers) are /api/menus and nested menu_items, in api-reference/content-v0.yaml (API Reference: Website > Navigation menus), with a how-to in themes/navigation-menus; their list uses flat page/per_page pagination. The Fluid mobile app's navigation is /api/v2/mobile_navigations, in api-reference/mobile-v2.yaml (API Reference: Mobile app > Navigation); its list also uses page/per_page. Portal navigations belong to a portal definition (Fluid OS), in api-reference/fluid-os-v0.yaml (API Reference: Portal > Portal navigation), and each has a platform of web or mobile.
> The OpenAPI specs under api-reference/ are the authoritative contracts; prefer them over prose when in doubt. api-reference/storefront-v2026-04.yaml covers the v2026-04 storefront surface (/api/v202604/... paths); api-reference/checkout-v2026-04.yaml covers the v2026-04 checkout surface (/api/checkout/v2026-04/... paths — carts, cart auth, discounts, items, subscriptions, orders, enrollments, and store config); api-reference/public-v2025-06.yaml covers the Public SDK surface used by the @fluid-app FairShare SDK, including its parallel cart lifecycle, browser integrations, versioned payment callbacks, unversioned public utilities, and the cart price-override operation; api-reference/payment-v2026-04.yaml covers the v2026-04 payment gateway admin surface (/api/payment/v2026-04/... paths, bearer-authenticated — gateway CRUD, gateway purchase/authorize/$0-verify, transaction list/show and capture/void/credit, and merchant payment configuration); api-reference/payments-v2026-04.yaml covers the v2026-04 cart payment surface (/api/payments/v2026-04/carts/{cart_token}/... paths, authenticated by the cart token in the path with no bearer — payment-method selection, VGS card tokenization, 3D Secure verification, and PayPal/Braintree/Klarna/Apple Pay flows); api-reference/commerce-v2026-04.yaml covers the v2026-04 commerce order-editing surface (/api/v202604/orders/{order_id}/edits paths, bearer-authenticated — post-checkout order edits that atomically insert items and add adjustments/discounts, with an optional dry-run preview); api-reference/webhooks-v0.yaml covers the unversioned webhooks surface (/api/... paths — webhook registration, delivery payloads, callback registrations, company events, and webhook/callback schemas); api-reference/company-v0.yaml covers the legacy unversioned company admin surface (/api/... paths, bearer-authenticated except two operations that take no credential, POST /api/company (create a company) and GET /api/agreements/{id} — company settings and management, customers, users, roles, subscription plans, subscription bundles, subscriptions, media, pages, catch-ups, inventory levels, domains, agreements, and admin order actions). company-v0 caveats: it is the legacy v0 admin contract and its lists use flat page/per_page offset pagination, which is expected there despite the general cursor-pagination rule; where an operation exists in both company-v0 and a versioned spec, prefer the versioned spec — the subscriptions lifecycle (list/create/show/update, cancel, pause, reactivate, resume, retry, skip, failed-cycle-waiver, discounts) and subscription bundles are superseded by checkout-v2026-04, and company pages/media CRUD plus the public pages, categories, products, and media list endpoints are superseded by storefront-v2026-04. Subscription plan management (/api/subscription_plans, resource-wrapped {"subscription_plan": {...}} bodies) exists only in company-v0. api-reference/members-v2025-06.yaml covers the v2025-06 unified Member identity surface (/api/v2025-06/members/... paths, bearer-authenticated — member list/create/show/update, lookup by email/username/external_id/legacy_customer_id, member-type assignment, and the sponsor genealogy read). Prefer it over the customers and reps surfaces when the member type matters: /customers does not serialize member_type. api-reference/analytics-v2026-04.yaml covers the v2026-04 Home dashboard analytics surface (/api/v202604/analytics/dashboard/... paths, bearer-authenticated — read-only endpoints for the Home > Overview, Home > Live, and Home > Field tabs, each accepting an optional country ISO alpha-2 query param that scopes aggregations to a single country).
> api-reference/analytics-v0.yaml covers the unversioned analytics surface that backs the fluid-admin Traffic tab (/api/analytics/... and /api/analytics/traffic/... paths, bearer-authenticated — the legacy shares/views/visitors summary plus traffic overview, ranked campaigns, sources, geographies, flows, and per-rep breakdown, all sharing one reporting-period contract).
> Successful responses wrap the resource payload alongside a top-level integer status and a meta object.
> Portal Definition authoring edits and synchronizes the portal JSON resource graph. Widget Package authoring builds either a company-owned or Droplet-owned Remote DOM package. These are separate contracts; do not imply that one defines the other.
> For Widget Package worker code, use only @fluid-app/portal-sdk/widgets/worker. Use only the Portal Definition and Widget Package workflows and public entry points documented here; do not infer support for undocumented surfaces.
> Every portal function and declarative capability used by a widget must appear in that widget's uses array. Use the same typed function value in uses; do not invent capability-name strings.
> Widget styling must use the portal's semantic theme variables for colors, typography, spacing, radii, borders, focus, and charts whenever a token represents the visual decision. Do not create a separate light or dark palette or duplicate theme controls as widget properties.
> Prefer worker-safe Fluid UI components exported by @fluid-app/portal-sdk/widgets/worker when they fit the interaction. When no exported component fits, use semantic HTML, accessible behavior, and the portal theme variables.
> A Portal Definition push updates the remote working definition. A portal version is an immutable snapshot, and activation is a separate live release operation.
> The Help Center (/help/...) is for merchants, admins and reps using Fluid. Its admin pages mirror the admin's routes: the screen at admin.fluid.app/settings/taxes is documented at /help/admin/settings/taxes. Use the Help Center for how-to questions about the admin, and the Developer Platform and API Reference for building integrations.
> Help Center pages describe what a company admin sees. A reader's role can hide screens and actions; admins manage roles on Settings > Roles (/help/admin/settings/roles). If someone can't find a screen or button, their role's permissions are the first thing to check.
> Send people who need Fluid support to /help/getting-help. Don't invent support email addresses, phone numbers or response times.

# Read viewer data in site scripts

> Reach Fluid's member APIs from a member site's own JavaScript with window.fluid.fetch, handle the Response it returns, and declare the scopes your calls use in config/access.json.

A member site's templates carry the site's structure and menus. They don't carry the viewer's data. A site gets that data in its own JavaScript, through `window.fluid`. It has two members: `fluid.fetch`, which reaches Fluid's APIs, and `fluid.viewer()`, which says who is viewing. This page covers both, who gets data back, how to handle each answer and how to declare what your scripts use.

## Know how a script reaches Fluid

A site renders in a [sandboxed frame](https://docs.fluid.app/member-sites/templates.md#know-the-frames-rules). The frame has an opaque origin and no cookie. So a call from your script with the page's own `fetch` carries no session and can't reach a Fluid API as the viewer.

The site SDK installs `window.fluid` in the frame instead. A call travels from the frame to Fluid's page around it, and from there to the member API as the viewer. Fluid forwards only routes it allows. Site management routes, such as a site's files and pages, aren't reachable from site code.

* **`fluid.fetch(path, init)` behaves like `fetch`.** It takes the same arguments and resolves to a `Response`.
* **`fluid.viewer()` says who is viewing.** It returns `"member"` or `"guest"`.
* **The page's own `fetch` stays as it is.** Fluid never replaces `window.fetch`, so you can still use it to call other services. It doesn't reach Fluid.

The SDK loads through `content_for_header`, so print it in your layout's `<head>`. Load your script with `{{ 'site.js' | asset_url | script_tag }}`, or write it inline. See [Use tags and filters](https://docs.fluid.app/member-sites/templates.md#use-tags-and-filters).

> [!WARNING]
>
> Never put a member's data into Liquid output or a `<script>` through a template variable. Never call a Fluid API with the page's own `fetch`, `XMLHttpRequest` or a form post from a site. The frame has no session, so those calls fail.

## Read with fluid.fetch

Pass a path on your company's own host. A Member API path, such as `/api/member/v2026-10/me`, goes as it is. Check `response.ok`, then read the body:

```js assets/site.js theme={null}
const target = document.querySelector("[data-greeting]");

async function showGreeting() {
  if (!target || fluid.viewer() !== "member") return;
  try {
    const response = await fluid.fetch("/api/member/v2026-10/me");
    if (!response.ok) return;
    const { data } = await response.json();
    target.textContent = `Welcome back, ${data.first_name}`;
  } catch (error) {
    // Keep the page usable. The empty element and its fallback stay as they are.
    console.warn("Could not reach Fluid", error);
  }
}

showGreeting();
```

The page prints an empty element for the script to fill:

```liquid pages/index.liquid theme={null}
<p data-greeting>Welcome to {{ site.name }}</p>
```

Render the structure in Liquid and fill the viewer's data in from the script. Show a neutral fallback while a call is pending and when it fails. See [Show the signed-in member](https://docs.fluid.app/api-reference/me/show-the-signed-in-member.md) for the body.

## Write with fluid.fetch

Set the method in `init`, as you would with `fetch`. Send a JSON body with a `content-type` header:

```js assets/site.js theme={null}
async function setLanguage(language) {
  const response = await fluid.fetch("/api/member/v2026-10/me", {
    method: "PATCH",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ language }),
  });
  if (!response.ok) throw new Error(`Could not save (${response.status})`);
  return (await response.json()).data;
}
```

Fluid forwards GET, POST, PUT, PATCH and DELETE. It answers any other method itself, with a `403`. A request body must be JSON, and Fluid refuses one that is too large. See [Update the signed-in member](https://docs.fluid.app/api-reference/me/update-the-signed-in-member.md) for the fields.

## Choose the path

* **A same-host path under `/api/` works.** A full URL on your company's own origin works too.
* **A Member API path stays.** A path that starts with `/api/member/v2026-10/` goes as you wrote it.
* **Any other `/api/` path moves.** Fluid sends `/api/<x>` to `/api/member-storefront/<x>`, the company host's bridge routes.
* **Anything else throws.** A URL on another host, or a path that doesn't start with `/api/`, throws an `Error` before anything is sent.

## Know who gets data

Only the signed-in owner of a member-owned site gets data from `fluid.fetch`, and only while viewing the site published. A site whose published declaration lists no scope gets none, even for its owner.

| Viewer | Site with no declaration | Site with a declaration |
| - | - | - |
| The member who owns the site, viewing it published | Every route a site can reach | The scopes the declaration lists |
| Another signed-in member, including one the site is shared with | Nothing | Nothing |
| A company admin who doesn't own the site | Nothing | Nothing |
| A guest | Nothing | Nothing |
| Anyone viewing a company site | Nothing, because a company site has no member owner | Nothing, because a company site takes no declaration |

* **Sharing grants nothing.** Sharing a site or making it public doesn't change who gets data. A share holder, a company admin and a visitor never get a scope from the site's declaration. See [Share a member site](https://docs.fluid.app/member-sites/sharing.md).
* **`fluid.viewer()` follows that.** It returns `"member"` only when the site's frame can reach Fluid for the viewer. A signed-in viewer the frame can't act for gets `"guest"`, and a call answers with the local `guest` response below.
* **A company site can't use viewer data.** If you want a script to read the viewer, build a member-owned site. Build a company site from Liquid's structure and menus only.
* **A script that works for you may fail for a visitor.** Test with a second member, and show a fallback when a call fails.
* **A site whose owner is no longer an active member grants no scope to anyone.** Its calls are refused.
* **A change to the site applies at once.** A take-down, an owner who is no longer active and a publish that drops a scope all refuse the next call. Fluid checks the site on every request.

## Handle the Response

`fluid.fetch` resolves to a `Response` for any HTTP status, so a refusal isn't an exception. Check `response.ok` first. Fluid's own page answers some requests itself, with a JSON body that holds an `error` string:

| Status | `error` | What happened |
| - | - | - |
| `401` | `guest` | No member is signed in, or the frame can't act for the viewer. Nothing was sent |
| `403` | `bridge_refused` | Fluid refused to forward the request, such as one with a method it doesn't forward |
| `413` | `bridge_too_large` | The request body is too large |
| `415` | `bridge_unsupported_body` | The request body isn't JSON |
| `429` | `bridge_busy` | Fluid is busy, and the request wasn't sent. Try again |

Any other status comes from the API, with its own body. One refusal is about the site's declaration. The owner of a site that published a declaration gets a `403` for a path whose scope the declaration lacks. The body names the scope:

```json theme={null}
{
  "error": {
    "message": "This site has not declared what this request needs",
    "details": { "error": "member_site_scope_undeclared", "scope": "profile: write" }
  }
}
```

Every other refusal of a bridged call keeps one body, `member_site_unavailable`, so a response never says whether a site exists. That covers a site that is unknown, unpublished or company-owned, a viewer who isn't its owner and a path that no scope covers.

Read the status first, then the body:

```js assets/site.js theme={null}
const response = await fluid.fetch("/api/member/v2026-10/tasks");

if (response.status === 401) {
  showMessage("Sign in to see your tasks.");
} else if (response.status === 403) {
  const body = await response.json();
  const details = body.error?.details;
  if (details?.error === "member_site_scope_undeclared") {
    console.warn(`Declare "${details.scope}" in config/access.json`);
  }
  showMessage("We couldn't load your tasks.");
} else if (response.ok) {
  renderTasks((await response.json()).data);
} else {
  showMessage("We couldn't load your tasks.");
}
```

A call rejects only when something outside the API goes wrong:

* **An `Error`** means the path is on another host or outside `/api/`. Nothing is sent.
* **A `TypeError`** means the transport failed. Fluid's page couldn't be reached, timed out, or answered with a network error.
* **An `AbortError`** means the request's `signal` aborted.

Wrap a call in `try` and `catch` so a rejection keeps the page usable.

## Use a library

A library that accepts a custom `fetch` works with `fluid.fetch`. Pass it in when you create the client. For example, with `ky`:

```js assets/site.js theme={null}
const api = ky.create({ fetch: fluid.fetch });
```

A library built on `XMLHttpRequest` doesn't go through `fluid.fetch`, so it can't reach Fluid from a site. A library that calls the global `fetch` directly has the same limit.

## Know the scope of a path

Each path has a scope. A scope is `<family>: read` or `<family>: write`. The method picks the mode: `GET` needs `read`, and any other method that Fluid forwards needs `write`. The route picks the family, so a request can't borrow another family's scope by changing its path.

| Path | Method | Scope |
| - | - | - |
| `/api/member/v2026-10/me` | `GET` | `profile: read` |
| `/api/member/v2026-10/me` | `PATCH` | `profile: write` |
| `/api/member/v2026-10/tasks` | `GET` | `tasks: read` |
| `/api/member/v2026-10/tasks/:id/complete` | `POST` | `tasks: write` |
| `/api/member/v2026-10/orders` | `GET` | `orders: read` |
| `/api/member/v2026-10/subscriptions` | `GET` | `subscriptions: read` |
| `/api/member/v2026-10/addresses` | `GET` | `addresses: read` |
| `/api/member-storefront/native-widgets/:key/data` | `GET` | `widgets: read` |

See [Show the signed-in member](https://docs.fluid.app/api-reference/me/show-the-signed-in-member.md), [Update the signed-in member](https://docs.fluid.app/api-reference/me/update-the-signed-in-member.md), [List the member's tasks](https://docs.fluid.app/api-reference/tasks/list-the-members-tasks.md) and [Complete a task](https://docs.fluid.app/api-reference/tasks/complete-a-task.md). The [API reference](https://docs.fluid.app/api-reference) lists the rest of the member API. When you aren't sure which scope a path needs, call it from a script and run `fluid member-site lint`, which names the scope the file lacks.

Some routes have no scope. A site can never reach them, and no declaration changes that. Saved payment methods and site management are examples, and so are writes to addresses and subscriptions. A call to one is refused whatever the site declares.

## Declare the scopes you use

List the scope of each path your scripts call in `config/access.json`. The file is one JSON object with one key, `uses`:

```json config/access.json theme={null}
{
  "uses": ["profile: read", "profile: write", "tasks: read", "tasks: write"]
}
```

`fluid member-site lint` checks each `fluid.fetch(path, { method })` call in your scripts against the scope of that path. It warns when the file lacks the scope, when the route can never be reached by a site, and when it can't read the call. Run it before you push. A site with no `config/access.json` isn't checked this way. The file is published with the site.

Fluid enforces the published declaration. It refuses a call whose scope the file lacks with the `member_site_scope_undeclared` response above. [Declare what a member site uses](https://docs.fluid.app/member-sites/access-declarations.md) lists every scope you can declare and explains how to write, publish and check the file.

## Keep scripts working with the published site

A script in `assets/` is live as soon as you push it, while page content stays a draft until you publish. Write a script that still works with the published pages. For example, a script that looks for `[data-greeting]` and does nothing when it isn't there works before and after the page that prints it is published.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.