Skip to main content
POST
Generate temporary Voice Agent token

Authorizations

Authorization
string
header
required

Your AssemblyAI API key passed as a Bearer token (e.g. Authorization: Bearer YOUR_API_KEY).

Body

application/json
product
string
required

The product the token is minted for. Use speech_to_speech for the Voice Agent API. Other products are streaming, sync, dictation, tts and llm_gateway; the aliases realtime, voice_agent and agent are also accepted.

Example:

"speech_to_speech"

expires_in_seconds
integer
required

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.

Required range: 1 <= x <= 600
Example:

300

access
object

Optional per-product settings that narrow what the token can open, keyed by product name. Products you leave out are not restricted. See Temporary tokens for a tutorial.

max_session_duration_seconds
integer
default: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.

Required range: 60 <= x <= 10800
Example:

8640

Response

Successfully generated a temporary token.

token
string
required

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

Example:

"your-temporary-token"

expires_in_seconds
integer
required

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.

Example:

300