[{"data":1,"prerenderedAt":982,"buildId":983},["ShallowReactive",2],{"docs:\u002Fguide\u002Fnegotiation":3},{"page":4,"section":16,"document":17,"credits":10,"prev":974,"next":978},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":8,"description":9,"tagline":9,"eyebrow":10,"credits":10,"keywords":11,"icon":12,"layout":13,"sidebar":14,"toc":14,"kind":10,"group":10,"navigation":14,"order":15},"negotiation","\u002Fguide\u002Fnegotiation","guide\u002Fnegotiation.md","Negotiation","The seven rules that pick a form from a twin URL, ?format= and Accept, and what Claude Code, Cursor, Codex and curl get from each.",null,[],"i-lucide-scale","article",true,5,"guide",{"nodes":18,"toc":960},[19,28,36,100,106,156,162,171,362,368,374,468,474,486,491,525,531,551,713,720,776,782,788,799,805,816,822,874,879,885],[20,21,22,23,27],"p",{},"whoasks makes one pick per request: a form and a media type. The rules below run in the same order every time. ",[24,25,26],"code",{},"site.ask(request)"," returns the pick.",[29,30,35],"h2",{"id":31,"anchor":32},"three-words",{"label":33,"icon":34},"Section titled \"Three words\"","#","Three words",[37,38,39,55,63,69,78],"ul",{},[40,41,42,43,46,47,50,51,54],"li",{},"For a media type, the range that applies is the most specific one in ",[24,44,45],{},"Accept",": the exact type, then ",[24,48,49],{},"type\u002F*",", then ",[24,52,53],{},"*\u002F*",".",[40,56,57,58,62],{},"A type is ",[59,60,61],"strong",{},"named"," when an exact range lists it with q above 0.",[40,64,57,65,68],{},[59,66,67],{},"permitted"," when the range that applies has q above 0.",[40,70,71,72,74,75,77],{},"A missing, empty, or unreadable ",[24,73,45],{}," counts as ",[24,76,53],{},". A range with a malformed type or q is dropped.",[40,79,80,81,84,85,88,89,50,92,95,96,99],{},"A route's ",[59,82,83],{},"offers"," are the forms it can produce, in order. A page behind ",[24,86,87],{},"handle"," offers ",[24,90,91],{},"html",[24,93,94],{},"markdown",". A route that calls ",[24,97,98],{},"respond"," offers its keys.",[29,101,105],{"id":102,"anchor":103},"the-rules",{"label":104,"icon":34},"Section titled \"The rules\"","The rules",[107,108,109,116,122,125,132,135,143],"ol",{},[40,110,111,112,115],{},"A twin URL, or ",[24,113,114],{},"?format="," naming an offered form, reduces the offers to that form. The twin is checked first.",[40,117,118,119,121],{},"Among offered forms with a named type, the highest q wins. On equal q, the type listed first in ",[24,120,45],{}," wins.",[40,123,124],{},"If no offered form is named, the first offered form with a permitted type wins. A wildcard permits and never prefers.",[40,126,127,128,131],{},"If nothing offered is permitted, the pick is the first offer and ",[24,129,130],{},"acceptable"," is false.",[40,133,134],{},"The media type sent is the named type that won, else the form's first permitted type, else its first type.",[40,136,137,138,54],{},"The hooks of the layers run last, in layer order. A hook cannot pick a form or a type the request did not allow. See ",[139,140,142],"a",{"href":141},"\u002Fguide\u002Flayers#change-the-pick","Change the pick",[40,144,145,146,148,149,152,153,54],{},"Every response whoasks shapes, and every HTML response that passes through ",[24,147,87],{},", carries ",[24,150,151],{},"Vary"," with the entries of ",[24,154,155],{},"ask.vary",[29,157,161],{"id":158,"anchor":159},"examples",{"label":160,"icon":34},"Section titled \"Examples\"","Examples",[20,163,164,165,167,168,170],{},"For a page that offers ",[24,166,91],{}," then ",[24,169,94],{},":",[172,173,174,191],"table",{},[175,176,177],"thead",{},[178,179,180,185,188],"tr",{},[181,182,183],"th",{},[24,184,45],{},[181,186,187],{},"Pick",[181,189,190],{},"Rule",[192,193,194,208,222,236,250,264,278,295,312,328,346],"tbody",{},[178,195,196,201,205],{},[197,198,199],"td",{},[24,200,53],{},[197,202,203],{},[24,204,91],{},[197,206,207],{},"3. Nothing is named, the first offer is permitted",[178,209,210,215,219],{},[197,211,212],{},[24,213,214],{},"text\u002F*",[197,216,217],{},[24,218,91],{},[197,220,221],{},"3. A wildcard does not prefer Markdown",[178,223,224,229,233],{},[197,225,226],{},[24,227,228],{},"text\u002Fmarkdown, text\u002Fhtml",[197,230,231],{},[24,232,94],{},[197,234,235],{},"2. Equal q, Markdown is listed first",[178,237,238,243,247],{},[197,239,240],{},[24,241,242],{},"text\u002Fhtml, text\u002Fmarkdown",[197,244,245],{},[24,246,91],{},[197,248,249],{},"2. Equal q, HTML is listed first",[178,251,252,257,261],{},[197,253,254],{},[24,255,256],{},"text\u002Fhtml;q=0.5, text\u002Fmarkdown;q=0.8",[197,258,259],{},[24,260,94],{},[197,262,263],{},"2. Highest q",[178,265,266,271,275],{},[197,267,268],{},[24,269,270],{},"*\u002F*;q=1, text\u002Fmarkdown;q=0.5",[197,272,273],{},[24,274,94],{},[197,276,277],{},"2. A named type beats a wildcard, whatever its q",[178,279,280,285,289],{},[197,281,282],{},[24,283,284],{},"text\u002Fhtml;q=0, *\u002F*",[197,286,287],{},[24,288,94],{},[197,290,291,292,294],{},"3. HTML is refused, ",[24,293,53],{}," permits Markdown",[178,296,297,302,309],{},[197,298,299],{},[24,300,301],{},"text\u002Fplain",[197,303,304,306,307],{},[24,305,94],{},", sent as ",[24,308,301],{},[197,310,311],{},"5. The named type is sent",[178,313,314,319,325],{},[197,315,316],{},[24,317,318],{},"text\u002Fx-markdown",[197,320,321,306,323],{},[24,322,94],{},[24,324,318],{},[197,326,327],{},"5",[178,329,330,335,343],{},[197,331,332],{},[24,333,334],{},"image\u002Fpng",[197,336,337,339,340],{},[24,338,91],{},", ",[24,341,342],{},"acceptable: false",[197,344,345],{},"4",[178,347,348,353,359],{},[197,349,350],{},[24,351,352],{},"application\u002Fjson",[197,354,355,339,357],{},[24,356,91],{},[24,358,342],{},[197,360,361],{},"4. A page does not offer JSON",[20,363,364,365,367],{},"On equal q, the order in ",[24,366,45],{}," decides, not the order of the offers.",[29,369,373],{"id":370,"anchor":371},"url-overrides",{"label":372,"icon":34},"Section titled \"URL overrides\"","URL overrides",[37,375,376,389,403,416,434,444],{},[40,377,378,379,382,383,385,386,54],{},"A twin is the canonical path plus a form's ",[24,380,381],{},"ext",". Only ",[24,384,94],{}," has one built in, ",[24,387,388],{},".md",[40,390,391,394,395,398,399,402],{},[24,392,393],{},"\u002Findex.md"," is the twin of ",[24,396,397],{},"\u002F",". A path that is only the suffix, such as ",[24,400,401],{},"\u002Fdocs\u002F.md",", is not a twin.",[40,404,405,406,408,409,339,412,415],{},"A twin of a form the route does not offer is not a twin. On a route offering ",[24,407,91],{}," and ",[24,410,411],{},"json",[24,413,414],{},"\u002FREADME.md"," is an ordinary path.",[40,417,418,420,421,423,424,339,427,339,429,339,431,433],{},[24,419,114],{}," takes a form's name or its ",[24,422,381],{}," without the dot, exactly as written: ",[24,425,426],{},"md",[24,428,94],{},[24,430,91],{},[24,432,411],{},". Only offered forms count. Any other value stays in the URL for the app.",[40,435,436,439,440,443],{},[24,437,438],{},"ask.url"," is the URL without the suffix and without ",[24,441,442],{},"format",". Other query parameters stay.",[40,445,446,447,449,450,453,454,457,458,453,460,449,462,464,465,467],{},"An override still checks ",[24,448,45],{},". ",[24,451,452],{},"\u002Fdocs\u002Fguide.md"," with ",[24,455,456],{},"Accept: text\u002Fhtml"," picks ",[24,459,94],{},[24,461,342],{},[24,463,87],{}," answers it with Markdown anyway. A strict ",[24,466,98],{}," answers 406.",[29,469,473],{"id":470,"anchor":471},"nothing-acceptable",{"label":472,"icon":34},"Section titled \"Nothing acceptable\"","Nothing acceptable",[20,475,476,478,479,481,482,54],{},[24,477,87],{}," sends the first offer and never refuses. ",[24,480,98],{}," sends the first offer too, unless the site is strict. See ",[139,483,485],{"href":484},"\u002Fguide\u002Fapi-routes#refuse-with-406","Refuse with 406",[29,487,151],{"id":488,"anchor":489},"vary",{"label":490,"icon":34},"Section titled \"Vary\"",[37,492,493,501,507,517],{},[40,494,495,497,498,54],{},[24,496,155],{}," starts as ",[24,499,500],{},"[\"Accept\"]",[40,502,503,504,54],{},"A hook that reads another header adds it, as the Codex layer adds ",[24,505,506],{},"User-Agent",[40,508,509,510,512,513,516],{},"whoasks appends each name once and keeps a ",[24,511,151],{}," the app already set. ",[24,514,515],{},"Vary: Cookie, accept"," stays as it is.",[40,518,519,520,522,523,54],{},"A response that passes through ",[24,521,87],{}," untouched, such as an image or a plain JSON route, gets no ",[24,524,151],{},[29,526,530],{"id":527,"anchor":528},"what-real-clients-get",{"label":529,"icon":34},"Section titled \"What real clients get\"","What real clients get",[20,532,533,534,537,538,541,542,544,545,453,547,167,549,54],{},"The table is the conformance matrix in ",[24,535,536],{},"test\u002Fconformance.test.ts",", which runs every row against ",[24,539,540],{},"site.handle"," and against an h3 app. \"Page\" is a page behind ",[24,543,87],{},". \"API route\" calls ",[24,546,98],{},[24,548,411],{},[24,550,94],{},[172,552,553,579],{},[175,554,555],{},[178,556,557,560,564,567,576],{},[181,558,559],{},"Client",[181,561,562],{},[24,563,45],{},[181,565,566],{},"Page",[181,568,569,570,572,573],{},"Page ",[24,571,388],{}," twin or ",[24,574,575],{},"?format=md",[181,577,578],{},"API route",[192,580,581,604,626,649,670,693],{},[178,582,583,586,591,596,600],{},[197,584,585],{},"Claude Code WebFetch",[197,587,588],{},[24,589,590],{},"text\u002Fmarkdown, text\u002Fhtml, *\u002F*",[197,592,593],{},[24,594,595],{},"text\u002Fmarkdown",[197,597,598],{},[24,599,595],{},[197,601,602],{},[24,603,595],{},[178,605,606,609,614,618,622],{},[197,607,608],{},"Cursor",[197,610,611],{},[24,612,613],{},"text\u002Fmarkdown,text\u002Fhtml;q=0.9,application\u002Fxhtml+xml;q=0.8,application\u002Fxml;q=0.7,image\u002Fwebp;q=0.6,*\u002F*;q=0.5",[197,615,616],{},[24,617,595],{},[197,619,620],{},[24,621,595],{},[197,623,624],{},[24,625,595],{},[178,627,628,631,636,641,645],{},[197,629,630],{},"Codex",[197,632,633],{},[24,634,635],{},"text\u002Fhtml,application\u002Fxhtml+xml,application\u002Fxml;q=0.9,*\u002F*;q=0.8",[197,637,638],{},[24,639,640],{},"text\u002Fhtml",[197,642,643],{},[24,644,595],{},[197,646,647],{},[24,648,352],{},[178,650,651,654,658,662,666],{},[197,652,653],{},"curl",[197,655,656],{},[24,657,53],{},[197,659,660],{},[24,661,640],{},[197,663,664],{},[24,665,595],{},[197,667,668],{},[24,669,352],{},[178,671,672,675,679,684,688],{},[197,673,674],{},"Synthetic",[197,676,677],{},[24,678,301],{},[197,680,681,683],{},[24,682,301],{},", Markdown",[197,685,686,683],{},[24,687,301],{},[197,689,690,692],{},[24,691,301],{},", the agent text",[178,694,695,697,701,705,709],{},[197,696,674],{},[197,698,699],{},[24,700,352],{},[197,702,703],{},[24,704,640],{},[197,706,707],{},[24,708,595],{},[197,710,711],{},[24,712,352],{},[714,715,719],"h3",{"id":716,"anchor":717},"where-the-headers-come-from",{"label":718,"icon":34},"Section titled \"Where the headers come from\"","Where the headers come from",[172,721,722,732],{},[175,723,724],{},[178,725,726,729],{},[181,727,728],{},"Header",[181,730,731],{},"Source",[192,733,734,742,749,761,768],{},[178,735,736,739],{},[197,737,738],{},"Claude Code",[197,740,741],{},"Captured by us from Claude Code's WebFetch, 6 December 2026",[178,743,744,746],{},[197,745,653],{},[197,747,748],{},"curl's default, captured by us, 6 December 2026",[178,750,751,753],{},[197,752,630],{},[197,754,755,756,760],{},"From ",[139,757,759],{"href":758},"https:\u002F\u002Fgithub.com\u002FPostHog\u002Fposthog.com\u002Fissues\u002F21381","PostHog\u002Fposthog.com#21381",". Not captured by us",[178,762,763,765],{},[197,764,608],{},[197,766,767],{},"Unverified. A summary of Checkly's February 2026 article. Not captured by us",[178,769,770,773],{},[197,771,772],{},"The two synthetic rows",[197,774,775],{},"No client is known to send them. They exercise the rules",[20,777,778,781],{},[24,779,780],{},"test\u002Fclients.ts"," in the repository lists each header with its source.",[29,783,787],{"id":784,"anchor":785},"codex-and-twin-urls",{"label":786,"icon":34},"Section titled \"Codex and twin URLs\"","Codex and twin URLs",[20,789,790,791,793,794,796,797,54],{},"Codex sends a browser-like ",[24,792,45],{},", so on a page it gets HTML, and on a twin URL it gets ",[24,795,595],{}," through ",[24,798,53],{},[20,800,801,802,804],{},"The README reports that Codex's fetch tool rejects ",[24,803,595],{},". We did not capture that ourselves.",[20,806,807,809,810,812,813,815],{},[24,808,45],{}," alone cannot tell Codex from a browser, and whoasks does not read the User-Agent. A layer that reads the User-Agent sends ",[24,811,301],{}," to it instead. See ",[139,814,142],{"href":141}," for the code.",[29,817,821],{"id":818,"anchor":819},"read-the-pick",{"label":820,"icon":34},"Section titled \"Read the pick\"","Read the pick",[823,824,827],"pre",{"language":825,"class":826,"wrap":14},"ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[24,828,830,857,858,857,864,857,869],{"class":829},"language-ts",[831,832,835,839,843,846,850,854],"span",{"class":833,"style":834},"line","display: inline",[831,836,838],{"style":837},"color:#CF222E;--shiki-dark:#FF7B72","const",[831,840,842],{"style":841},"color:#0550AE;--shiki-dark:#79C0FF"," ask",[831,844,845],{"style":837}," =",[831,847,849],{"style":848},"color:#1F2328;--shiki-dark:#E6EDF3"," site.",[831,851,853],{"style":852},"color:#8250DF;--shiki-dark:#D2A8FF","ask",[831,855,856],{"style":848},"(request);","\n",[831,859,860],{"class":833,"style":834},[831,861,863],{"style":862},"color:#6E7781;--shiki-dark:#8B949E","\u002F\u002F GET \u002Fdocs\u002Fguide.md, Accept: *\u002F*",[831,865,866],{"class":833,"style":834},[831,867,868],{"style":862},"\u002F\u002F { form: \"markdown\", type: \"text\u002Fmarkdown\", reason: \"twin\", acceptable: true,",[831,870,871],{"class":833,"style":834},[831,872,873],{"style":862},"\u002F\u002F   url: URL \"https:\u002F\u002Fexample.com\u002Fdocs\u002Fguide\", vary: [\"Accept\"] }",[20,875,876,878],{},[24,877,853],{}," is synchronous and builds no response.",[20,880,881,882,54],{},"With no second argument, it uses the page offers. Pass the offers of a route to ask for that route: ",[24,883,884],{},"site.ask(request, [\"json\", \"markdown\"])",[172,886,887,899],{},[175,888,889],{},[178,890,891,896],{},[181,892,893],{},[24,894,895],{},"reason",[181,897,898],{},"When",[192,900,901,913,925,937,950],{},[178,902,903,908],{},[197,904,905],{},[24,906,907],{},"twin",[197,909,910,911],{},"The path ended with a form's ",[24,912,381],{},[178,914,915,920],{},[197,916,917],{},[24,918,919],{},"query",[197,921,922,924],{},[24,923,114],{}," named an offered form",[178,926,927,932],{},[197,928,929],{},[24,930,931],{},"accept",[197,933,934,936],{},[24,935,45],{}," named the picked type, or refused the first offer so a later one won",[178,938,939,944],{},[197,940,941],{},[24,942,943],{},"default",[197,945,946,947,949],{},"The pick is the first offer and ",[24,948,45],{}," did not name its type. Also when nothing was acceptable",[178,951,952,957],{},[197,953,954],{},[24,955,956],{},"layer",[197,958,959],{},"A hook changed the form or the type",[961,963,964,965,966,967,968,972,973],{"id":31,"depth":962,"text":35},2,{"id":102,"depth":962,"text":105},{"id":158,"depth":962,"text":161},{"id":370,"depth":962,"text":373},{"id":470,"depth":962,"text":473},{"id":488,"depth":962,"text":151},{"id":527,"depth":962,"text":530,"children":969},[970],{"id":716,"depth":971,"text":719},3,{"id":784,"depth":962,"text":787},{"id":818,"depth":962,"text":821},{"path":975,"title":976,"description":977},"\u002Fguide\u002Fapi-routes","API routes","respond answers one route in the form the request picked, from one value or function per form, with your status and headers.",{"path":979,"title":980,"description":981},"\u002Fguide\u002Flayers","Layers","A layer is a plain object that adds a form, renders a form from your own source, changes the pick or sets the HTML to Markdown converter.",1796579201652,"78c9ee36-381e-45a5-bdf8-02819f0a7eb0"]