Secure your agent with authentication and access control
Use signed URLs or conversation tokens to gate agent access. Generate them server-side so your XUNA AI API key stays out of the browser.
By default, agents created on XUNA AI require authentication to start a conversation. This prevents unauthorized callers from consuming your quota or accessing your agent’s capabilities. Authentication is enforced at the connection layer — clients must present a valid signed URL or conversation token to open a session.
Never expose your XUNA AI API key in client-side code. All authentication artifacts (signed URLs and conversation tokens) must be generated on your server and passed to the client.
A signed URL is a time-limited URL generated server-side that the client uses to open a WebSocket connection. It embeds your agent ID and authentication credentials so the client never needs your API key.Use signed URLs when you are connecting via the WebSocket API or need fine-grained control over the connection parameters.
from xuna_ai import XunaAIclient = XunaAI()response = client.conversational_ai.conversations.get_signed_url( agent_id="your-agent-id")signed_url = response.signed_url# Pass this URL to your client
A conversation token is a short-lived token generated server-side that the client uses to initiate a WebRTC session. Conversation tokens also support dynamic variables and session overrides at creation time.Use conversation tokens when you are using the React SDK, mobile SDKs, or any WebRTC-based deployment, or when you want to attach per-session personalization data.
If you want anyone to start a conversation without server-side authentication — for example, a public demo — you can mark the agent as public in the dashboard. Public agents accept connections without a signed URL or token.
Public agents consume your XUNA AI quota for every conversation started. Set a max conversation duration and monitor usage closely to avoid unexpected charges.
For advanced use cases — such as integrating with your own identity provider or enforcing business-specific access rules — you can implement custom authentication middleware on your server. The pattern is the same for both signed URLs and conversation tokens: your server authenticates the user through whatever mechanism you choose, then issues the XUNA AI credential only if authentication passes.See the server-side examples above for how to integrate user authentication with token generation.