# UXXRAY for agents — research the corpus, build original work, report the comparison

**UXXRAY does not design.** It hands you measured references with receipts and hosts the review;
the original work is yours. Everything here is MEASURED from live pages (deterministic extraction,
every claim carrying the on-page string that produced it, no LLM judgment in the data).

## THE CONTRACT — three steps, in this order

**1. RESEARCH** — before you design anything. Two calls, both public, no key:

    GET https://api.uxxray.com/api/v1/library/specimens?kind=section&archetype=hero&funnel_type=saas&scope=broad
    GET https://api.uxxray.com/api/v1/patterns?funnel_type=saas

The first is the real pages: `availability.available` is how many exist for your filters (that is
your N), and each specimen has a `crop_url` to LOOK at. Change `kind` (`section` + `archetype`,
`page`, `element`), `archetype` and `funnel_type` to match what you are building. The second is
the tactic rates for that funnel type: each pattern has `prevalence.pct` and `prevalence.scored`
(optionally add `&depth_class=…`). Use the tactics (urgency, offer, social proof, guarantee …) as
your checklist while you design. Not sure of the filters? `GET https://api.uxxray.com/api/v1/library/index`.

**2. BUILD** — original concepts (3-4 genuinely different directions), registered into a Design
Factory session (Reference D below). Structural and strategic reference only: do NOT copy source DOM,
CSS, brand colours, logos, imagery or verbatim copy.

Register ONE responsive page per concept, at real size, with no device frames, no side-by-side desktop/phone mock-ups and no labels like 'Desktop' or 'Phone'. The review page shows it at 1440 and 390 itself (its own device toggle); make it work at both widths with CSS media queries.

**3. REPORT** — your final message to your human MUST contain the review link and this comparison.
A draft with a link and no comparison is unfinished. Fill the template from the API responses and
from nothing else:

    Compared against {N} real {kind} specimens ({filters}).
    {tactic}: mine HAS|LACKS it. {pct}% of {scored} {funnel_type} funnels run it.
    {tactic}: mine HAS|LACKS it. {pct}% of {scored} {funnel_type} funnels run it.
    Missing: {the tactics it LACKS that most of the corpus has, or "none"}.
    Review: https://uxxray.com/factory/sessions/?id={session_id}

e.g. (illustrative numbers) `Compared against 253 real saas hero specimens (kind=section, archetype=hero). Free trial:
mine LACKS it. 78% of 1,872 saas funnels run it.` N is `availability.available`. `pct` and `scored`
are copied from `prevalence.pct` and `prevalence.scored`. **Never estimate or round a number the
API did not give you**; if a tactic has no rate, say "no corpus rate". Has/LACKS is your own reading
of your own draft, so say it plainly and do not claim UXXRAY verified it.

Send the same numbers with every concept you register, as the optional `research` field:
`{"research": {"compared_n": 253, "tactics": [{"id": "free_trial", "mine": false, "pct": 78, "scored": 1872}]}}`.
It is stored and shown to the reviewer next to the brief. It is never required.

The rest of this document is the reference for those three steps.

    research -> build original concepts -> open a review session -> report + review link
       -> read the verdict -> download the bundle

## Reference A — See the whole shelf
`GET https://api.uxxray.com/api/v1/library/index`

Every facet, every legal value, real counts. No specimens — it is the map, and it is cheap.

**Read the counts before you ask for anything.** The inventory is LUMPY and pretending otherwise
is the one thing this product will not do: hero and faq run to the hundreds while stat_proof is
in single digits, and narrowing by `funnel_type` on top of that thins it further. If you ask for
20 and only 9 exist, the response says `showing 9 of 9 available` rather than let nine read as a
page of many. The index has the live numbers — never quote one from memory.

Two things can select specimens, and you pick ONE per request:

- `kind` — `section` (+ `archetype`), `page` (+ optional `template`), `element`
- `playbook` — funnels measurably running one named play

`funnel_type` is a filter and composes with either. Naming both axes returns 400 with the rule,
because applying one and dropping the other would hand you a set that looks like it honoured your
whole query.

## Reference B — Take as much as you want
`GET https://api.uxxray.com/api/v1/library/specimens?kind=section&archetype=hero&scope=broad`

**YOU choose the breadth, and you can change it every round.** The tiers differ in how much of
each specimen you get, not only in how many:

