<iframe>.
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.Fetch Embedding Information
Before you can render the The returned
<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.
Multi-Tenancy & User Isolation
If your application serves multiple users, you likely want to ensure that one user cannot see another’s data within the embedded tool.You can achieve this by passing theexternal_user_id query parameter to the /embed-info endpoint.cURL
access_token will be automatically scoped to user_456. When you pass this token to the iframe, all actions (like saving state or accessing files) will be strictly isolated to that user.Alternatively, you can generate user-scoped tokens using the generic
/auth/token endpoint. See the Authentication & Security Guide for details.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.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. Use the one from/tools/{tool_id}/embed-info(optionally withexternal_user_idfor isolation).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.
Embedding a Specific Execution
In addition to embedding the tool input form, you can also embed a specific existing execution. This is ideal for sharing results with users or allowing them to monitor a long-running task that was initiated via the API.The process is identical to embedding a tool, but you use a different URL path.URL Format:
https://app.ubik-agent.com/embed/execution/YOUR_EXECUTION_ID?jwt=YOUR_JWTOr with an API Key (Server-side rendering only):
https://app.ubik-agent.com/embed/execution/YOUR_EXECUTION_ID?apiKey=YOUR_API_KEYUse Cases:- Monitoring: Redirect a user to this view after starting a task via the API.
- Sharing: Allow users to view the results of a completed task.
- Connecting to the real-time event stream.
- Displaying progress and intermediate steps.
- Rendering the final results (text, images, files) when complete.
Handling Events (Advanced)
The embedded iframe handles all real-time events, state management, and user interactions internally. You do not need to write any additional code to handle tool progress or results.However, if you need to build a completely custom interface that reacts to tool events programmatically (e.g., for deep integration into your own UI framework), you should use the API directly instead of the iframe.The main events to monitor are:
tool_update: General progress.tool_partial_update: Content streaming.tool_input_required: Request for user interaction.tool_end(orfinal_result): Execution completion with results.error: Execution error.

