Pro Plan10 minutesintermediate

API Connection Errors

Troubleshoot API connection issues, authentication failures, and integration problems.

apierrorsauthenticationintegrationdebugging
Last updated: January 15, 2025

Diagnose and resolve API connection errors, authentication failures, and integration issues.

Authentication Errors

"Invalid API Key" (401)

Common causes:

  1. Wrong key format

    • API key must start with zv_ prefix
    • Keys without this prefix are invalid
    • Check you copied the full key from dashboard
  2. Key not activated

    • New keys need 1-2 minutes
    • Regenerate if still failing
  3. Key revoked

    • Check API Keys in dashboard
    • Generate new key if revoked

Fix:

// Wrong - invalid format
const key = 'abc123_not_valid...';

// Correct - Zenovay API key
const key = 'zv_xyz789abc...';

"API Key Not Found" (401)

Check header format:

# Wrong
curl -H "Api-Key: zv_..."

# Correct (External API)
curl -H "X-API-Key: zv_..."

"Insufficient Permissions" (403)

Your API key lacks required scope:

OperationRequired Scope
Read analyticsanalytics:read
Create goalsgoals:write
Manage websiteswebsites:admin

Fix: Generate new key with correct scopes.

Connection Errors

"Connection Refused"

Check endpoint:

Correct: https://api.zenovay.com/api/external/v1/
Wrong:   http://api.zenovay.com/api/external/v1/  (no HTTPS)
Wrong:   https://zenovay.com/api/    (wrong domain)

"Connection Timeout"

Causes:

  • Network issues
  • Firewall blocking
  • DNS resolution failure

Debug steps:

  1. Test connectivity:

    curl -v https://api.zenovay.com/api/external/v1/usage
    
  2. Check DNS:

    nslookup api.zenovay.com
    
  3. Check firewall:

    • Allow outbound HTTPS (443)
    • Allow api.zenovay.com domain

"SSL Certificate Error"

Causes:

  • Outdated root certificates
  • Corporate proxy interference
  • Clock skew on server

Fix:

# Update certificates (Ubuntu)
sudo apt update && sudo apt install ca-certificates

# Check system time
date

# If using Node.js, don't disable verification:
// DON'T DO THIS IN PRODUCTION
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

Rate Limit Errors

"Rate Limit Exceeded" (429)

Response headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1640000000
Retry-After: 60

Implement backoff:

async function apiCallWithRetry(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.status === 429) {
        const retryAfter = error.headers.get('Retry-After') || 60;
        await sleep(retryAfter * 1000);
        continue;
      }
      throw error;
    }
  }
}

Rate Limits

Rate limits are per-IP, not per-plan:

ContextLimit
Default API100 req/min per IP
Auth endpoints30 req/min per IP
Tracking (burst)60 req/10sec per IP
Tracking (sustained)5,000 req/hour per IP
Public endpoints30 req/min per IP

Request Errors

"Bad Request" (400)

Common issues:

  1. Invalid JSON:

    // Wrong - trailing comma
    { "name": "Test", }
    
    // Correct
    { "name": "Test" }
    
  2. Missing required fields:

    // Missing website_id
    POST /v1/goals
    { "name": "Signup" }
    
    // Correct
    POST /v1/goals
    { "name": "Signup", "website_id": "web_123" }
    
  3. Wrong data types:

    // Wrong - string instead of number
    { "page": "1" }
    
    // Correct
    { "page": 1 }
    

"Not Found" (404)

Check:

  • Endpoint URL is correct
  • Resource ID exists
  • Resource belongs to your account
# Verify endpoint
GET /v1/websites/web_123  # Correct
GET /v1/website/web_123   # Wrong (singular)

"Unprocessable Entity" (422)

Validation failed. Check response body:

{
  "error": "validation_error",
  "details": {
    "url": "Invalid URL format",
    "name": "Name too long (max 100 characters)"
  }
}

SDK Errors

JavaScript SDK

"Zenovay not defined":

<!-- Ensure script loaded -->
<script src="https://api.zenovay.com/z.js"
        data-tracking-code="YOUR_TRACKING_CODE"></script>

<!-- Check after load -->
<script>
  window.addEventListener('load', () => {
    if (typeof zenovay !== 'undefined') {
      console.log('Zenovay loaded');
    }
  });
</script>

Server-Side API Calls

Connection issues with the tracking endpoint:

// Use fetch with the tracking endpoint - no npm package needed
const response = await fetch('https://api.zenovay.com/e/YOUR_TRACKING_CODE', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'page_view',
    url: '/home',
  }),
});

if (!response.ok) {
  console.error('Zenovay tracking error:', response.status);
}

Timeout errors:

// Use AbortController for timeout control
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000);

const response = await fetch('https://api.zenovay.com/e/YOUR_TRACKING_CODE', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ type: 'page_view', url: '/home' }),
  signal: controller.signal,
});

clearTimeout(timeout);

Debugging Tips

Enable Debug Mode

In server-side calls:

// Enable verbose logging for External API calls
const response = await fetch('https://api.zenovay.com/api/external/v1/websites', {
  headers: { 'X-API-Key': 'zv_...' },
});
console.log('Status:', response.status);
console.log('Response:', await response.json());

In tracking script:

<script data-tracking-code="YOUR_TRACKING_CODE"
        data-debug="true"
        src="..."></script>

Check API Status

  1. Visit status.zenovay.com
  2. Check API endpoint status
  3. Review incident history

View Request Logs

In dashboard:

  1. Go to SettingsAPI
  2. Click Request Logs
  3. Filter by status, endpoint, time

Test with cURL

# Test API key with usage endpoint
curl -H "X-API-Key: zv_..." \
     https://api.zenovay.com/api/external/v1/usage

# List websites
curl -H "X-API-Key: zv_..." \
     https://api.zenovay.com/api/external/v1/websites

# With verbose output
curl -v -H "X-API-Key: zv_..." \
     https://api.zenovay.com/api/external/v1/websites

Common Error Codes

CodeMeaningSolution
400Bad requestCheck request body
401UnauthorizedCheck API key
403ForbiddenCheck permissions
404Not foundCheck endpoint/ID
422Validation failedCheck field values
429Rate limitedImplement backoff
500Server errorRetry, contact support
502Bad gatewayRetry in 1 minute
503UnavailableCheck status page

Contacting Support

When reporting API issues, include:

  1. Request details:

    • Endpoint URL
    • HTTP method
    • Request headers (redact API key)
    • Request body
  2. Response details:

    • Status code
    • Response body
    • Response headers
  3. Context:

    • Timestamp
    • Request ID (from headers)
    • SDK version if applicable

Email: support@zenovay.com

Next Steps

Was this article helpful?