Authentication
All API requests to KalimaLab require an API key. Learn how to find, use, and secure your key.
Getting your API key
API keys are created and managed in Dashboard → API Keys. Click "Create API Key", give it a name (e.g. "production", "development"), and click "Create".
How to find your key in the dashboard:
- 1Sign in to kalimalab.com and open the Dashboard.
- 2Click "API Keys" in the left sidebar.
- 3Click "Create API Key", enter a descriptive label (e.g. "production"), and confirm.
- 4Copy the displayed key — it starts with
klmt_live_. - 5Paste it into your
.envfile or secrets manager immediately.
⚠Copy immediately
.env file right away.You can also revoke any key at any time from the same API Keys page. Revocation takes effect within milliseconds — see Error Handling for the response callers will receive.
Two authentication methods
KalimaLab accepts an API key in either the Authorization header (recommended) or an x-api-key header.
RecommendedBearer token (Authorization header)
curl https://api.kalimalab.com/v1/words/random \ -H "Authorization: Bearer klmt_live_your_key"const response = await fetch('https://api.kalimalab.com/v1/words/random', { headers: { Authorization: `Bearer ${process.env.KALIMALAB_API_KEY}`, },})x-api-key header
curl https://api.kalimalab.com/v1/words/random \ -H "x-api-key: klmt_live_your_key"const response = await fetch('https://api.kalimalab.com/v1/words/random', { headers: { 'x-api-key': process.env.KALIMALAB_API_KEY!, },})Side-by-side comparison (cURL)
# Method 1: Bearer token (recommended)curl https://api.kalimalab.com/v1/words \ -H "Authorization: Bearer klmt_live_your_key_here"# Method 2: x-api-key headercurl https://api.kalimalab.com/v1/words \ -H "x-api-key: klmt_live_your_key_here"SDK (handles authentication automatically)
import { KalimaLab } from '@kalimalab/sdk'// The SDK reads KALIMALAB_API_KEY from environment by defaultconst client = new KalimaLab({ apiKey: process.env.KALIMALAB_API_KEY! })// All requests are automatically authenticatedconst word = await client.words.random()✕Never expose your key client-side
Security best practices
Never expose your key client-side
API keys must only be used server-side. Never embed them in browser JavaScript, mobile app bundles, or public repositories.
Use environment variables
Store keys in .env files (never committed to git) or in your deployment platform's secrets manager (Vercel, Fly.io, Railway, etc.).
One key per environment
Create separate keys for development, staging, and production. This way you can revoke a compromised key without affecting other environments.
Rotate keys periodically
Create a new key, update your environment variables, then revoke the old key. Zero downtime if you follow this order.
Using environment variables in Node.js
# .env (never commit this file)KALIMALAB_API_KEY=klmt_live_your_key_hereimport { KalimaLab } from '@kalimalab/sdk'if (!process.env.KALIMALAB_API_KEY) { throw new Error('KALIMALAB_API_KEY is not set')}export const kalimalab = new KalimaLab({ apiKey: process.env.KALIMALAB_API_KEY,})Key rotation
To rotate an API key with zero downtime, follow this sequence:
- 1Go to Dashboard → API Keys and click "Create API Key".
- 2Give it the same name as the key you are rotating (e.g. "Production").
- 3Update your production environment variable to use the new key.
- 4Deploy / restart your service.
- 5After confirming the new key works, return to API Keys and revoke the old key.
What happens when a key is revoked?
Revoked keys are rejected immediately — within milliseconds of revocation. Any request made with a revoked key will receive:
{ "data": null, "error": { "code": "ERR_AUTH_REVOKED", "message": "This API key has been revoked. Generate a new key from your dashboard." }, "meta": { "requestId": "req_01j9..." }}✕Revocation is permanent
Authentication error codes
| Code | HTTP Status | Meaning |
|---|---|---|
| ERR_AUTH_MISSING | 401 | No API key was provided in the request headers. |
| ERR_AUTH_INVALID | 401 | API key does not exist or was entered incorrectly. |
| ERR_AUTH_REVOKED | 401 | API key exists but has been revoked. |