Skip to main content

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 your sk_... key out of client bundles entirely.
The API key is a server secret. Never ship it to the browser or commit it to client code.

Create the route

The example below uses Next.js App Router. The same createFoundingAgentSession call works from any Node server.

Response

The route returns a JSON object with the following fields.
token
string
LiveKit access token for the browser to join the session.
serverUrl
string
LiveKit server URL to connect to.
roomName
string
The session’s room name.
bookingNonce
string
Optional. One-time value used by the booking flow.
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.