Embedding the dashboard is available to enterprise customers with Partner API access. Contact us to get started.
Summary/Quick Start
- Get your API key from Settings → API Keys in your Answering Agent dashboard
- Create a user via
POST /api/v1/userswithX-API-KEYheader → receivesembed_tokenin response - Store the embed token in your database alongside the user
- Embed the dashboard using
<iframe src="https://answeringagent.com/dashboard.html?token=EMBED_TOKEN"> - User’s browser loads embed → token is auto-exchanged for session auth
X-API-KEY = your server only. embed_token = safe for browsers.
The Answering Agent dashboard can be embedded into your website, providing a seamless customer support platform for your users. The embed system uses secure, compact tokens that authenticate users without exposing sensitive credentials.
Authentication Overview
The embed system involves two different authentication contexts:Your Server (Partner)
Uses the X-API-KEY header to call the Partner API and retrieve embed tokens for your users.
User's Browser (End User)
Uses the embed_token which is automatically exchanged for session authentication.
How Tokens Flow
Your server requests an embed token
Call the Partner API with your
X-API-KEY to get an embed_token for a specific user.Your server passes the token to the browser
Inject the
embed_token into your HTML page (via data-token attribute or iFrame URL).The browser exchanges the token
When the embed loads, it automatically calls
/api/validate-embed-token to exchange the embed_token for a session auth_token.Getting Embed Tokens (Server-Side)
These endpoints require your X-API-KEY header and should only be called from your server, never from client-side code.
From User Creation
When you create a user from your server, the response includes anembed_token:
Managing Existing Tokens
For existing users, your server can retrieve or regenerate embed tokens:Get Current Embed Token
- cURL
- Node.js
- PHP
Generate New Embed Token
Embedding the Dashboard
There are two ways to embed the Answering Agent dashboard:- iFrame Embed (Recommended) - Simple, isolated, no JavaScript needed
- Script Embed - More control, direct DOM integration
iFrame Embed (Recommended)
The easiest way to embed the dashboard with complete DOM isolation:- Zero JavaScript required - just paste the iFrame
- Complete DOM isolation from your page
- Works with strict Content Security Policies
- No conflicts with your site’s CSS or JavaScript
- Easy to implement in any CMS or page builder
Script Embed
For more direct integration into your page’s DOM:Quick Start Checklist
For iFrame Embed:- iFrame tag with
srcpointing to/dashboard.html?token=YOUR_TOKEN - Valid embed token in the URL query parameter
- Container div with
id="answering-agent" - Embed token in
data-tokenattribute - Embed script loaded from
https://answeringagent.com/embed.js - API URL in
data-api-urlattribute (optional, for playground/custom environments)
embed_token for session authentication.
Dynamic Token Integration
For production applications, your server should fetch embed tokens and pass them to the frontend.Server-Side Endpoint
Create an endpoint in your backend that fetches the embed token:- Node.js / Express
- PHP / Laravel
Client-Side Integration
Your frontend calls your backend (not Answering Agent directly):The embed script automatically handles exchanging the
embed_token for a session token. You don’t need to call /api/validate-embed-token yourself.React Component Example
Your
/api/embed-token endpoint should authenticate the request using your own auth system, then call the Answering Agent Partner API with your X-API-KEY.Security Features
Token Types
| Token | Who Uses It | How It’s Sent | How to Get It |
|---|---|---|---|
| X-API-KEY | Your server | X-API-KEY header | Dashboard → Settings → API Keys |
| embed_token | User’s browser | data-token attr or URL param | Partner API response |
| auth_token | User’s browser | Authorization: Bearer header | Auto-exchanged from embed_token |
Compact Tokens
- URL-safe base64 encoding without padding
- Optimized for query parameters and data attributes
Secure Validation
- Uses HMAC-SHA256 for cryptographic integrity
- Tokens are tied to specific users and cannot be transferred
- Automatic signing secret rotation invalidates old tokens
Token Lifecycle
- Tokens don’t expire but can be invalidated by generating new ones
- Each user can only have one valid embed token at a time
- Signing secrets are unique per user and automatically generated
Error Handling
Invalid or Expired Tokens
If an embed token is invalid, the embedded dashboard will show an authentication error. Common causes:- Token was invalidated by generating a new one
- Token is malformed or corrupted
- User account was deleted or suspended
Missing Configuration
If the embed container is not properly configured, you may see:- Console warnings about missing configuration
- Dashboard not loading or appearing blank
- Authentication errors
Best Practices
Server-Side (Your Backend)
- Never expose X-API-KEY - Keep your API key in environment variables on your server
- Proxy embed tokens - Your backend should fetch tokens and pass them to the frontend
- Cache tokens - Store embed tokens in your database to reduce API calls
- Regenerate on security events - Rotate tokens when users change passwords
Client-Side (User’s Browser)
- Use the embed script - Let
embed.jshandle token exchange automatically - Set data-token before loading script - Ensure the container has the token attribute set
- Handle errors gracefully - Show fallback UI if embedding fails
- Use HTTPS only - Never transmit tokens over insecure connections
Troubleshooting
Dashboard Won’t Load
- Verify the embed token is valid by checking the Partner API response
- Confirm the container has
id="answering-agent"(exact match required) - Check browser console for JavaScript errors
- Ensure the embed container has proper dimensions and is visible
Authentication Errors
- The embed token may have been invalidated - fetch a new one from the Partner API
- Check that your server is using the correct
X-API-KEY - Verify the user exists in Answering Agent
- Ensure the
data-tokenattribute is set on the container
Configuration Errors
- Verify the container has exactly
id="answering-agent" - Check that the
data-tokenattribute contains a valid embed token - Ensure the embed script loads successfully from
https://answeringagent.com/embed.js - Monitor network requests to verify API calls are reaching the correct endpoint
Performance Issues
- Cache embed tokens in your backend to avoid repeated Partner API calls
- Consider preloading the embed script on pages where it will be used
- Monitor embed container sizing to prevent layout shifts