Skip to Content
unii.docs

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:

example.ts
import { Unii } from "@unii/sdk";const client = new Unii({apiKey: process.env.UNII_API_KEY,});

Generating an API key

  1. Sign in to the Unii Developer Console
  2. Navigate to Settings → API Keys
  3. Click Create new key and give it a descriptive name
  4. 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:

  1. Generate a new key from the console
  2. Update your application configuration with the new key
  3. 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:

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

On this page