Authentication
Authenticate your API requests using API keys.
API key authentication
Unii uses API keys to authenticate requests. Include your API key in the Authorization header of every request:
import { Unii } from "@unii/sdk";const client = new Unii({apiKey: process.env.UNII_API_KEY,});Generating an API key
- Sign in to the Unii Developer Console
- Navigate to Settings → API Keys
- Click Create new key and give it a descriptive name
- Copy the key immediately — it will not be shown again
Warning
Store your API key securely. Never commit it to version control or share it publicly. Use environment variables or a secrets manager.
Key permissions
API keys can be scoped to specific permissions:
- Full access — Read and write access to all resources
- Read only — Read access to all resources
- Chat only — Access limited to chat completions
You can manage key permissions from the Developer Console.
Rotating keys
To rotate an API key:
- Generate a new key from the console
- Update your application configuration with the new key
- Revoke the old key from the console
Note
Revoking a key immediately invalidates all active sessions using that key. Plan rotations during maintenance windows.
Error responses
When authentication fails, the API returns a 401 Unauthorized response:
{"error": { "message": "Invalid API key", "type": "authentication_error", "code": "invalid_api_key"}}Common authentication errors:
- invalid_api_key — The API key format is incorrect
- expired_api_key — The API key has expired
- revoked_api_key — The API key has been revoked
- missing_api_key — No API key was provided
Next steps
- Follow the Quickstart to make your first API call.
- Read the API Reference for complete endpoint documentation.
- Learn how to verify your API key programmatically.