Setup
Create a key, keep it out of your repository, and construct the client once.
- 1
Install
bashnpm install @tigerbase/server - 2
Create a key
Open API keys in the dashboard sidebar. Give the key a name you will recognise in a log, and only the scopes it needs. The key is shown once and cannot be read back — if you lose it, revoke it and make another.
- 3
Put it in the environment
.env.localTIGERBASE_KEY=tb_live_…Not in the repository, and not in anything your build sends to a browser. In Next.js that means not a
NEXT_PUBLIC_variable — that prefix is an instruction to put the value in the bundle. - 4
Construct it once
lib/tigerbase.tsimport { TigerbaseServer } from "@tigerbase/server"; /** * One instance for the process. * * Constructing per request re-reads the key every time and, more to the * point, spreads the import across files — which is how it eventually * lands in one that ships to a browser. */ export const tigerbase = new TigerbaseServer({ apiKey: process.env.TIGERBASE_KEY!, }); - 5
Check it works
bashcurl https://api.tigerbase.cloud/v1/agents \ -H "Authorization: Bearer $TIGERBASE_KEY"A list of your agents means the key and its
readscope are good. A 401 means the key itself is wrong; a 403 means it is valid but was not givenread.
Creating a key asks who you are
A server key is standing access: it keeps working long after the session that made it has ended. So the dashboard treats minting one as a sensitive change, and two rules apply.
You confirm it is you
Before the key is created you are asked for your password, or a two-factor code if you have it switched on. An open laptop or a borrowed session is not enough to walk away with a key.
A key can do no more than you can
| read, chat | You need permission to view agents. |
|---|---|
| write | You need permission to edit agents. |
| handoff | You need permission to reply in the inbox. |
Ask for a scope beyond your own role and the request is refused. A member who cannot read the inbox should not be able to mint a key that can.
TipOne key, one App
Options
| apiKey | Required. The secret key, starting tb_live_. |
|---|---|
| apiUrl | Optional. Where the API lives. Defaults to https://api.tigerbase.cloud — set it for a self-hosted install or local development. |
What it does the moment you construct it
Two checks, both before any network call, so a misconfiguration fails where you can see it rather than on the first request in production.
| A missing key | Throws invalid_key immediately, instead of making a request that was always going to be refused. |
|---|---|
| A browser | Throws secret_key_in_browser. If you see this in a framework that renders on both sides, the import has reached a client component. |
WarningIf you hit secret_key_in_browser in Next.js
TipBoth packages, one app
@tigerbase/server in your route handlers and server components, @tigerbase/client in the components that render the chat. Different keys, different packages, no overlap.