Identity-verification endpoints configure HMAC-based end-user identity validation for embedded widgets.

Use these routes to read or update identity verification settings. Widget identity signatures should be generated server-side with the organization secret and never exposed in client bundles.

Endpoint Groups

  • GET /api/settings/identity-verification: read the active widget identity client, current secret, rotation timestamp, and previous-secret expiry.
  • POST /api/settings/identity-verification with action: "validate": validate an HMAC payload and return whether it matched the current or previous secret.
  • POST /api/settings/identity-verification with action: "regenerate": rotate the identity secret.
  • POST /api/widget-clients/{id}/rotate-identity-secret: rotate the identity secret for a specific widget client.

These settings routes require a dashboard session. Add organizationId when managing organization-owned widget identity settings.

Read Settings

const url = new URL('/api/settings/identity-verification', window.location.origin); url.searchParams.set('organizationId', organizationId); const response = await fetch(url, { credentials: 'include', }); const { identityVerification } = await response.json();

Example response:

{ "identityVerification": { "clientId": "identity-verification", "secret": "ik_live_secret_value", "rotatedAt": "2026-05-17T09:00:00.000Z", "previousSecretExpiresAt": null } }

Store the secret only in server-side configuration. Do not expose it in browser bundles, HTML templates, analytics payloads, logs, or mobile apps.

Generate A Signed Identity

Create signed identity envelopes on your application server after your own authentication has identified the visitor. The value being signed is the exact string timestamp.payload.

import crypto from 'node:crypto'; export function createKommanderIdentity() { const payload = JSON.stringify({ userId: 'customer_123', userHash: 'acct_456', email: 'customer@example.com', metadata: { plan: 'pro' }, }); const timestamp = Date.now(); const signature = crypto .createHmac('sha256', process.env.KOMMANDER_IDENTITY_SECRET!) .update(`${timestamp}.${payload}`) .digest('hex'); return { payload, timestamp, signature, signatureEncoding: 'hex', }; }
import hashlib import hmac import json import os import time payload = json.dumps({ "userId": "customer_123", "userHash": "acct_456", "email": "customer@example.com", "metadata": {"plan": "pro"}, }, separators=(",", ":")) timestamp = int(time.time() * 1000) signature = hmac.new( os.environ["KOMMANDER_IDENTITY_SECRET"].encode("utf-8"), f"{timestamp}.{payload}".encode("utf-8"), hashlib.sha256, ).hexdigest()

Validate A Signature

Use validation while building and while rotating secrets. The endpoint accepts hex, base64, and base64url signatures.

const response = await fetch('/api/settings/identity-verification', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'validate', organizationId, payload, timestamp, signature, signatureEncoding: 'hex', }), }); const result = await response.json(); // { valid: true, matchedSecret: "current", reason: null }

Invalid signatures return a successful JSON response with valid: false so tools can display the reason without treating the request itself as failed.

{ "valid": false, "matchedSecret": null, "reason": "signature_mismatch" }

Rotate Secrets

Rotate the secret if it has been exposed, before handing control to another team, or as part of a scheduled credential rotation. Previous secrets remain accepted only during the configured grace period exposed as previousSecretExpiresAt.

const response = await fetch('/api/settings/identity-verification', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'regenerate', organizationId, }), }); const { identityVerification } = await response.json();

After rotating:

  1. Deploy the new secret to your server.
  2. Keep accepting the previous secret only until previousSecretExpiresAt.
  3. Regenerate any cached signed widget payloads.
  4. Remove the old value from secret stores and deployment logs.

Widget Request Shape

Custom widgets can pass the signed identity fields with message requests:

{ "userId": "64f000000000000000000001", "message": "Show my subscription", "identity": { "payload": "{\"userId\":\"customer_123\",\"userHash\":\"acct_456\"}", "timestamp": 1779026400000, "signature": "GENERATED_HMAC_SIGNATURE", "signatureEncoding": "hex" } }

For hosted widgets, use the widget JavaScript identity format documented in the widget identity verification guide.

Rate Limiting

Validation is intended for setup and diagnostics, not for every visitor request from your browser. Sign identities on your server and let the widget or message endpoint verify them as part of the chat request. If a settings endpoint returns 429, stop validation loops and retry after the Retry-After header when present.

Error Handling

  • 400: invalid action, missing payload fields, unsupported encoding, or invalid organizationId.
  • 401: no dashboard session.
  • 403: signed-in user cannot manage the requested organization identity settings.
  • 404: widget client not found during a targeted rotation.
  • 500: settings could not be loaded, encrypted, decrypted, or rotated.

Kommander.ai API Reference

Reference generated from Next.js route handlers under app/api. Response schemas intentionally describe public envelopes and common fields, not database schemas.

v1.0.0
Groups
1
Paths
2
Operations
3

Authentication

cookieAuth

Authenticated dashboard session issued by NextAuth.

bearerAuth

Bearer token used by embedded clients, service calls, or future public API clients where supported.

widgetIdentity

Signed widget identity payload. Pair with identityPayload and identityTimestamp, or use legacy userHash where still accepted.

Errors

Most handlers return JSON errors shaped as { error: string, details?: unknown }. Message endpoints may also return { status: "error", error: string }. Streaming endpoints emit JSON error events in the event stream where possible.

400 Bad request or validation failure401 Authentication required403 Permission denied404 Resource not found409 Concurrent update conflict429 Rate limit exceeded500 Server or upstream provider error

