perform.chat
Auth for Chat

Error Handling

Common errors and solutions

Common Errors

Status CodeErrorCauseSolution
401UnauthorizedInvalid API credentialsCheck keyId and keySecret
401UnauthorizedExpired API keyGenerate a new API key
401UnauthorizedInsufficient permissionsEnable required permissions on API key
400Bad RequestAgent not foundVerify agentId exists and is active
400Bad RequestNo active agentsCreate an active agent for your company
500Internal Server ErrorServer errorRetry request, contact support if persists

Example Error Response

{
  "statusCode": 401,
  "message": "Invalid API credentials",
  "error": "Unauthorized"
}

Handling Token Expiration

// Auto-refresh token when expired
let currentToken = null;
let tokenExpiresAt = null;

async function getValidToken() {
  if (!currentToken || Date.now() >= tokenExpiresAt) {
    const response = await fetch('/api/chat/token');
    const data = await response.json();

    currentToken = data.token;
    tokenExpiresAt = Date.now() + (55 * 60 * 1000); // Refresh 5 min early
  }

  return currentToken;
}

Rate Limits

OperationLimitWindow
Token generation100 requests1 minute
Failed authentication10 attempts5 minutes
API requests1000 requests1 minute

Exceeding rate limits returns a 429 Too Many Requests response.