KLIQ|Developers

Authentication

The KLIQ AI API supports three authentication methods: API keys, JWT tokens, and OAuth2 client credentials.

API Key Authentication

The simplest way to authenticate. Include your API key in the X-API-Key header with every request.

import { KliqClient } from '@kliq-ai/sdk';

const kliq = new KliqClient({
apiKey: process.env.KLIQ_API_KEY!,
});

Keep your API key secret

Never expose your API key in client-side code or public repositories. Use environment variables and server-side requests.

Raw HTTP Example

GET /v1/tenants/t_abc123/observations HTTP/1.1
Host: api.kliq-ai.eu
X-API-Key: kliq_sk_abc123...

JWT Token Authentication

For user-scoped actions, use JWT tokens obtained via the token endpoint.

POST/v1/auth/tokenExchange credentials for a JWT token
POST/v1/auth/refreshRefresh an expired JWT token
// Exchange credentials for a token
const { accessToken, refreshToken } = await kliq.auth.getToken({
email: 'user@example.com',
password: 'your-password',
});

// Use the token for subsequent requests
const kliqAuth = new KliqClient({
accessToken,
});

// Refresh when expired
const newTokens = await kliq.auth.refresh(refreshToken);

OAuth2 Client Credentials

For service-to-service integration, use the OAuth2 client credentials flow.

OAuth2 client credentials is the recommended flow for service-to-service authentication. The SDK handles token acquisition and refresh automatically.

const kliq = new KliqClient({
clientId: process.env.KLIQ_CLIENT_ID!,
clientSecret: process.env.KLIQ_CLIENT_SECRET!,
});

// The SDK handles token acquisition and refresh automatically

Scopes and Permissions

Authorization is role-based today. Your membership role in a tenant determines your access level:

RoleDescription
viewerRead-only access to observations and CV results
memberFull access to observations and CV jobs
managerTeam management and webhook configuration
adminFull tenant administration
ownerComplete control including billing and members

Per-key scope enforcement is on the roadmap. Today, authorization is controlled by your tenant membership role. Fine-grained API key scopes will be available in a future release.

AuthConfig

PropertyTypeRequiredDescription
apiKeystringNoAPI key for simple authentication
accessTokenstringNoJWT access token
clientIdstringNoOAuth2 client ID
clientSecretstringNoOAuth2 client secret
baseUrlstringNoAPI base URL (defaults to production)

Error Codes

StatusMeaning
401 UnauthorizedMissing or invalid credentials
403 ForbiddenValid credentials but insufficient permissions

Next steps