# Toll-free streamlines: the organization's key pays

An organization can make one of its **public** streamlines **toll-free**: its own model key pays, so anyone can chat
with it without an app account or a key of their own. It chooses **where** that free chat happens:

| Place | `places` | Default | What a visitor sees |
|---|---|---|---|
| Its own websites | `embed` | off | a chat button on the pages that carry the one-line embed tag, only on the sites listed |
| Toll-free AI | `site` | on | the streamline on tollfree.streamliner.work with **Start Chat** |
| The Streamliner app | `app` | on | the streamline in Discover runs without the person's own key; the chat says once that the organization pays |

A streamline **listed publicly in Discover** can be toll-free everywhere ([listings.md](listings.md)). One **shared by
link only** is toll-free on its own websites only: the embed, with the sites named (not "any"); Toll-free AI and the app stay
off until it is in Discover. On a streamline not shared at all the block is kept but does nothing, and the checker warns. Organization accounts only (personal accounts don't sponsor). Owners and
admins set it, in the streamline's settings in the app (*Toll-free*), through the Concierge, from files on this Mac, or
with `admin.mjs` below: all four change the same block.

## The block

It lives in the streamline's **private** file, `private/agents/<kind>.json`, key `tollfree`. It never reaches a member's
device or a visitor's browser: visitors get only what drawing the chat needs.

```json
"tollfree": {
  "enabled": true,
  "credentialRef": "anthropic-main",
  "places": { "embed": true, "site": true, "app": true },
  "embed": { "origins": ["https://meridian.example"], "title": "Ask Meridian", "subtitle": "Free, from Meridian Jewelers" },
  "limits": { "dailyUSD": 5, "perVisitor": { "burst": 6, "hour": 40, "day": 150, "dailyUSD": 0.10 } },
  "words": { "outOfAllowance": "That's all the free questions for today. Ask again tomorrow.", "busy": "We've answered a lot of questions today. Please ask again tomorrow." }
}
```

- `enabled` turns it on or off. `credentialRef` names the model key that pays: a key the organization set on the account
  (the app's Vault, *Organization model key*), never the key itself. No key set, or the budget reached, and visitors see
  a calm "busy" card; Streamliner's own key never pays for an organization's streamline.
- `embed.origins`: the exact sites the chat may be embedded on (1 to 20, each `https://host` with no path; a dev account
  may also list `http://localhost:<port>`), **or** `"any"`. **"Any site" means what it says: any website can put this
  chat on its pages, and your key pays for it.** Choose it only on purpose. A listed site you don't own gains nothing:
  only that site's owner can put the tag on its pages. `title` (up to 60 characters) and `subtitle` (up to 90) head the
  chat's panel.
- `limits.dailyUSD`: the streamline's budget per day on the organization's key ($0.01 to $10,000; default $5). Each
  visitor (or each app install): `perVisitor.burst` messages in 10 seconds (default 6), `hour` (40), `day` (150), and
  `dailyUSD`, their share of the budget per day (default $0.10).
- `words.outOfAllowance` (a visitor used their share) and `words.busy` (the budget is spent): plain text up to 200
  characters, no `<` or `>`. Left out, Streamliner's own words are used.

The checker's codes: `tollfree.notListed` (a warning: the streamline isn't shared), `tollfree.linkOnly` (a warning:
shared by link only, so only named websites count), `tollfree.noKey` (on, with no
`credentialRef`), `tollfree.origin` (not an exact https origin), `tollfree.noOrigins` (embed on, no sites),
`tollfree.range` (a limit out of range), `tollfree.words` (too long, or markup).

## From a terminal: `admin.mjs tollfree`

Reads and dry runs take a server key with scope `config`, or an owner's or admin's session (`SL_ADMIN_BEARER`). A change
is published as a signed revision, so `--yes` takes the **server key and one of the organization's publisher keys**
(`--publisher-key <jwk>`, default `_local/keys/<account>.publisher.jwk`; `--publisher-key-id <id>` when the file has no
`kid` and the key isn't found in `enrolment.json`), never a session. A change is a dry run until `--yes`; no key is ever
printed.

```bash
node scripts/admin.mjs meridian https://streamliner.work tollfree register                   # the block, today's spend, listed or not
node scripts/admin.mjs meridian https://streamliner.work tollfree register --tag             # the embed tag, alone
node scripts/admin.mjs meridian https://streamliner.work tollfree register \
  --on --credential anthropic-main --places embed,site,app --origin https://meridian.example --budget 5   # dry run
# … the same with --publisher-key <jwk> --yes, on the person's yes
```

| Flag | Changes |
|---|---|
| `--on` / `--off` | `enabled` |
| `--credential <ref>` | `credentialRef` (a key's name, never a key) |
| `--places embed,site,app` (or `none`) | the places listed are on, the rest off |
| `--origin <url>` (repeat) / `--remove-origin <url>` | adds or removes a site |
| `--any` | `embed.origins` = `"any"` |
| `--title <text>` / `--subtitle <text>` | `embed.title`, `embed.subtitle` |
| `--budget <usd>` | `limits.dailyUSD` |
| `--per-visitor burst=6,hour=40,day=150,usd=0.10` | `limits.perVisitor` (`usd` is its `dailyUSD`) |
| `--words-out <text>` / `--words-busy <text>` | `words.outOfAllowance`, `words.busy` |

It reads the block (`GET /v1/admin/<t>/streamlines/<kind>/tollfree`: the block where the next write lands, `env`
(Staging while it is on, else Live), `live.enabled` (whether Live has it on), `listed`, `embedTag`, `today`'s spend and
`keyPresent`, never a key), changes only what the flags name and checks the result with the config checker's own
toll-free rules (`checkTollfree` in runtime/configcheck.js: the skill zip's `scripts/vendor/`, or a Streamliner checkout).
Then, because the Worker never signs config (config-schema §4.5.2, §8d), the write has two steps:

1. `PUT /v1/admin/<t>/streamlines/<kind>/tollfree?dryRun=1` with `{ "tollfree": <the whole block> }` writes nothing and answers where it lands (`env`,
   `baseRevision`, `nextRevision`), `unchanged`, warnings in `issues`, and `manifest`: the next manifest, unsigned. The
   dry run stops here and prints it.
2. With `--yes`, `admin.mjs` signs that manifest with the publisher key (Ed25519 over its JCS bytes without `signature`,
   as sign-config.mjs does) and sends `PUT /v1/admin/<t>/streamlines/<kind>/tollfree` with `{ "tollfree", "manifest", "baseRevision" }`, the request
   signed with the server key → `{ ok, revision, env, tollfree }`. To Staging while Staging is on (then promote), else
   Live.

Answers it handles: `409 behind` (someone published meanwhile: it reads the block again and sends once more, then stops),
`409 unchanged` (nothing to change), `428 signature_needed` (the manifest wasn't taken as signed: nothing written),
`400 invalid` with each `issues[]` entry, `400 bad_manifest_signature` (not the organization's publisher key).
`DELETE` on the same route removes the block (the same two steps; `admin.mjs` has no flag for it: `--off` keeps the
block). Spend over time is in the usage routes, the streamline's row (`admin.mjs … usage summary`).

## From files on this Mac

The block is one more field of `private/agents/<kind>.json` in the organization's folder: edit the file and
`node scripts/mirror.mjs put <file> --place <folder> --path private/agents/<kind>.json` (a dry run naming each
toll-free field that changes, then `--yes`), then `push` as with any change (SKILL.md, *Organization from the mirror*).

## The embed tag

One line on each page of the listed sites (`--tag` prints the real one):

```html
<script src="https://tollfree.streamliner.work/embed.js" data-listing="<listing id>" async></script>
```
