Overview
Auto-authentication persists a user’s credentials for a user-level header-auth server as part of the widget token-mint call. Because it runs before the widget initializes, the server shows up as already connected in the chat widget’s Connected Services panel and the agent can call its tools immediately. It is designed for the common case where:- The user is already logged in to your SaaS platform.
- Your backend can look up that user’s API key or token on their behalf.
- The integration’s MCP server uses header authentication (for example, an
Authorization: Bearer <token>header).
Auto-authentication only applies to user-level, header-auth servers. OAuth, cookie auth, and URL-parameter auth are not supported, and project-level credentials must still go through the standard auth link flow. Header auth is the most common programmatic access method, so it covers the typical “connect the user to our own API” case.
How It Works
Auto-authentication is an optional extension of the samePOST /widget/agent-session-init call you already make to embed a widget. You do not call a separate endpoint.
1
Look up the user's credential on your backend
Your backend already knows which user is signed in, so it can fetch that user’s API key or token for your platform.
2
Include an auto_authenticate payload when minting the token
Add the
auto_authenticate object to your existing session-init request, naming the target server and supplying the raw header value(s).3
Caylex stores the credentials before the widget loads
Caylex resolves the server, applies any configured header prefix, and persists the user-level credentials. The mint response includes per-server results.
Prerequisites
- A working widget integration. See Embedded Widgets first.
- A user-level header-auth server set up in your project. The header name(s) and any prefix (such as
Bearer) are configured when the server is onboarded — auto-authentication reuses that configuration and never changes it. - A User Email for the signed-in user. This is required whenever
auto_authenticateis present. - The ability to look up the user’s platform credential on your backend.
Auto-authentication does not configure a server’s auth settings — it only saves a user’s credentials for a server that is already configured for header auth. Set up the header name and prefix when you onboard the server.
Request Shape
Add an optionalauto_authenticate object to your POST /widget/agent-session-init body:
Step 1: Mint A Token With Auto-Authentication
Extend your existing backend mint endpoint to include theauto_authenticate payload. Your backend looks up the signed-in user’s platform token and passes it through.
- Python
- TypeScript
token.py
token to the widget exactly as described in Embedded Widgets. The only difference is that the user is already connected to the named server when the widget loads.
Step 2: Read The Auto-Authentication Results
The mint response includes the usualtoken and expires_at, plus an auto_authenticate object reporting the outcome for each requested server.
status:
Auto-authentication is resilient to partial failure. If you request multiple servers and only some succeed, the call still returns a token along with per-server results — it does not fail the whole mint. Only global problems (such as a missing
user_email) return a 400.Header Values and Prefixes
Send the raw credential value. Caylex applies whatever prefix was configured for the server’s header when it was onboarded. For example, if the server’sAuthorization header is configured with a Bearer prefix:
- You send
header_value: "abc123". - Caylex stores and sends
Authorization: Bearer abc123.
header_value: "Bearer abc123" when a Bearer prefix is configured is rejected with a clear error, so you do not accidentally double-prefix the credential.
Multiple Headers
Some servers require more than one header (for example, an API key plus an account identifier). Provide every header the server’s auth config expects:failed result with details.
Server Name
Pass the server’s display name — the name you see for the server in the Caylex platform. Matching is case-insensitive, so you do not need to worry about exact capitalization. If the value matches more than one server in the project, the request returns afailed result with "Server name is ambiguous". Give the servers distinct display names to disambiguate.
Idempotency and Rotation
By default, auto-authentication is idempotent and safe to call on every widget load:- If the user has no credentials for the server, they are stored (
authenticated). - If the user already has credentials and
forceisfalse, nothing changes (already_authenticated).
force: true to replace the stored credential:
force: true, Caylex revokes the existing credentials and stores the new ones atomically, then invalidates the agent’s cached credentials so the next tool call uses the updated value. Because rotation has a small cost, prefer force: false for routine widget loads and only set force: true when you know the credential changed.
Security Model
- Auto-authentication is gated to platform administrators. The mint endpoint requires a platform access token (or an admin user), so only your backend can submit credentials.
- Credentials are stored as user-level secrets in Caylex’s tenant-scoped credential store, never returned to the browser.
- The widget token never contains raw credentials — it only encodes navigator context and the user’s identity.
- Your platform token, navigator API key, and users’ credentials stay server-side. Always call the mint endpoint from your backend.