Authentication Methods
There are two primary ways to authenticate with the UBIK API, depending on your integration context:1. API Key (Server-Side)
For backend-to-backend communication, use your secret API Key. Pass it in theX-API-KEY header. This grants full access to your account resources.
cURL
external_user_id (in headers or body) when using the API Key. This allows you to perform actions on behalf of a specific end-user while using your server-side credentials.
cURL
2. Scoped JWT (Client-Side & Multi-Tenant)
For frontend applications or when you need to isolate data for specific end-users, use a short-lived JSON Web Token (JWT).- Generate Token: Call
POST /auth/tokenfrom your backend using your API Key. You can optionally pass anexternal_user_idto scope the token to a specific user. - Use Token: Pass the token in the
Authorizationheader.
cURL
Multi-Tenancy & Data Isolation
UBIK is designed to support multi-tenant applications out of the box. You can manage millions of your own end-users under a single UBIK account using theexternal_user_id parameter.
When you authenticate a request with an external_user_id (either via a scoped JWT or by passing it in the request body/header), the API enforces a Hybrid Access Model:
1. Private Resources (Strict Isolation)
- Agent Sessions and Tool Executions created with a specific
external_user_idare strictly private. They can only be accessed by that same user ID. - User A cannot see User B’s chat history or tool results.
2. Shared Resources (Hybrid Access)
- Workspaces and Documents follow a hybrid model. A user can access:
- Private Resources: Created specifically for them (tagged with their
external_user_id). - Global Resources: Created in your account without any
external_user_id(e.g., shared project workspaces, knowledge bases).
- Private Resources: Created specifically for them (tagged with their
- This allows you to build agents that have access to both your company’s shared knowledge base and the user’s private context simultaneously.
Why use external_user_id?
- Automatic Filtering: The API automatically filters list endpoints based on the rules above. You don’t need to build complex filtering logic in your backend.
- Security Boundaries: It enforces strict isolation at the database level.
- Simplified Auth: You can generate short-lived, scoped tokens for your frontend clients that encode this ID.
Integration Examples
Server-Side Integration (API Key)
If your backend server communicates with UBIK, you can simply pass theexternal_user_id in the request body while using your main API Key.
cURL
Client-Side Integration (Scoped JWT)
If you are integrating UBIK directly into a frontend application (like a chat widget), do not expose your API Key. Instead, generate a short-lived JWT token on your server that encodes theexternal_user_id.
Step 1: Generate a Scoped Token (Server-Side)
Call this endpoint from your backend to get a token for a specific user.
cURL
access_token in the Authorization header. The external_user_id is automatically enforced, so you don’t need to send it in the body.
cURL