| scope | returns | each specimen carries |
|---|---|---|
| `narrow` | 5 | everything — crop, the pattern counts (`patterns_detected` of `patterns_total`), and every tactic receipt with its VERBATIM on-page evidence |
| `broad` | 20 **(default)** | crop, and which tactics the funnel runs — pattern ids, no quotes, no counts |
| `full` | the whole roster | identity only (ref, slug, domain, funnel type, template). No crops, no receipts, no counts. The map of what exists |

Silence gets you 20. The corpus holds hundreds of hero bands — `scope=full` lists every one as a
roster so YOU pick, then re-request the ones you chose at `scope=narrow` for their receipts. That
is the intended loop: roster to survey, narrow to study.

Every specimen carries:

- `crop_url` — **a real cropped image of THIS band**, ~1440px wide and ~27KB, cut at build
  time from the page's own screenshot. **Fetch this, look at it.** It is `null` only when no
  crop exists, and `crop_unavailable_reason` then says which rule refused: a band too thin to
  frame honestly, or too tall to be a section. `full_url` is never substituted for it.
- `crop` — `y`/`h` as fractions of `full_url`, for a consumer that would rather window
  the whole page. `cut_h` is the height the image was actually cut at; where it differs from
  `h`, the band was thinner than the display floor and the picture includes what follows it.
- `receipts.patterns[]` — every tactic the funnel measurably runs, each with the VERBATIM
  on-page evidence, e.g. `"pricing: comparison table: FREE · TRAVELER · NOMAD"`.
  `receipts.scope` is `"funnel"`: the tactics describe the whole walked funnel, **not** this
  one band. Do not report them as properties of the section.
- `score` — a RANKING signal for references, not a grade. See "What the number is" below.

### One specimen per domain, by default
A ranked response returns at most ONE specimen per domain, so twenty results are twenty different
sites. Score is FUNNEL-scoped — every page of one walk shares it — so without the cap a four-page
funnel takes four consecutive slots; measured, 20 SaaS heroes out of 1,725 came from six domains.
`&per_domain=3` raises it, `&per_domain=all` lifts it for studying one funnel's whole set.
Bands the crop pipeline refuses are not ranked at all. Every reduction is stated in the response
and `availability.available` still reports the true population.

### Never get served the same specimen twice
`&exclude_seen_project=<your project>` with your `x-uxxray-visitor` header excludes every
specimen ANY of your sessions already used for that project. `exclude_seen_session=<id>` does the
same for one session and needs no token; `exclude_seen=<refs>` takes an explicit list.

**Use it on every round after the first.** A ranked pool returns its best matches in the same
order every time, so a second round without this asks the same question and gets the same answer.
That is not a hypothetical: a real worker built 15 concepts across three sessions from FIVE
distinct specimens because nothing told it there were more.

**LOOK at the crops.** You can read images. The screenshots are the ground truth the data was
measured from, and the composition is the part no JSON field carries.

### Shortcut, once you know the shelf
`GET https://api.uxxray.com/api/v1/library/resolve?task=build_review_section` maps design-task language to
corpus vocabulary, and `GET https://api.uxxray.com/api/v1/library/brief?task=…&top=3` returns a small curated
set with `selected_because` on each. A convenience for a second round, not where you start: three
specimens is not a comparison, and the brief cannot know what you already used.

## Reference C — Build original concepts
Structural and strategic reference only. Original layout, original copy, original visual style.
Do NOT copy source DOM, CSS, brand colours, logos, imagery or verbatim copy. The evidence strings
prove a tactic is real on that page — they are not text to reuse.

Aim for 3-4 genuinely different directions, not one idea in four skins.

## Reference D — Open a Design Factory session
`POST https://api.uxxray.com/api/v1/factory/sessions`

The step-2 response hands you the body already filled in — see `next.create_session`; it pre-seeds
`source_specimens` with the refs of the specimens you were just served. That is what makes the
finished artifact traceable back to measured sources, **and it is what makes
`exclude_seen_project` work on your next round.** Register the refs you actually used, or the
library has no way to know what to stop showing you.

