Generate temporary Voice Agent token

<llms-only> > For the complete documentation index, see [llms.txt](https://www.assemblyai.com/docs/llms.txt) </llms-only> Generate a temporary authentication token for the Voice Agent API. Use this to connect browser or other client-side applications to the Voice Agent API without exposing your permanent API key. See [Browser integration](https://www.assemblyai.com/docs/voice-agents/voice-agent-api/browser-integration) for the full flow. Each token is one-time use and can only be used for a single session. All usage is attributed to the API key that generated the token.

Query parameters

expires_in_secondsintegerRequired1-600
Token redemption window, in seconds. The token must be used to open a WebSocket connection within this window. If the window has elapsed when the WebSocket is opened, the server returns a `session.error` with code `unauthorized` on the first frame instead of `session.ready`. This does NOT cap the duration of the resulting voice agent session — once the WebSocket is open the session runs for up to `max_session_duration_seconds`.
max_session_duration_secondsintegerOptional60-10800Defaults to 10800

Maximum duration of the Voice Agent session started with this token, in seconds. There is no “closing soon” warning event before the session ends, so if you need to finalize gracefully (e.g. play a wrap-up message, save state), run a client-side timer using the value you passed here.

Response

Successfully generated a temporary token.
tokenstring

The temporary authentication token. Pass as the token query parameter when opening the WebSocket.

expires_in_secondsinteger

The token redemption window in seconds — the time the client has to use this token to open a WebSocket before it expires unused. This is not the session duration; see max_session_duration_seconds for that.

Errors

400
Bad Request Error
401
Unauthorized Error
429
Too Many Requests Error
500
Internal Server Error