Rate Limits

Rate limits are enforced on selected authenticated organization and admin endpoints. Clients should treat 429 as retryable after backoff and should honor Retry-After when present.

  • Use exponential backoff for 429 and transient 5xx responses.
  • Do not retry non-idempotent POST requests unless the caller provides an idempotency key or the endpoint is explicitly idempotent.
  • Streaming clients should reconnect with the last known conversation or cursor state.

Identity Verification

Identity Verification endpoints.

get/api/settings/identity-verificationGet Settings Identity Verification

Get Settings Identity Verification. This identity verification endpoint is documented from the matching route handler under app/api.

Authentication

cookieAuth

Authenticated dashboard session issued by NextAuth.

bearerAuth

Bearer token used by embedded clients, service calls, or future public API clients where supported.

Code examples

cURL

curl -X GET https://app.kommander.ai/api/settings/identity-verification \
  -H "Authorization: Bearer <token>"

JavaScript

const response = await fetch('https://app.kommander.ai/api/settings/identity-verification', {
  method: 'GET',
  headers: {
    "Authorization": "Bearer <token>"
  },
});

const data = await response.json();

Python

import requests

response = requests.get(
    'https://app.kommander.ai/api/settings/identity-verification',
    headers={
      "Authorization": "Bearer <token>"
    }
)

data = response.json()

Interactive testing

GET /api/settings/identity-verification

Responses

200application/json

Successful response from the route handler.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "description": "Endpoint-specific JSON response."
}

Example response

{}
400application/json

Invalid request payload, missing parameter, or validation failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
401application/json

Missing or invalid authentication.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
403application/json

Authenticated caller lacks permission for the requested organization, resource, or admin operation.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
404application/json

Requested resource was not found.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
429application/json

Too many requests. Retry after the policy window resets; some handlers also emit Retry-After headers.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
500application/json

Unexpected server or provider failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
post/api/settings/identity-verificationCreate or run Settings Identity Verification

Create or run Settings Identity Verification. This identity verification endpoint is documented from the matching route handler under app/api.

Authentication

cookieAuth

Authenticated dashboard session issued by NextAuth.

bearerAuth

Bearer token used by embedded clients, service calls, or future public API clients where supported.

Request body

application/json

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "description": "Endpoint-specific JSON payload. See the route handler for field-level implementation details."
}

Code examples

cURL

curl -X POST https://app.kommander.ai/api/settings/identity-verification \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  --data '{}'

JavaScript

const response = await fetch('https://app.kommander.ai/api/settings/identity-verification', {
  method: 'POST',
  headers: {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({}),
});

const data = await response.json();

Python

import requests

response = requests.post(
    'https://app.kommander.ai/api/settings/identity-verification',
    headers={
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    json={}
)

data = response.json()

Interactive testing

POST /api/settings/identity-verification

Responses

200application/json

200 or 201 response from the route handler.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "description": "Endpoint-specific JSON response."
}

Example response

{}
400application/json

Invalid request payload, missing parameter, or validation failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
401application/json

Missing or invalid authentication.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
403application/json

Authenticated caller lacks permission for the requested organization, resource, or admin operation.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
404application/json

Requested resource was not found.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
429application/json

Too many requests. Retry after the policy window resets; some handlers also emit Retry-After headers.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
500application/json

Unexpected server or provider failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
post/api/widget-clients/{id}/rotate-identity-secretCreate or run Widget Clients ID Rotate Identity Secret

Create or run Widget Clients ID Rotate Identity Secret. This identity verification endpoint is documented from the matching route handler under app/api.

Authentication

cookieAuth

Authenticated dashboard session issued by NextAuth.

bearerAuth

Bearer token used by embedded clients, service calls, or future public API clients where supported.

Parameters

NameInTypeRequiredDescription
idpathstringyesid route parameter.

Request body

application/json

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "description": "Endpoint-specific JSON payload. See the route handler for field-level implementation details."
}

Code examples

cURL

curl -X POST https://app.kommander.ai/api/widget-clients/123/rotate-identity-secret \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  --data '{}'

JavaScript

const response = await fetch('https://app.kommander.ai/api/widget-clients/123/rotate-identity-secret', {
  method: 'POST',
  headers: {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({}),
});

const data = await response.json();

Python

import requests

response = requests.post(
    'https://app.kommander.ai/api/widget-clients/123/rotate-identity-secret',
    headers={
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    json={}
)

data = response.json()

Interactive testing

POST /api/widget-clients/123/rotate-identity-secret

Responses

200application/json

200 or 201 response from the route handler.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "description": "Endpoint-specific JSON response."
}

Example response

{}
400application/json

Invalid request payload, missing parameter, or validation failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
401application/json

Missing or invalid authentication.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
403application/json

Authenticated caller lacks permission for the requested organization, resource, or admin operation.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
404application/json

Requested resource was not found.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
429application/json

Too many requests. Retry after the policy window resets; some handlers also emit Retry-After headers.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}
500application/json

Unexpected server or provider failure.

application/json schema

{
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    },
    "details": {
      "description": "Optional validation or provider-specific details."
    },
    "status": {
      "type": "string",
      "description": "Optional machine status used by some message endpoints."
    }
  }
}

Example response

{
  "error": "string",
  "details": {},
  "status": "string"
}