# Storefronts and the link bar

> For AI agents: the index of these docs is at https://referalli.com/docs/llms.txt (every page it lists has a Markdown version like this one).

Let partners publish a page of products with their own links, and get a link for any shop page while they browse it.

Two ways for a shop's affiliates to share products. Both need products in your [catalog](https://referalli.com/docs/product-catalog) and are off until you turn them on.

## Partner storefronts

A storefront is a page a partner curates: a title, a short bio and an ordered list of catalog products, each pointing at the partner's own tracked link. One per partner per program.

Turn it on for a program:

```bash
curl -X PATCH https://referalli.com/v1/programs/prg_... \
  -H "Authorization: Bearer rk_live_..." \
  -d '{ "storefronts": { "enabled": true } }'
```

Partners then build theirs in the portal, or with the API (session only):

```bash
# create or update (orgId and programId are query parameters)
curl -X PUT "https://referalli.com/v1/partner/storefronts?orgId=org_...&programId=prg_..." \
  -d '{ "slug": "dana-picks", "title": "Dana'"'"'s picks", "published": true }'

# set its products, in order
curl -X PUT https://referalli.com/v1/partner/storefronts/stf_.../items \
  -d '{ "items": [{ "catalogItemId": "cat_...", "note": "My daily pair" }] }'
```

Each product gets the partner's link for it. A partner who adds the same product again, or lists it in a second place, keeps one link.

The public page is `GET /v1/public/storefronts/{orgSlugOrDomain}/{slug}`: the merchant's verified portal domain (or its public tracking token) and the slug. It returns the title, bio, the partner's display name (never an email) and each product with its image, price and short link. It answers 404 unless the storefront is published, the program has storefronts on, and the partner is active and approved. Turning the program setting off hides every storefront at once.

## The get-link bar

A signed-in partner browsing your shop can get a link for the page they are on. Add the script tag with `data-partner-bar="on"`:

```html
<script src="https://referalli.com/t/tk_.../aff.js" data-partner-bar="on" async></script>
```

Nothing shows to visitors. The partner opens the shop from the portal ("Enable the get-link bar on this store"); the portal sends them to the page with a short-lived token in the URL fragment. aff.js moves it into `sessionStorage` (never a cookie, so it needs no consent and writes nothing the consent kit governs), removes it from the address and shows a small fixed bar: "Get your link, earns 10% of every order". One click copies the partner's short link for that page. The bar sits over the page, so nothing shifts.

How it stays safe:

- The token lasts 8 hours, is only valid on this endpoint (`POST /t/{orgToken}/bar`) and reaches no other API route. Minting a new one revokes the previous.
- The link comes from the catalog product at that URL (same link as the storefront uses), else a plain link on your site; a URL on any other site is refused.
- The partner can close the bar, which forgets the token for that tab.

Mint a token yourself with `POST /v1/partner/storefront-bar/token` (`orgId`, `programId`, `storeUrl`); it returns the URL to open.

## Embeddable product cards

A partner can put a product card on any page they control: the product's image, title and price, a "Shop" button that goes through the partner's short link, and an "Affiliate link" disclosure. The card uses your portal theme colours. It is a small HTML page in an iframe, with no script, no cookies and no partner id or email in it.

In the portal, **Products > Embed** (shown once the partner has a link for the product) gives the snippet:

```html
<div data-referalli-card="tk_.../abc123"></div>
<script src="https://referalli.com/t/cards.js" async></script>
```

`cards.js` replaces each div with a sandboxed iframe from the script's own origin. The reference is `{trackingToken}/{linkCode}`.

The same card is available without the script:

- `GET /t/{orgToken}/card/{code}` returns the card page (cached 5 minutes, framable from any site, loads only https images).
- `GET /t/{orgToken}/card/{code}.json` returns an oEmbed-like object: `{ version, type: "rich", title, width, height, thumbnail_url, html }`, where `html` is the iframe.

Both answer 404 unless the link is a product link (made from a catalog item) whose catalog item is still active, so a card never shows a product you have removed.

---

## For AI agents

- This page for a human reader: https://referalli.com/docs/storefronts-and-link-bar
- The whole space as one Markdown file: https://referalli.com/docs/llms-full.txt
- Live search + fetch over MCP: https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/mcp
  - Install (Claude CLI): `claude mcp add referalli --transport http https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/mcp`

This Markdown is the same content the page renders — safe to quote and to ground answers in.
