Skip to main content

Overview

The System & Testing endpoints provide tools for monitoring API health, testing authentication, and ensuring proper system functionality. These endpoints are essential for monitoring and debugging integrations.

Health Check

GET /health

Comprehensive system health check that verifies API server status, database connectivity, and authentication services. This endpoint does not require authentication.

Example Request

Response Statuses

  • 200 OK: All systems operational
  • 207 Multi-Status: Some systems degraded but API functional
  • 503 Service Unavailable: Critical systems down

Healthy Response (200)

Degraded Response (207)

Error Response (503)

Authentication Testing

GET /test-auth

Test endpoint to verify that your authentication is working correctly. Supports both API key and JWT token authentication methods.

Authentication Methods

The endpoint will detect and test whichever authentication method you provide:
  1. API Key: Use X-API-Key header
  2. JWT Token: Use Authorization: Bearer header
  3. Legacy API Key: Use Authorization: Bearer with legacy key

Example: Test API Key

Example: Test JWT Token

Success Response (200)

API Key Authentication:
JWT Authentication:
Legacy API Key:

Error Response (401)

CORS Testing

GET /cors-test

Test Cross-Origin Resource Sharing (CORS) configuration. This endpoint helps verify that your web application can properly communicate with the API from browser environments.

Example Request

Response

CORS Headers

The API supports requests from these origins:
  • https://intentgpt.ai
  • https://www.intentgpt.ai
  • http://localhost:8080
  • http://localhost:3000
  • Development workstation URLs

System Monitoring

Health Check Integration

The health check endpoint is designed for integration with monitoring systems:

Kubernetes Liveness Probe

Docker Health Check

Monitoring Script

Error Diagnosis

Common Issues

Authentication Failures

Symptom: 401 errors on /test-auth Solutions:
  1. Verify API key format and validity
  2. Check header format (X-API-Key vs Authorization: Bearer)
  3. Ensure key is active using /toggle_key endpoint

Health Check Degraded

Symptom: 207 status on /health Solutions:
  1. Check database connectivity
  2. Verify required tables exist
  3. Review system logs for errors

CORS Issues

Symptom: Browser requests blocked Solutions:
  1. Verify origin is in allowed list
  2. Test with /cors-test endpoint
  3. Check preflight OPTIONS requests

Testing Checklist

Before going to production, test these scenarios:
  • Health check returns 200 OK
  • API key authentication works via X-API-Key header
  • JWT token authentication works via Authorization: Bearer
  • CORS requests succeed from your domain
  • Error responses are properly formatted
  • Rate limiting is functioning (if applicable)

Integration Examples

Frontend Health Check

Backend Monitoring

Best Practices

Monitoring

  1. Regular Health Checks: Monitor /health every 1-5 minutes
  2. Alert Thresholds: Alert on 207 (degraded) and 503 (down) responses
  3. Response Time Monitoring: Track response_time_ms for performance trends

Testing

  1. Pre-deployment Testing: Always test auth before deploying
  2. CORS Validation: Test from actual client domains
  3. Error Handling: Verify your app handles API errors gracefully

Debugging

  1. Use Test Endpoints: Leverage /test-auth for debugging auth issues
  2. Check Health Details: Review specific component failures in health checks
  3. Monitor Logs: Enable logging for all API interactions during debugging