App Credentials
Copy page
How app credentials authenticate end-users, the session token flow, domain validation, and Proof-of-Work protection.
App credentials are the auth mechanism for chat components. This page covers the underlying auth flow, security model, and advanced configuration.
How Authentication Works
When your widget loads, it authenticates through a two-step flow:
- Get a session token — the widget calls
POST /run/auth/apps/{appId}/anonymous-session. The server validates the requestOriginagainst the app's allowed domains and returns a JWT. - Use the token — subsequent chat requests include the JWT and App ID:
Each session gets a unique anonymous user ID (anon_<uuid>), enabling per-user conversation history.
To refresh a token while preserving the same anonymous identity, include the existing token as an Authorization: Bearer header when requesting a new session. If the token is valid, the server reuses the same user ID (sub claim) and issues a fresh token with a new 30-day expiry. If the token is invalid, expired, or belongs to a different app, a new anonymous identity is created as usual.
Create an App via API
See the Apps API Reference for the full CRUD API.
Proof-of-Work Protection
When Proof-of-Work (PoW) is enabled on the server, clients must solve a computational challenge before requesting a session token. This protects against automated abuse.
PoW is optional and controlled by the server administrator via the INKEEP_POW_HMAC_SECRET environment variable. If PoW is not enabled, the challenge endpoint returns 404 and clients skip this step.
Client Integration
Install the solver library:
Fetch a challenge, solve it, and include the solution when requesting a session token:
Include the returned headers in the anonymous session request:
Security Model
| Feature | Details |
|---|---|
| Domain allowlist | Origin header validated against the app's allowedDomains at token issuance |
| Scoped access | Each app is bound to a default agent via defaultAgentId |
| Anonymous identity | Each session gets a unique user ID for per-user conversation history |
| Token expiry | Session tokens have a configurable TTL (default: 30 days) |
| PoW | Optional Proof-of-Work challenges prevent automated abuse |
| Rolling refresh | Include existing token when requesting a new session to preserve identity with a fresh expiry |
App Credentials vs API Keys
| App Credentials | API Keys | |
|---|---|---|
| Use case | Browser / client-side | Server-to-server |
| Exposed to end-users | Yes (App ID only) | No (secret) |
| Domain restrictions | Yes | No |
| Per-user identity | Yes (anonymous sessions) | No |
| Default agent | One agent (via defaultAgentId) | One agent per key |
Related
- Chat Components — widget setup and configuration
- Chat API — low-level streaming API details
- Apps API Reference — CRUD operations for app management
- Auth API Reference — session and PoW challenge endpoints