Authentication
Phonic supports three ways to authenticate requests to the API and the conversation WebSocket. Pick based on where your code runs and how you manage user identity.
Quick decision guide
- Just getting started? Use an API key. See Quick Start.
- Building a client-side app? Mint a session token from your backend and hand it to the browser.
- Operating your own identity provider? Issue JWTs signed with your own key. Phonic verifies them without a round-trip.
Where to pass credentials
All three mechanisms work on both REST endpoints and the conversation WebSocket.
For REST endpoints, pass credentials in the Authorization header:
For the conversation WebSocket, pass credentials as a query parameter:
Browsers cannot set custom headers on a WebSocket handshake, so the query parameter form exists specifically for client-side use.