Authentication

API authentication, token generation, and security best practices

Authentication

All Cliqer API requests require authentication via Bearer token.

Token Types

TypeUse CaseExpiryScope
Access TokenAPI requests15 minUser-specific
Refresh TokenToken renewal7 daysRefresh only
API KeyServer-to-serverConfigurableCustom scopes

Using Tokens

Include the token in the Authorization header:

curl -X GET "$BASE_URL/api/..." \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Obtain Access Token

Exchange user credentials for tokens.

Endpoint: POST /api/auth/token

ParameterTypeRequiredDescription
emailstringYesUser email
passwordstringYesUser password
curl -X POST "$BASE_URL/api/auth/token" \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"your_password"}'

Response:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4...",
  "expires_in": 900,
  "token_type": "Bearer"
}

Refresh Token

Obtain a new access token using a refresh token.

Endpoint: POST /api/auth/refresh

curl -X POST "$BASE_URL/api/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{"refresh_token":"your_refresh_token"}'

Revoke Token

Invalidate a token (logout).

Endpoint: POST /api/auth/revoke

curl -X POST "$BASE_URL/api/auth/revoke" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Admin: API Key Management

Admin Only - Requires admin:api-keys permission.

Generate API Key

Create a new API key for server-to-server integrations.

Endpoint: POST /api/admin/api-keys

ParameterTypeRequiredDescription
namestringYesKey identifier (e.g., "Production Server")
scopesstringYesPermissions: read, write, admin, or specific resources
expires_innumberNoExpiry in seconds (default: never)
ip_allowliststringNoRestrict to specific IPs/CIDRs
rate_limitnumberNoCustom requests/minute (default: tier limit)
curl -X POST "$BASE_URL/api/admin/api-keys" \
  -H "Authorization: Bearer ADMIN_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Server",
    "scopes": ["connections:read", "connections:write", "licenses:read"],
    "expires_in": 31536000,
    "ip_allowlist": ["203.0.113.0/24", "198.51.100.50"],
    "rate_limit": 500
  }'

Response:

{
  "id": "key_abc123",
  "key": "clq_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890",
  "name": "Production Server",
  "scopes": ["connections:read", "connections:write", "licenses:read"],
  "ip_allowlist": ["203.0.113.0/24", "198.51.100.50"],
  "rate_limit": 500,
  "created_at": "2025-01-15T10:30:00Z",
  "expires_at": "2026-01-15T10:30:00Z",
  "last_used_at": null
}
Security Warning - The key value is only returned once at creation. Store it securely immediately. If lost, delete and create a new key.

List API Keys

Endpoint: GET /api/admin/api-keys

curl -X GET "$BASE_URL/api/admin/api-keys" \
  -H "Authorization: Bearer ADMIN_ACCESS_TOKEN"

Revoke API Key

Endpoint: DELETE /api/admin/api-keys/{id}

curl -X DELETE "$BASE_URL/api/admin/api-keys/key_abc123" \
  -H "Authorization: Bearer ADMIN_ACCESS_TOKEN"

Available Scopes

ScopeDescription
readRead access to all resources
writeWrite access to all resources
adminFull administrative access
connections:readView active connections
connections:writeManage connections (kick, broadcast)
licenses:readView license information
licenses:writeManage licenses
rooms:readView room information
rooms:writeCreate/manage rooms
users:readView user information
users:writeManage users

Security Best Practices

Recommended Security Measures
  1. Use short-lived access tokens - Default 15 minutes, use refresh tokens for renewal
  2. Restrict IP allowlists - Limit API keys to known server IPs
  3. Minimum scopes - Only grant permissions actually needed
  4. Rotate keys regularly - Set expiry and rotate before expiration
  5. Monitor usage - Check last_used_at and audit logs for anomalies
  6. Secure storage - Store tokens in environment variables, never in code
  7. Use HTTPS only - All API requests must use TLS 1.2+

Token Storage Recommendations

EnvironmentStorage Method
BrowserHttpOnly cookies or secure memory
ServerEnvironment variables
MobileSecure keychain/keystore
CI/CDSecret management (Vault, AWS Secrets)
See Security Overview for enterprise security features.

Copyright © 2026. All rights reserved.