Authentication Overview

ChordianAI API uses AWS Cognito User Pools with JWT (JSON Web Tokens) for secure authentication and authorization.

Authentication Flow

Token Types

ChordianAI uses three types of tokens:

1. ID Token (from Cognito)

PropertyValue
IssuerAWS Cognito User Pool
VerificationJWKS (JSON Web Key Set)
PurposeInitial authentication
LifespanShort-lived (typically 1 hour)

2. Session JWT (Server-side)

PropertyValue
AlgorithmHS256
Expiration15 days
StorageClient-side (localStorage or sessionStorage)
Libraryjose
PurposeAPI authentication

3. Refresh Token

PropertyValue
Cookie TypehttpOnly
Expiration30 days
PurposeRenew session JWT without re-login
SecurityProtected from XSS attacks

Quick Start

import requests
 
# 1. Login
response = requests.post(
    "https://chordian-core.chordian.ai/api/auth/login",
    json={
        "username": "your-email@example.com",
        "password": "your-password"
    }
)
 
data = response.json()
session_token = data["token"]
 
# 2. Use token in API calls
headers = {
    "Authorization": f"Bearer {session_token}",
    "Content-Type": "application/json"
}
 
workflow_response = requests.post(
    "https://chordian-core.chordian.ai/api/workflow/start",
    headers=headers,
    json={
        "prompt": "Find SaaS companies",
        "serviceId": "your-service-id"
    }
)

Security Best Practices

⚠️ Warning: Never expose your credentials or tokens in client-side code, version control, or logs.

1. Token Storage

MethodSecurity LevelRecommended For
httpOnly cookie (refresh token)✅ HighProduction
Server-side session✅ HighProduction
localStorage⚠️ MediumDevelopment only
sessionStorage⚠️ MediumDevelopment only
JavaScript variables❌ LowNever

2. Always Use HTTPS

All API calls must use HTTPS to prevent token interception.

3. Token Expiration

  • Session JWT: 15 days
  • Refresh Token: 30 days
  • Implement automatic token refresh before expiration

4. Logout

Always clear tokens and cookies on logout:

// Logout example
await fetch('https://chordian-core.chordian.ai/api/auth/logout', {
  method: 'POST',
  credentials: 'include'
});
 
// Clear client-side storage
localStorage.removeItem('token');

Next Steps