**`task` — KEEP IT UNDER 118 CHARACTERS.** It is the review page's headline, not a brief. The API
accepts 120 and will truncate silently at exactly 120, mid-word, which is how one real session
shipped a title ending `...and a real "why `. 118 is measured, not chosen, and it is RE-measured
whenever the h1 changes: `node scripts/measure-task-limit.mjs` sweeps lengths against the rule
that actually ships. It was 72 until 2026-08-07, when the task became a one-line disclosure at a
smaller type scale — the same string now costs a third of the height, so a tighter limit would be a
number derived from a page nobody serves. Put the detail in each concept's
`brief_md`, which has room for it and is rendered where a reader wants it.

  good: `Rebuild the /vpn/ hero: personalized, ONE provider, no sub-nav`   (61)
  bad:  `Rebuild the /vpn/ hero: personalized (quiz answer + device + region), ONE provider not two, no sub-nav, and a real "why it beats the rest"`   (137, truncated to 120)

**KEEP THE `session_token` THE RESPONSE GIVES YOU.** It is shown once and cannot be recovered —
only its hash is stored. It is what lets you register concepts. Two different things come back
and they are not interchangeable:

- `session_id` — read the session and leave feedback. **This is the review link. It is safe to
  hand a human**, and it is all they need.
- `session_token` — register concepts. **Yours only.** Send it as the
  `x-uxxray-session-token` header. Never put it in a URL — URLs leak through referrer headers,
  browser history and screenshots.

Sessions are **private by default**: reachable only by someone who already has the id, and in no
listing anywhere. Pass `"privacy": "public"` only if the human explicitly wants it listed.

Then register each concept:
`POST https://api.uxxray.com/api/v1/factory/sessions/{session_id}/concepts`
with header `x-uxxray-session-token: <your token>`
and body `{concept_id, title, brief_md, sources, artifact:{html, css, tokens}, research}` (`research` optional, see step 3).

**Send one `delivery` id (a short string, max 64 chars) with every concept in the same batch**, e.g.
`"delivery": "d2"` on each, or POST an array of concepts in one call. The server assigns the ROUND
per delivery: a NEW delivery id opens round N+1 (no verdict needed), and re-sending a delivery id never
opens an extra round. You never send a round number.

**Refer to a concept ONLY by the `label` the server returns** (e.g. `R3·B`, on every registration and in
the session GET). That is what the reviewer reads on the page. Never title a concept with a letter or a
round number ("B · ...", "Round 4.2"): that is refused with a 400. Put sequence in `version_label`.
`parent_concept_id` is lineage only (1.0 / 1.1 labels), it does not set the round.

Without the header this returns **401** — that is the review link failing to authorise a write,
which is the point. `artifact` must carry non-empty `html` or `css`, or registration is
rejected: a concept nobody can look at is a failed registration, and you should hear about it
rather than the human discovering a blank card.

Keep artifacts portable and compact — a section, not a project bundle. Oversize payloads are
rejected rather than truncated.

## Reference E — Report and hand your human the review link
The session response carries `review_url`:

    https://uxxray.com/factory/sessions/?id={session_id}

**Always hand over this SESSION link (never a per-concept or per-round link): the review page has the R1 | R2 | R3 toggle itself.** Give it to them, with the step-3 comparison above it. This is the step agents skip.** They star, rate and comment on each concept in
a workspace that previews your artifacts in sandboxed iframes. You cannot judge your own design
work, and the whole point of the session is that a human does not have to read your code to react
to it.

## Reference F — Read the verdict back
`GET https://api.uxxray.com/api/v1/factory/sessions/{session_id}/feedback`

Returns per-concept stars, ratings, comments and a summary naming what was starred. Refine the
winner from the actual comment; do not restart from scratch.

**WAIT for the verdict; do not make the owner tell you he is done.** There is no way to push to
you, so after handing over the review link, long-poll: `GET .../feedback?wait=90` holds the
request open (re-checking about every 3 seconds) and returns the moment the reviewer has answered
every open concept in the latest round, or at 90 seconds with `done:false`. Repeat while
`done` is false; stop when it is true, then read `summary` and refine as a NEW delivery in the
SAME session. Run it as a BACKGROUND command so you stay free. Optional `&since=<iso or round>`
also returns on anything newer than that. The session GET reports your wait as `agent_waiting_since`.
```sh
# background this; it exits when the reviewer is done
until curl -sf "https://api.uxxray.com/api/v1/factory/sessions/$SID/feedback?wait=90" -o fb.json \
      && grep -q '"done":true' fb.json; do sleep 1; done
cat fb.json   # per-concept verdicts and comments; now POST the refinement as a new delivery
```

