[{"data":1,"prerenderedAt":1592},["ShallowReactive",2],{"navigation":3,"/agent-api/authentication":261,"/agent-api/authentication-surround":1587},[4,22,50,83,125,161,194,205,231],{"title":5,"path":6,"stem":7,"children":8,"icon":16},"Getting Started","/getting-started","1.getting-started/1.index",[9,12,17],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-ph-house",{"title":13,"path":14,"stem":15,"icon":16},"Quickstart","/getting-started/quickstart","1.getting-started/2.quickstart","i-ph-rocket",{"title":18,"path":19,"stem":20,"icon":21},"Plans","/getting-started/plans","1.getting-started/3.plans","i-ph-credit-card",{"title":23,"path":24,"stem":25,"children":26,"icon":29},"Agents","/agents","2.agents/1.index",[27,30,35,40,45],{"title":28,"path":24,"stem":25,"icon":29},"Overview","i-ph-robot",{"title":31,"path":32,"stem":33,"icon":34},"Creating an agent","/agents/creating-an-agent","2.agents/2.creating-an-agent","i-ph-plus",{"title":36,"path":37,"stem":38,"icon":39},"Agent settings","/agents/settings","2.agents/3.settings","i-ph-gear",{"title":41,"path":42,"stem":43,"icon":44},"Memory","/agents/memory","2.agents/4.memory","i-ph-database",{"title":46,"path":47,"stem":48,"icon":49},"Residential proxy","/agents/proxy","2.agents/5.proxy","i-ph-globe-hemisphere-west",{"title":51,"path":52,"stem":53,"children":54,"icon":57},"Chats & Tasks","/chats-and-tasks","3.chats-and-tasks/1.index",[55,58,63,68,73,78],{"title":56,"path":52,"stem":53,"icon":57},"Chats","i-ph-chats-circle",{"title":59,"path":60,"stem":61,"icon":62},"Sharing chats","/chats-and-tasks/sharing-chats","3.chats-and-tasks/2.sharing-chats","i-ph-share-network",{"title":64,"path":65,"stem":66,"icon":67},"Tasks","/chats-and-tasks/tasks","3.chats-and-tasks/3.tasks","i-ph-list-checks",{"title":69,"path":70,"stem":71,"icon":72},"Recurring tasks","/chats-and-tasks/recurring-tasks","3.chats-and-tasks/4.recurring-tasks","i-ph-repeat",{"title":74,"path":75,"stem":76,"icon":77},"Results & deliverables","/chats-and-tasks/results-and-deliverables","3.chats-and-tasks/5.results-and-deliverables","i-ph-package",{"title":79,"path":80,"stem":81,"icon":82},"Save a chat as a skill","/chats-and-tasks/save-chat-as-skill","3.chats-and-tasks/6.save-chat-as-skill","i-ph-sparkle",{"title":84,"path":85,"stem":86,"children":87,"icon":90},"Models & Skills","/models-and-skills","4.models-and-skills/1.index",[88,91,96,101,105,110,115,120],{"title":89,"path":85,"stem":86,"icon":90},"LLM configuration","i-ph-cpu",{"title":92,"path":93,"stem":94,"icon":95},"Providers & models","/models-and-skills/providers","4.models-and-skills/2.providers","i-ph-stack",{"title":97,"path":98,"stem":99,"icon":100},"Bring your own key","/models-and-skills/byok","4.models-and-skills/3.byok","i-ph-key",{"title":102,"path":103,"stem":104,"icon":29},"ChatGPT subscription","/models-and-skills/chatgpt-subscription","4.models-and-skills/4.chatgpt-subscription",{"title":106,"path":107,"stem":108,"icon":109},"Skills","/models-and-skills/skills","4.models-and-skills/5.skills","i-ph-puzzle-piece",{"title":111,"path":112,"stem":113,"icon":114},"Installing skills","/models-and-skills/installing-skills","4.models-and-skills/6.installing-skills","i-ph-download-simple",{"title":116,"path":117,"stem":118,"icon":119},"Custom skills","/models-and-skills/custom-skills","4.models-and-skills/7.custom-skills","i-ph-code",{"title":121,"path":122,"stem":123,"icon":124},"Local models","/models-and-skills/local-models","4.models-and-skills/8.local-models","i-ph-desktop-tower",{"title":126,"path":127,"stem":128,"children":129,"icon":131},"Connect Your Tools","/connect-your-tools","5.connect-your-tools/1.index",[130,132,137,142,147,152,156],{"title":28,"path":127,"stem":128,"icon":131},"i-ph-plug",{"title":133,"path":134,"stem":135,"icon":136},"Telegram","/connect-your-tools/telegram","5.connect-your-tools/2.telegram","i-ph-telegram-logo",{"title":138,"path":139,"stem":140,"icon":141},"Discord","/connect-your-tools/discord","5.connect-your-tools/3.discord","i-ph-discord-logo",{"title":143,"path":144,"stem":145,"icon":146},"Slack","/connect-your-tools/slack","5.connect-your-tools/4.slack","i-ph-slack-logo",{"title":148,"path":149,"stem":150,"icon":151},"Connectors","/connect-your-tools/connectors","5.connect-your-tools/5.connectors","i-ph-link",{"title":153,"path":154,"stem":155,"icon":100},"Secrets","/connect-your-tools/secrets","5.connect-your-tools/6.secrets",{"title":157,"path":158,"stem":159,"icon":160},"Audit log","/connect-your-tools/secret-audit-log","5.connect-your-tools/7.secret-audit-log","i-ph-scroll",{"title":162,"path":163,"stem":164,"children":165,"icon":193},"Account & Team","/account-and-team","6.account-and-team/1.index",[166,169,174,179,184,188],{"title":167,"path":163,"stem":164,"icon":168},"Signing in","i-ph-sign-in",{"title":170,"path":171,"stem":172,"icon":173},"Team members","/account-and-team/teams","6.account-and-team/3.teams","i-ph-users",{"title":175,"path":176,"stem":177,"icon":178},"Roles & permissions","/account-and-team/roles-and-permissions","6.account-and-team/4.roles-and-permissions","i-ph-shield",{"title":180,"path":181,"stem":182,"icon":183},"Invitations","/account-and-team/invitations","6.account-and-team/5.invitations","i-ph-envelope-simple",{"title":185,"path":186,"stem":187,"icon":21},"Billing & upgrades","/account-and-team/billing","6.account-and-team/6.billing",{"title":189,"path":190,"stem":191,"icon":192},"Support","/account-and-team/support","6.account-and-team/7.support","i-ph-lifebuoy","i-ph-user",{"title":195,"path":196,"stem":197,"children":198,"icon":200},"Apps","/apps","7.apps/1.index",[199,201],{"title":195,"path":196,"stem":197,"icon":200},"i-ph-squares-four",{"title":202,"path":203,"stem":204,"icon":119},"Building an app","/apps/building-an-app","7.apps/2.building-an-app",{"title":206,"path":207,"stem":208,"children":209,"icon":211},"Workflows","/workflows","8.workflows/1.index",[210,212,216,221,226],{"title":28,"path":207,"stem":208,"icon":211},"i-ph-flow-arrow",{"title":213,"path":214,"stem":215,"icon":82},"Create a workflow","/workflows/creating-a-workflow","8.workflows/2.creating-a-workflow",{"title":217,"path":218,"stem":219,"icon":220},"Edit sections","/workflows/editing-sections","8.workflows/3.editing-sections","i-ph-pencil-simple",{"title":222,"path":223,"stem":224,"icon":225},"Run and schedule","/workflows/running-and-scheduling","8.workflows/4.running-and-scheduling","i-ph-clock",{"title":227,"path":228,"stem":229,"icon":230},"Workflow directory","/workflows/directory","8.workflows/5.directory","i-ph-compass",{"title":232,"path":233,"stem":234,"children":235,"icon":119},"Agent API","/agent-api","9.agent-api/1.index",[236,237,241,246,251,256],{"title":28,"path":233,"stem":234,"icon":119},{"title":13,"path":238,"stem":239,"icon":240},"/agent-api/quickstart","9.agent-api/2.quickstart","i-ph-rocket-launch",{"title":242,"path":243,"stem":244,"icon":245},"Authentication","/agent-api/authentication","9.agent-api/3.authentication","i-ph-lock-key",{"title":247,"path":248,"stem":249,"icon":250},"Endpoints","/agent-api/endpoints","9.agent-api/4.endpoints","i-ph-list-bullets",{"title":252,"path":253,"stem":254,"icon":255},"Streaming","/agent-api/streaming","9.agent-api/5.streaming","i-ph-broadcast",{"title":257,"path":258,"stem":259,"icon":260},"Errors","/agent-api/errors","9.agent-api/6.errors","i-ph-warning-circle",{"id":262,"title":242,"body":263,"description":1580,"extension":1581,"links":1582,"meta":1583,"navigation":1584,"path":243,"seo":1585,"stem":244,"__hash__":1586},"docs/9.agent-api/3.authentication.md",{"type":264,"value":265,"toc":1569},"minimark",[266,270,292,297,304,346,448,451,486,492,496,502,529,534,596,667,674,841,856,860,870,1236,1395,1419,1425,1429,1444,1486,1490,1504,1508,1511,1549,1553,1562,1565],[267,268,242],"h1",{"id":269},"authentication",[271,272,273,274,278,279,283,284,287,288,291],"p",{},"The Agent API accepts two credentials: the ",[275,276,277],"strong",{},"API key"," you generate in the app (",[280,281,282],"code",{},"bc_sk_…","), and a\nshort-lived ",[275,285,286],{},"session token"," (",[280,289,290],{},"bcs_…",") that your server mints from that key. Both are sent as a\nbearer token.",[293,294,296],"h2",{"id":295},"sending-an-api-key","Sending an API key",[271,298,299,300,303],{},"Send the key in the ",[280,301,302],{},"Authorization"," header on every request:",[305,306,311],"pre",{"className":307,"code":308,"language":309,"meta":310,"style":310},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl https://api.betterclaw.io/workspaces \\\n  -H \"Authorization: Bearer bc_sk_…\"\n","bash","",[280,312,313,330],{"__ignoreMap":310},[314,315,318,322,326],"span",{"class":316,"line":317},"line",1,[314,319,321],{"class":320},"sBMFI","curl",[314,323,325],{"class":324},"sfazB"," https://api.betterclaw.io/workspaces",[314,327,329],{"class":328},"sTEyZ"," \\\n",[314,331,333,336,340,343],{"class":316,"line":332},2,[314,334,335],{"class":324},"  -H",[314,337,339],{"class":338},"sMK4o"," \"",[314,341,342],{"class":324},"Authorization: Bearer bc_sk_…",[314,344,345],{"class":338},"\"\n",[305,347,351],{"className":348,"code":349,"language":350,"meta":310,"style":310},"language-js shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const res = await fetch('https://api.betterclaw.io/workspaces', {\n  headers: { Authorization: `Bearer ${process.env.BETTERCLAW_API_KEY}` },\n});\n","js",[280,352,353,390,436],{"__ignoreMap":310},[314,354,355,359,362,365,369,373,376,379,382,384,387],{"class":316,"line":317},[314,356,358],{"class":357},"spNyl","const",[314,360,361],{"class":328}," res ",[314,363,364],{"class":338},"=",[314,366,368],{"class":367},"s7zQu"," await",[314,370,372],{"class":371},"s2Zo4"," fetch",[314,374,375],{"class":328},"(",[314,377,378],{"class":338},"'",[314,380,381],{"class":324},"https://api.betterclaw.io/workspaces",[314,383,378],{"class":338},[314,385,386],{"class":338},",",[314,388,389],{"class":338}," {\n",[314,391,392,396,399,402,405,407,410,413,416,419,422,425,427,430,433],{"class":316,"line":332},[314,393,395],{"class":394},"swJcz","  headers",[314,397,398],{"class":338},":",[314,400,401],{"class":338}," {",[314,403,404],{"class":394}," Authorization",[314,406,398],{"class":338},[314,408,409],{"class":338}," `",[314,411,412],{"class":324},"Bearer ",[314,414,415],{"class":338},"${",[314,417,418],{"class":328},"process",[314,420,421],{"class":338},".",[314,423,424],{"class":328},"env",[314,426,421],{"class":338},[314,428,429],{"class":328},"BETTERCLAW_API_KEY",[314,431,432],{"class":338},"}`",[314,434,435],{"class":338}," },\n",[314,437,439,442,445],{"class":316,"line":438},3,[314,440,441],{"class":338},"}",[314,443,444],{"class":328},")",[314,446,447],{"class":338},";\n",[271,449,450],{},"The API enforces two rules for raw keys, because a leaked key works until someone revokes it:",[452,453,454,469],"ul",{},[455,456,457,460,461,464,465,468],"li",{},[275,458,459],{},"Header only."," A key in a query string (",[280,462,463],{},"?token=bc_sk_…",") is rejected with ",[280,466,467],{},"401",". URLs end up\nin server logs, proxy logs, and browser history.",[455,470,471,474,475,478,479,482,483,485],{},[275,472,473],{},"Server only."," A key on a request that carries an ",[280,476,477],{},"Origin"," header, which browsers add to\ncross-origin requests, is rejected with ",[280,480,481],{},"403",". If a server-side HTTP client you use adds\n",[280,484,477],{}," on its own, remove the header.",[487,488,489],"tip",{},[271,490,491],{},"Store the key the way you store any production secret: in an environment variable or secrets\nmanager, never in source control.",[293,493,495],{"id":494},"session-tokens","Session tokens",[271,497,498,499,501],{},"A browser, mobile app, or anything else you don't control should never hold an API key. Instead,\nyour server exchanges the key for a ",[275,500,286],{}," and passes that to the client. A session\ntoken:",[452,503,504,515,518],{},[455,505,506,507,510,511,514],{},"expires after ",[275,508,509],{},"10 minutes"," by default (at most ",[275,512,513],{},"15","),",[455,516,517],{},"can be narrowed to fewer permissions than the key has,",[455,519,520,521,524,525,421],{},"may be sent from a browser, and in a query string (",[280,522,523],{},"?token=bcs_…","), which is how browsers\nauthenticate a ",[526,527,528],"a",{"href":253},"WebSocket",[530,531,533],"h3",{"id":532},"exchange-a-key-for-a-token","Exchange a key for a token",[305,535,537],{"className":307,"code":536,"language":309,"meta":310,"style":310},"curl -s https://api.betterclaw.io/auth/sdk-token \\\n  -H \"Authorization: Bearer $BETTERCLAW_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"ttlSeconds\": 600, \"scopes\": [\"chats:read\", \"chats:write\"]}'\n",[280,538,539,551,568,581],{"__ignoreMap":310},[314,540,541,543,546,549],{"class":316,"line":317},[314,542,321],{"class":320},[314,544,545],{"class":324}," -s",[314,547,548],{"class":324}," https://api.betterclaw.io/auth/sdk-token",[314,550,329],{"class":328},[314,552,553,555,557,560,563,566],{"class":316,"line":332},[314,554,335],{"class":324},[314,556,339],{"class":338},[314,558,559],{"class":324},"Authorization: Bearer ",[314,561,562],{"class":328},"$BETTERCLAW_API_KEY",[314,564,565],{"class":338},"\"",[314,567,329],{"class":328},[314,569,570,572,574,577,579],{"class":316,"line":438},[314,571,335],{"class":324},[314,573,339],{"class":338},[314,575,576],{"class":324},"Content-Type: application/json",[314,578,565],{"class":338},[314,580,329],{"class":328},[314,582,584,587,590,593],{"class":316,"line":583},4,[314,585,586],{"class":324},"  -d",[314,588,589],{"class":338}," '",[314,591,592],{"class":324},"{\"ttlSeconds\": 600, \"scopes\": [\"chats:read\", \"chats:write\"]}",[314,594,595],{"class":338},"'\n",[597,598,599,618],"table",{},[600,601,602],"thead",{},[603,604,605,609,612,615],"tr",{},[606,607,608],"th",{},"Field",[606,610,611],{},"Type",[606,613,614],{},"Required",[606,616,617],{},"Description",[619,620,621,650],"tbody",{},[603,622,623,629,632,635],{},[624,625,626],"td",{},[280,627,628],{},"ttlSeconds",[624,630,631],{},"integer",[624,633,634],{},"No",[624,636,637,638,641,642,645,646,649],{},"Lifetime in seconds, from ",[280,639,640],{},"60"," to ",[280,643,644],{},"900",". Defaults to ",[280,647,648],{},"600",". Values outside the range are rejected, not clamped.",[603,651,652,657,662,664],{},[624,653,654],{},[280,655,656],{},"scopes",[624,658,659,660],{},"string",[314,661],{},[624,663,634],{},[624,665,666],{},"Permissions for the token. Defaults to all of the key's permissions. Can only narrow them.",[271,668,669,670,673],{},"Response (",[280,671,672],{},"201","):",[305,675,679],{"className":676,"code":677,"language":678,"meta":310,"style":310},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"token\": \"bcs_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…\",\n  \"expiresIn\": 600,\n  \"expiresAt\": \"2026-10-08T10:25:00.000Z\",\n  \"workspaceId\": \"6f1c2d4e-8a90-4b1c-9d2e-3f4a5b6c7d8e\",\n  \"userId\": \"2d3e4f5a-6b7c-4d8e-9f0a-1b2c3d4e5f6a\",\n  \"agentId\": null,\n  \"scopes\": [\"chats:read\", \"chats:write\"]\n}\n","json",[280,680,681,686,708,725,745,766,787,802,835],{"__ignoreMap":310},[314,682,683],{"class":316,"line":317},[314,684,685],{"class":338},"{\n",[314,687,688,691,694,696,698,700,703,705],{"class":316,"line":332},[314,689,690],{"class":338},"  \"",[314,692,693],{"class":357},"token",[314,695,565],{"class":338},[314,697,398],{"class":338},[314,699,339],{"class":338},[314,701,702],{"class":324},"bcs_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",[314,704,565],{"class":338},[314,706,707],{"class":338},",\n",[314,709,710,712,715,717,719,723],{"class":316,"line":438},[314,711,690],{"class":338},[314,713,714],{"class":357},"expiresIn",[314,716,565],{"class":338},[314,718,398],{"class":338},[314,720,722],{"class":721},"sbssI"," 600",[314,724,707],{"class":338},[314,726,727,729,732,734,736,738,741,743],{"class":316,"line":583},[314,728,690],{"class":338},[314,730,731],{"class":357},"expiresAt",[314,733,565],{"class":338},[314,735,398],{"class":338},[314,737,339],{"class":338},[314,739,740],{"class":324},"2026-10-08T10:25:00.000Z",[314,742,565],{"class":338},[314,744,707],{"class":338},[314,746,748,750,753,755,757,759,762,764],{"class":316,"line":747},5,[314,749,690],{"class":338},[314,751,752],{"class":357},"workspaceId",[314,754,565],{"class":338},[314,756,398],{"class":338},[314,758,339],{"class":338},[314,760,761],{"class":324},"6f1c2d4e-8a90-4b1c-9d2e-3f4a5b6c7d8e",[314,763,565],{"class":338},[314,765,707],{"class":338},[314,767,769,771,774,776,778,780,783,785],{"class":316,"line":768},6,[314,770,690],{"class":338},[314,772,773],{"class":357},"userId",[314,775,565],{"class":338},[314,777,398],{"class":338},[314,779,339],{"class":338},[314,781,782],{"class":324},"2d3e4f5a-6b7c-4d8e-9f0a-1b2c3d4e5f6a",[314,784,565],{"class":338},[314,786,707],{"class":338},[314,788,790,792,795,797,799],{"class":316,"line":789},7,[314,791,690],{"class":338},[314,793,794],{"class":357},"agentId",[314,796,565],{"class":338},[314,798,398],{"class":338},[314,800,801],{"class":338}," null,\n",[314,803,805,807,809,811,813,816,818,821,823,825,827,830,832],{"class":316,"line":804},8,[314,806,690],{"class":338},[314,808,656],{"class":357},[314,810,565],{"class":338},[314,812,398],{"class":338},[314,814,815],{"class":338}," [",[314,817,565],{"class":338},[314,819,820],{"class":324},"chats:read",[314,822,565],{"class":338},[314,824,386],{"class":338},[314,826,339],{"class":338},[314,828,829],{"class":324},"chats:write",[314,831,565],{"class":338},[314,833,834],{"class":338},"]\n",[314,836,838],{"class":316,"line":837},9,[314,839,840],{"class":338},"}\n",[271,842,843,845,846,849,850,853,854,421],{},[280,844,794],{}," is the agent the key is pinned to, or ",[280,847,848],{},"null"," for ",[275,851,852],{},"Any agent",". Asking for a permission\nthe key doesn't have returns ",[280,855,481],{},[530,857,859],{"id":858},"hand-tokens-to-a-browser","Hand tokens to a browser",[271,861,862,863,867,868,421],{},"Add an endpoint to your own backend that checks ",[864,865,866],"em",{},"your"," user is signed in, mints a token, and\nreturns it. The browser calls the Agent API with that token and asks your endpoint for a new one\nbefore ",[280,869,731],{},[305,871,873],{"className":348,"code":872,"language":350,"meta":310,"style":310},"// Your server (Express). The API key never leaves it.\napp.post('/betterclaw-token', requireSignedInUser, async (req, res) => {\n  const r = await fetch('https://api.betterclaw.io/auth/sdk-token', {\n    method: 'POST',\n    headers: {\n      Authorization: `Bearer ${process.env.BETTERCLAW_API_KEY}`,\n      'Content-Type': 'application/json',\n    },\n    body: JSON.stringify({ scopes: ['chats:read', 'chats:write'] }),\n  });\n  if (!r.ok) return res.status(502).json({ error: 'Could not get a BetterClaw token' });\n  const { token, expiresAt, workspaceId } = await r.json();\n  res.json({ token, expiresAt, workspaceId });\n});\n",[280,874,875,881,928,956,972,981,1008,1029,1034,1084,1094,1160,1197,1227],{"__ignoreMap":310},[314,876,877],{"class":316,"line":317},[314,878,880],{"class":879},"sHwdD","// Your server (Express). The API key never leaves it.\n",[314,882,883,886,888,891,893,895,898,900,902,905,907,910,912,916,918,921,923,926],{"class":316,"line":332},[314,884,885],{"class":328},"app",[314,887,421],{"class":338},[314,889,890],{"class":371},"post",[314,892,375],{"class":328},[314,894,378],{"class":338},[314,896,897],{"class":324},"/betterclaw-token",[314,899,378],{"class":338},[314,901,386],{"class":338},[314,903,904],{"class":328}," requireSignedInUser",[314,906,386],{"class":338},[314,908,909],{"class":357}," async",[314,911,287],{"class":338},[314,913,915],{"class":914},"sHdIc","req",[314,917,386],{"class":338},[314,919,920],{"class":914}," res",[314,922,444],{"class":338},[314,924,925],{"class":357}," =>",[314,927,389],{"class":338},[314,929,930,933,936,939,941,943,945,947,950,952,954],{"class":316,"line":438},[314,931,932],{"class":357},"  const",[314,934,935],{"class":328}," r",[314,937,938],{"class":338}," =",[314,940,368],{"class":367},[314,942,372],{"class":371},[314,944,375],{"class":394},[314,946,378],{"class":338},[314,948,949],{"class":324},"https://api.betterclaw.io/auth/sdk-token",[314,951,378],{"class":338},[314,953,386],{"class":338},[314,955,389],{"class":338},[314,957,958,961,963,965,968,970],{"class":316,"line":583},[314,959,960],{"class":394},"    method",[314,962,398],{"class":338},[314,964,589],{"class":338},[314,966,967],{"class":324},"POST",[314,969,378],{"class":338},[314,971,707],{"class":338},[314,973,974,977,979],{"class":316,"line":747},[314,975,976],{"class":394},"    headers",[314,978,398],{"class":338},[314,980,389],{"class":338},[314,982,983,986,988,990,992,994,996,998,1000,1002,1004,1006],{"class":316,"line":768},[314,984,985],{"class":394},"      Authorization",[314,987,398],{"class":338},[314,989,409],{"class":338},[314,991,412],{"class":324},[314,993,415],{"class":338},[314,995,418],{"class":328},[314,997,421],{"class":338},[314,999,424],{"class":328},[314,1001,421],{"class":338},[314,1003,429],{"class":328},[314,1005,432],{"class":338},[314,1007,707],{"class":338},[314,1009,1010,1013,1016,1018,1020,1022,1025,1027],{"class":316,"line":789},[314,1011,1012],{"class":338},"      '",[314,1014,1015],{"class":394},"Content-Type",[314,1017,378],{"class":338},[314,1019,398],{"class":338},[314,1021,589],{"class":338},[314,1023,1024],{"class":324},"application/json",[314,1026,378],{"class":338},[314,1028,707],{"class":338},[314,1030,1031],{"class":316,"line":804},[314,1032,1033],{"class":338},"    },\n",[314,1035,1036,1039,1041,1044,1046,1049,1051,1054,1057,1059,1061,1063,1065,1067,1069,1071,1073,1075,1078,1080,1082],{"class":316,"line":837},[314,1037,1038],{"class":394},"    body",[314,1040,398],{"class":338},[314,1042,1043],{"class":328}," JSON",[314,1045,421],{"class":338},[314,1047,1048],{"class":371},"stringify",[314,1050,375],{"class":394},[314,1052,1053],{"class":338},"{",[314,1055,1056],{"class":394}," scopes",[314,1058,398],{"class":338},[314,1060,815],{"class":394},[314,1062,378],{"class":338},[314,1064,820],{"class":324},[314,1066,378],{"class":338},[314,1068,386],{"class":338},[314,1070,589],{"class":338},[314,1072,829],{"class":324},[314,1074,378],{"class":338},[314,1076,1077],{"class":394},"] ",[314,1079,441],{"class":338},[314,1081,444],{"class":394},[314,1083,707],{"class":338},[314,1085,1087,1090,1092],{"class":316,"line":1086},10,[314,1088,1089],{"class":338},"  }",[314,1091,444],{"class":394},[314,1093,447],{"class":338},[314,1095,1097,1100,1102,1105,1108,1110,1113,1116,1119,1121,1123,1126,1128,1131,1133,1135,1137,1139,1141,1144,1146,1148,1151,1153,1156,1158],{"class":316,"line":1096},11,[314,1098,1099],{"class":367},"  if",[314,1101,287],{"class":394},[314,1103,1104],{"class":338},"!",[314,1106,1107],{"class":328},"r",[314,1109,421],{"class":338},[314,1111,1112],{"class":328},"ok",[314,1114,1115],{"class":394},") ",[314,1117,1118],{"class":367},"return",[314,1120,920],{"class":328},[314,1122,421],{"class":338},[314,1124,1125],{"class":371},"status",[314,1127,375],{"class":394},[314,1129,1130],{"class":721},"502",[314,1132,444],{"class":394},[314,1134,421],{"class":338},[314,1136,678],{"class":371},[314,1138,375],{"class":394},[314,1140,1053],{"class":338},[314,1142,1143],{"class":394}," error",[314,1145,398],{"class":338},[314,1147,589],{"class":338},[314,1149,1150],{"class":324},"Could not get a BetterClaw token",[314,1152,378],{"class":338},[314,1154,1155],{"class":338}," }",[314,1157,444],{"class":394},[314,1159,447],{"class":338},[314,1161,1163,1165,1167,1170,1172,1175,1177,1180,1182,1184,1186,1188,1190,1192,1195],{"class":316,"line":1162},12,[314,1164,932],{"class":357},[314,1166,401],{"class":338},[314,1168,1169],{"class":328}," token",[314,1171,386],{"class":338},[314,1173,1174],{"class":328}," expiresAt",[314,1176,386],{"class":338},[314,1178,1179],{"class":328}," workspaceId",[314,1181,1155],{"class":338},[314,1183,938],{"class":338},[314,1185,368],{"class":367},[314,1187,935],{"class":328},[314,1189,421],{"class":338},[314,1191,678],{"class":371},[314,1193,1194],{"class":394},"()",[314,1196,447],{"class":338},[314,1198,1200,1203,1205,1207,1209,1211,1213,1215,1217,1219,1221,1223,1225],{"class":316,"line":1199},13,[314,1201,1202],{"class":328},"  res",[314,1204,421],{"class":338},[314,1206,678],{"class":371},[314,1208,375],{"class":394},[314,1210,1053],{"class":338},[314,1212,1169],{"class":328},[314,1214,386],{"class":338},[314,1216,1174],{"class":328},[314,1218,386],{"class":338},[314,1220,1179],{"class":328},[314,1222,1155],{"class":338},[314,1224,444],{"class":394},[314,1226,447],{"class":338},[314,1228,1230,1232,1234],{"class":316,"line":1229},14,[314,1231,441],{"class":338},[314,1233,444],{"class":328},[314,1235,447],{"class":338},[305,1237,1239],{"className":348,"code":1238,"language":350,"meta":310,"style":310},"// The browser.\nconst { token, workspaceId } = await (await fetch('/betterclaw-token', { method: 'POST' })).json();\nconst chats = await fetch(`https://api.betterclaw.io/chats?workspaceId=${workspaceId}`, {\n  headers: { Authorization: `Bearer ${token}` },\n}).then((r) => r.json());\n",[280,1240,1241,1246,1308,1339,1363],{"__ignoreMap":310},[314,1242,1243],{"class":316,"line":317},[314,1244,1245],{"class":879},"// The browser.\n",[314,1247,1248,1250,1252,1254,1256,1259,1261,1263,1265,1267,1270,1272,1274,1276,1278,1280,1282,1284,1287,1289,1291,1293,1295,1297,1300,1302,1304,1306],{"class":316,"line":332},[314,1249,358],{"class":357},[314,1251,401],{"class":338},[314,1253,1169],{"class":328},[314,1255,386],{"class":338},[314,1257,1258],{"class":328}," workspaceId ",[314,1260,441],{"class":338},[314,1262,938],{"class":338},[314,1264,368],{"class":367},[314,1266,287],{"class":328},[314,1268,1269],{"class":367},"await",[314,1271,372],{"class":371},[314,1273,375],{"class":328},[314,1275,378],{"class":338},[314,1277,897],{"class":324},[314,1279,378],{"class":338},[314,1281,386],{"class":338},[314,1283,401],{"class":338},[314,1285,1286],{"class":394}," method",[314,1288,398],{"class":338},[314,1290,589],{"class":338},[314,1292,967],{"class":324},[314,1294,378],{"class":338},[314,1296,1155],{"class":338},[314,1298,1299],{"class":328},"))",[314,1301,421],{"class":338},[314,1303,678],{"class":371},[314,1305,1194],{"class":328},[314,1307,447],{"class":338},[314,1309,1310,1312,1315,1317,1319,1321,1323,1326,1329,1331,1333,1335,1337],{"class":316,"line":438},[314,1311,358],{"class":357},[314,1313,1314],{"class":328}," chats ",[314,1316,364],{"class":338},[314,1318,368],{"class":367},[314,1320,372],{"class":371},[314,1322,375],{"class":328},[314,1324,1325],{"class":338},"`",[314,1327,1328],{"class":324},"https://api.betterclaw.io/chats?workspaceId=",[314,1330,415],{"class":338},[314,1332,752],{"class":328},[314,1334,432],{"class":338},[314,1336,386],{"class":338},[314,1338,389],{"class":338},[314,1340,1341,1343,1345,1347,1349,1351,1353,1355,1357,1359,1361],{"class":316,"line":583},[314,1342,395],{"class":394},[314,1344,398],{"class":338},[314,1346,401],{"class":338},[314,1348,404],{"class":394},[314,1350,398],{"class":338},[314,1352,409],{"class":338},[314,1354,412],{"class":324},[314,1356,415],{"class":338},[314,1358,693],{"class":328},[314,1360,432],{"class":338},[314,1362,435],{"class":338},[314,1364,1365,1367,1369,1371,1374,1376,1378,1380,1382,1384,1386,1388,1390,1393],{"class":316,"line":747},[314,1366,441],{"class":338},[314,1368,444],{"class":328},[314,1370,421],{"class":338},[314,1372,1373],{"class":371},"then",[314,1375,375],{"class":328},[314,1377,375],{"class":338},[314,1379,1107],{"class":914},[314,1381,444],{"class":338},[314,1383,925],{"class":357},[314,1385,935],{"class":328},[314,1387,421],{"class":338},[314,1389,678],{"class":371},[314,1391,1392],{"class":328},"())",[314,1394,447],{"class":338},[487,1396,1397],{},[271,1398,1399,1400,1406,1407,1410,1411,1414,1415,1418],{},"The ",[526,1401,1405],{"href":1402,"rel":1403},"https://github.com/better-claw/sdk-js",[1404],"nofollow","JavaScript SDK"," handles both halves: ",[280,1408,1409],{},"mintSessionToken","\nfrom ",[280,1412,1413],{},"@better-claw/sdk/server"," on your backend, and ",[280,1416,1417],{},"SessionTokenAuth"," in the browser, which\nfetches a new token from your endpoint when the current one is about to expire.",[1420,1421,1422],"note",{},[271,1423,1424],{},"Anyone holding a session token can act as the key until the token expires, so only give tokens\nto users you would let use the agent yourself, and keep the lifetime short.",[530,1426,1428],{"id":1427},"failed-exchanges-are-rate-limited","Failed exchanges are rate-limited",[271,1430,1431,1432,1435,1436,1439,1440,1443],{},"After ",[275,1433,1434],{},"10 failed"," exchanges from the same IP address within a minute, ",[280,1437,1438],{},"POST /auth/sdk-token","\nanswers ",[280,1441,1442],{},"429"," until the window passes. Successful exchanges are never limited. The body says how\nlong to wait:",[305,1445,1447],{"className":676,"code":1446,"language":678,"meta":310,"style":310},"{ \"message\": \"Too many failed attempts — try again shortly\", \"retryAfter\": 42 }\n",[280,1448,1449],{"__ignoreMap":310},[314,1450,1451,1453,1455,1458,1460,1462,1464,1467,1469,1471,1473,1476,1478,1480,1483],{"class":316,"line":317},[314,1452,1053],{"class":338},[314,1454,339],{"class":338},[314,1456,1457],{"class":357},"message",[314,1459,565],{"class":338},[314,1461,398],{"class":338},[314,1463,339],{"class":338},[314,1465,1466],{"class":324},"Too many failed attempts — try again shortly",[314,1468,565],{"class":338},[314,1470,386],{"class":338},[314,1472,339],{"class":338},[314,1474,1475],{"class":357},"retryAfter",[314,1477,565],{"class":338},[314,1479,398],{"class":338},[314,1481,1482],{"class":721}," 42",[314,1484,1485],{"class":338}," }\n",[293,1487,1489],{"id":1488},"who-a-key-acts-as","Who a key acts as",[271,1491,1492,1493,1496,1497,1500,1501,1503],{},"A key acts as the workspace admin who generated it. Everything it does is attributed to that\nperson: chats it starts are theirs, and they're visible to the rest of the workspace like any other\nchat. The key keeps working if that person is later changed to a member, but stops working the\nmoment they leave the workspace. The ",[275,1494,1495],{},"API keys"," tab then marks it ",[275,1498,1499],{},"Not working",", and requests\nfail with ",[280,1502,467],{},". Revoke it and generate a replacement from an admin who is staying.",[293,1505,1507],{"id":1506},"pinning-a-key-to-an-agent","Pinning a key to an agent",[271,1509,1510],{},"When you generate a key you can pin it to one agent. A pinned key:",[452,1512,1513,1519,1528,1534,1544],{},[455,1514,1515,1516,386],{},"sees only that agent in ",[280,1517,1518],{},"GET /workspaces/{workspaceId}/agents",[455,1520,1521,1522,1524,1525,1527],{},"gets ",[280,1523,481],{}," if a request names a different agent (for example ",[280,1526,794],{}," when creating a chat),",[455,1529,1521,1530,1533],{},[280,1531,1532],{},"404"," when opening, messaging, or downloading from a chat that belongs to another agent,",[455,1535,1536,1537,1540,1541,386],{},"sees only that agent's chats in ",[280,1538,1539],{},"GET /chats"," and on the live ",[526,1542,1543],{"href":253},"stream",[455,1545,1546,1547,421],{},"always starts chats with the pinned agent when you leave out ",[280,1548,794],{},[293,1550,1552],{"id":1551},"revoking-a-key","Revoking a key",[271,1554,1555,1556,1558,1559,1561],{},"Revoke a key from the ",[275,1557,1495],{}," tab of the ",[275,1560,23],{}," page. It stops working on its next request — there is no\ncache to wait out. Session tokens minted from it stop working at the same moment, and any open\nstream that used it is closed within about half a minute.",[271,1563,1564],{},"Each key shows when it was last used (updated at most once a minute), which helps you spot keys\nthat are safe to revoke.",[1566,1567,1568],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}",{"title":310,"searchDepth":317,"depth":332,"links":1570},[1571,1572,1577,1578,1579],{"id":295,"depth":332,"text":296},{"id":494,"depth":332,"text":495,"children":1573},[1574,1575,1576],{"id":532,"depth":438,"text":533},{"id":858,"depth":438,"text":859},{"id":1427,"depth":438,"text":1428},{"id":1488,"depth":332,"text":1489},{"id":1506,"depth":332,"text":1507},{"id":1551,"depth":332,"text":1552},"API keys, short-lived session tokens for browsers, agent pinning, and revocation.","md",null,{},{"icon":245},{"title":242,"description":1580},"L9cXVjuJZnw_JqUxDrGrXLPDy3khIQHg6slGpsuF1JY",[1588,1590],{"title":13,"path":238,"stem":239,"description":1589,"icon":240,"children":-1},"Generate a key, start a chat, send a message, and read your agent's reply.",{"title":247,"path":248,"stem":249,"description":1591,"icon":250,"children":-1},"Every Agent API request, its permission, parameters, and response.",1791467821221]