[{"data":1,"prerenderedAt":391},["ShallowReactive",2],{"academy-step:en:website-server-relay:2026-08-12:choose-javascript-sdk":3},{"outline":4,"page":46},[5,22],{"chapterId":6,"title":7,"steps":8},"server-relay-contract","Understand the contract",[9],{"stepId":10,"ref":11,"pageRef":14,"route":18,"title":19,"description":20,"durationMinutes":21},"understand-api-v2",{"courseId":12,"revisionId":13,"stepId":10},"website-server-relay","2026-08-12",{"spaceId":15,"versionId":16,"docId":17},"api","v2","api-overview","\u002Fen\u002Facademy\u002Fwebsite-server-relay\u002F2026-08-12\u002Funderstand-api-v2","TalkIt API v2 overview","Understand the current TalkIt HTTP API version, authentication boundary, and response conventions.",5,{"chapterId":23,"title":24,"steps":25},"server-relay-implementation","Implement the client flow",[26,37],{"stepId":27,"ref":28,"pageRef":29,"route":33,"title":34,"description":35,"durationMinutes":36},"choose-javascript-sdk",{"courseId":12,"revisionId":13,"stepId":27},{"spaceId":30,"versionId":31,"docId":32},"sdk",null,"javascript-sdk","\u002Fen\u002Facademy\u002Fwebsite-server-relay\u002F2026-08-12\u002Fchoose-javascript-sdk","TalkIt JavaScript SDK","Install the TalkIt browser SDK and choose the supported chat, voice, or server-relay entry point.",7,{"stepId":38,"ref":39,"pageRef":40,"route":42,"title":43,"description":44,"durationMinutes":45},"connect-web-chat",{"courseId":12,"revisionId":13,"stepId":38},{"spaceId":41,"versionId":31,"docId":38},"integrations","\u002Fen\u002Facademy\u002Fwebsite-server-relay\u002F2026-08-12\u002Fconnect-web-chat","Connect Web Chat with server relay","Connect an authenticated website user to TalkIt without exposing Website integration credentials.",12,{"id":47,"title":34,"authors":48,"badges":50,"body":51,"contentType":380,"deprecatedSince":31,"description":35,"docId":32,"durationMinutes":36,"extension":381,"introducedIn":31,"meta":382,"navigation":235,"path":383,"releaseVersion":31,"removedIn":31,"seo":384,"spaceId":30,"status":385,"stem":386,"tags":387,"updatedAt":13,"version":31,"__hash__":390},"docs_en\u002Fdocs\u002Fsdk\u002Fjavascript-sdk.md",[49],"talkit-docs",[],{"type":52,"value":53,"toc":373},"minimark",[54,62,67,93,97,158,169,173,184,188,196,200,203,358,361,369],[55,56,57,61],"p",{},[58,59,60],"code",{},"@talkit-llc\u002Ftalkit-js"," provides browser clients for TalkIt text chat and voice calls. A separate server-only export creates Website session grants without exposing integration credentials to the browser.",[63,64,66],"h2",{"id":65},"install","Install",[68,69,75],"pre",{"className":70,"code":71,"filename":72,"language":73,"meta":74,"style":74},"language-bash shiki shiki-themes github-light github-dark","npm install @talkit-llc\u002Ftalkit-js\n","terminal","bash","",[58,76,77],{"__ignoreMap":74},[78,79,82,86,90],"span",{"class":80,"line":81},"line",1,[78,83,85],{"class":84},"sScJk","npm",[78,87,89],{"class":88},"sZZnC"," install",[78,91,92],{"class":88}," @talkit-llc\u002Ftalkit-js\n",[63,94,96],{"id":95},"choose-a-client","Choose a client",[98,99,100,116],"table",{},[101,102,103],"thead",{},[104,105,106,110,113],"tr",{},[107,108,109],"th",{},"Entry point",[107,111,112],{},"Environment",[107,114,115],{},"Purpose",[117,118,119,133,145],"tbody",{},[104,120,121,127,130],{},[122,123,124],"td",{},[58,125,126],{},"createTalkitChat",[122,128,129],{},"Browser",[122,131,132],{},"Connect a text session and send messages.",[104,134,135,140,142],{},[122,136,137],{},[58,138,139],{},"createTalkitCall",[122,141,129],{},[122,143,144],{},"Start and control a voice session.",[104,146,147,152,155],{},[122,148,149],{},[58,150,151],{},"createTalkitServerRelayGrant",[122,153,154],{},"Trusted server",[122,156,157],{},"Exchange Website credentials for a one-use session grant.",[55,159,160,161,164,165,168],{},"The browser clients both require a ",[58,162,163],{},"baseUrl"," and an asynchronous ",[58,166,167],{},"getSessionToken"," function. That function should call your authenticated backend and return its short-lived grant response.",[63,170,172],{"id":171},"text-chat","Text chat",[55,174,175,176,183],{},"Read the generated ",[177,178,180,182],"a",{"href":179},"create-chat",[58,181,126],{}," reference"," for configuration, events, connection lifecycle, and cleanup.",[63,185,187],{"id":186},"voice-calls","Voice calls",[55,189,175,190,195],{},[177,191,193,182],{"href":192},"create-call",[58,194,139],{}," for microphone startup, events, call commands, and cleanup.",[63,197,199],{"id":198},"server-relay-grants","Server-relay grants",[55,201,202],{},"Import the server helper from the dedicated server entry point:",[68,204,210],{"className":205,"code":206,"filename":207,"highlights":208,"language":209,"meta":74,"style":74},"language-ts shiki shiki-themes github-light github-dark","import { createTalkitServerRelayGrant } from '@talkit-llc\u002Ftalkit-js\u002Fserver'\n\nconst grant = await createTalkitServerRelayGrant({\n  apiBaseUrl: process.env.TALKIT_BASE_URL!,\n  clientId: process.env.TALKIT_WEBSITE_CLIENT_ID!,\n  clientSecret: process.env.TALKIT_WEBSITE_CLIENT_SECRET!,\n  channel: 'text',\n  externalSubjectId: `customer:${user.id}`,\n  externalSessionId: `session:${session.id}`,\n})\n","grant.ts",[81],"ts",[58,211,212,230,237,259,274,286,299,309,332,352],{"__ignoreMap":74},[78,213,216,220,224,227],{"class":214,"line":81},[80,215],"highlight",[78,217,219],{"class":218},"szBVR","import",[78,221,223],{"class":222},"sVt8B"," { createTalkitServerRelayGrant } ",[78,225,226],{"class":218},"from",[78,228,229],{"class":88}," '@talkit-llc\u002Ftalkit-js\u002Fserver'\n",[78,231,233],{"class":80,"line":232},2,[78,234,236],{"emptyLinePlaceholder":235},true,"\n",[78,238,240,243,247,250,253,256],{"class":80,"line":239},3,[78,241,242],{"class":218},"const",[78,244,246],{"class":245},"sj4cs"," grant",[78,248,249],{"class":218}," =",[78,251,252],{"class":218}," await",[78,254,255],{"class":84}," createTalkitServerRelayGrant",[78,257,258],{"class":222},"({\n",[78,260,262,265,268,271],{"class":80,"line":261},4,[78,263,264],{"class":222},"  apiBaseUrl: process.env.",[78,266,267],{"class":245},"TALKIT_BASE_URL",[78,269,270],{"class":218},"!",[78,272,273],{"class":222},",\n",[78,275,276,279,282,284],{"class":80,"line":21},[78,277,278],{"class":222},"  clientId: process.env.",[78,280,281],{"class":245},"TALKIT_WEBSITE_CLIENT_ID",[78,283,270],{"class":218},[78,285,273],{"class":222},[78,287,289,292,295,297],{"class":80,"line":288},6,[78,290,291],{"class":222},"  clientSecret: process.env.",[78,293,294],{"class":245},"TALKIT_WEBSITE_CLIENT_SECRET",[78,296,270],{"class":218},[78,298,273],{"class":222},[78,300,301,304,307],{"class":80,"line":36},[78,302,303],{"class":222},"  channel: ",[78,305,306],{"class":88},"'text'",[78,308,273],{"class":222},[78,310,312,315,318,321,324,327,330],{"class":80,"line":311},8,[78,313,314],{"class":222},"  externalSubjectId: ",[78,316,317],{"class":88},"`customer:${",[78,319,320],{"class":222},"user",[78,322,323],{"class":88},".",[78,325,326],{"class":222},"id",[78,328,329],{"class":88},"}`",[78,331,273],{"class":222},[78,333,335,338,341,344,346,348,350],{"class":80,"line":334},9,[78,336,337],{"class":222},"  externalSessionId: ",[78,339,340],{"class":88},"`session:${",[78,342,343],{"class":222},"session",[78,345,323],{"class":88},[78,347,326],{"class":222},[78,349,329],{"class":88},[78,351,273],{"class":222},[78,353,355],{"class":80,"line":354},10,[78,356,357],{"class":222},"})\n",[55,359,360],{},"Derive customer and session identifiers from authenticated server-side state. Never accept them blindly from browser JSON, and never return the client secret with the grant.",[55,362,363,364,368],{},"Follow ",[177,365,367],{"href":366},"..\u002Fintegrations\u002Fconnect-web-chat","Connect Web Chat"," for the complete server and browser flow.",[370,371,372],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}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);}",{"title":74,"searchDepth":239,"depth":239,"links":374},[375,376,377,378,379],{"id":65,"depth":232,"text":66},{"id":95,"depth":232,"text":96},{"id":171,"depth":232,"text":172},{"id":186,"depth":232,"text":187},{"id":198,"depth":232,"text":199},"reference","md",{},"\u002Fdocs\u002Fsdk\u002Fjavascript-sdk",{"title":34,"description":35},"published","docs\u002Fsdk\u002Fjavascript-sdk",[30,388,389],"javascript","browser","I3hXkDL30oUySeDL_1FNXDNkwzfKDYlIAqbtL8rgH6o",1792741583015]