**Refine in the SAME session. Never open a new session for a refinement of the same task.** After
reading the verdict, register the refinement as a NEW DELIVERY in this SAME session: same
`session_id`, same `session_token`, a new `delivery` id (e.g. `"d3"` after `"d2"`). The server opens the next
round for you. Hand the reviewer the SAME session link as before; the review page opens on the round
that needs them. Open a new session only for a genuinely new task. A new session for a refinement
leaves the reviewer a new link per round and the R1 | R2 | R3 toggle never applies.

**Register the refinement with `parent_concept_id` set to the concept you refined.** That link is
the only thing that makes the workspace read as a design history instead of a growing pile: it
puts the new version on the SAME card, behind a version toggle, instead of adding a fourth tile.
Omit the parent only when you mean a genuinely new direction.

You never send a version NUMBER — 1.0 / 1.1 / 1.2 is derived from that link, so it cannot drift.
You may send an optional `version_label` (max 40 chars) NAMING the version — "tighter proof",
"warm paper". It is printed on the toggle and the derived number stays beside it.

## Reference G — Download it into their project
`GET https://api.uxxray.com/api/v1/factory/sessions/{session_id}/concepts/{concept_id}/artifact`

Stack-neutral bundle: `index.html`, `style.css`, `tokens.json`, `sources.json`, `brief.md`.
`sources.json` preserves the provenance chain — which measured specimens informed it.

You are almost certainly working in the USER'S repo, not UXXRAY's, so just fetch that endpoint
and write the files yourself — it needs no tooling and no auth. Suggested location:
`.uxxray/factory/<session_id>/<concept_id>/` (add `.uxxray/` to their .gitignore; these are
re-pullable working copies, never source of truth).

A convenience adapter exists for anyone who has the UXXRAY repo checked out
(`npm run factory:pull -- <session_id> --concept starred`), but there is no published CLI —
do not tell a user to run `npx uxxray`.

## Going deeper than one section
When the task is a whole funnel rather than one band:

- `GET https://api.uxxray.com/api/v1/playbooks` — the named plays and which funnels measurably run each.
- `GET https://api.uxxray.com/api/v1/templates` — recurring section-skeletons real pages are built from.
- `GET https://api.uxxray.com/api/v1/patterns` (+ `/{pattern_id}`) — each tactic with up to 60 verbatim examples.
- `GET https://api.uxxray.com/api/v1/sections` — archetype prevalence and where each band typically sits.

Read one strong funnel end to end when you need the whole composition:
- comparitech.com (affiliate): `GET https://api.uxxray.com/api/v1/teardown/comparitech/bundle`
- viewra.co (saas): `GET https://api.uxxray.com/api/v1/teardown/viewra-co/bundle`
- ainexfinder.com (saas): `GET https://api.uxxray.com/api/v1/teardown/ainexfinder/bundle`
- dapdip.com (saas): `GET https://api.uxxray.com/api/v1/teardown/dapdip/bundle`
- findalternative.to (saas): `GET https://api.uxxray.com/api/v1/teardown/findalternative-to/bundle`
- launchelion.com (saas): `GET https://api.uxxray.com/api/v1/teardown/launchelion/bundle`

## What the number is, and is not
The /100 is **detected conversion-tactic coverage**, funnel-type-aware. It is not a quality
grade, not a UX score, and not taste. Its job here is to RANK references so the library can put
something useful first — **the crop is the product, the score is the sort order.** A well-built
unconventional funnel can register low. Never tell a user their site is "bad" because of it.

## Rules that keep you honest
- Every claim carries evidence. If a signal is absent it was NOT measured — never guess it onto a site.
- Prevalence is scoped to the crawled corpus (SaaS-heavy today), never "the web".
- Playbook matches are SURFACE matches; ads and emails are unobservable from a crawl.
- Specimens are references. Shipping a copy of someone's section is not what this is for.

## ★ Rate this
How useful was this? 1 = poor, 5 = excellent. Pass the question to your user if one is present
(via:"user"), else answer yourself (via:"agent"):
`POST https://api.uxxray.com/api/v1/rate {"rating": 1-5, "context": "curriculum", "via": "agent", "comment": "optional"}`
