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.kliqpulse.com
X-API-Key: kliq_live_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.

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

AuthConfig

PropertyTypeRequiredDescription
apiKeystringNoAPI key for simple authentication
accessTokenstringNoJWT access token
clientIdstringNoOAuth2 client ID
clientSecretstringNoOAuth2 client secret
baseUrlstringNoAPI base URL (defaults to production)
ScopeDescription
observations:readList and retrieve observations
observations:writeCreate and update observations
cv:readView CV job results
cv:writeStart CV jobs
locations:readList locations
locations:writeManage locations
webhooks:manageCreate and delete webhook subscriptions
adminFull tenant administration

Error Codes

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

Next steps