<iframe>.
1
Configure Allowed Origins
To prevent unauthorized domains from embedding your tools, you must first configure a list of Allowed Origins for your API key. This is a critical security step. An “origin” is the combination of a protocol, domain, and port (e.g.,
https://yourapp.com).You can set the allowed origins for your API keys in the user settings page on the UBIK dashboard.Go to API Key Settings
For local development, you can add origins like
http://localhost:3000. For production, ensure you only add the domains where your application is hosted.2
Fetch Embedding Information
Before you can render the
<iframe>, your application’s frontend needs to fetch the embedding details from the UBIK API. This is done by making a GET request to the /tools/{tool_id}/embed-info endpoint.This endpoint provides two crucial pieces of information:- Tool Details: The schema, name, description, etc.
- Access Token: A short-lived JSON Web Token (JWT) that the embedded
<iframe>will use to authenticate itself.
3
Render the iframe
Once your frontend has the embedding information, you can construct the
<iframe> URL and render it. The access_token from the embed-info endpoint must be passed as a jwt query parameter to the iframe’s source URL.Here is a simplified example using React:React Example
Using a direct API Key: For scenarios where you prefer not to use the
/embed-info endpoint (e.g., server-side rendering), you can also authenticate by passing your UBIK API key directly as the apiKey query parameter.const iframeSrc = https://app.ubik-agent.com/embed/tools/YOUR_TOOL_ID?apiKey=YOUR_API_KEY`;`However, for client-side applications, using the short-lived access_token is strongly recommended to avoid exposing your secret API key.4
Customize the Embedded Tool
You can customize the appearance and behavior of the embedded tool by adding query parameters to the
<iframe> source URL.Here is a list of available parameters:jwt(string): A short-lived JSON Web Token obtained from the/tools/{tool_id}/embed-infoendpoint. This is the recommended method for client-side authentication.apiKey(string): Your UBIK API key. This can be used for authentication instead of a JWT, but it is less secure for client-side applications as it may expose your secret key.theme(‘light’ | ‘dark’): Sets the default color theme for the tool’s UI. If not provided, it defaults to the user’s system preference.showThemeToggle(boolean): If set totrue, a theme toggle switch will be displayed in the tool’s header, allowing users to switch between light and dark mode.showLangToggle(boolean): If set totrue, a language selector will be displayed, allowing users to change the display language.

