Why a server route
Your API key must stay on the server. The browser calls your own route; your route calls Moss with the secret key and returns a short-lived session token to the browser. This keeps yoursk_... key out of client bundles entirely.
Create the route
The example below uses Next.js App Router. The samecreateFoundingAgentSession call works from any Node server.
Response
The route returns a JSON object with the following fields.Return the whole session object, as the example above does. Returning only
token and serverUrl silently disables the booking and intake forms, which need bookingNonce.createFoundingAgentSession also accepts serviceUrl and timeoutMs. The defaults are correct for production, so you can omit them.Next steps
React components
Add the provider and voice bubble to your React app.