See platform-level auth: /en/api/authentication
Authentication
Shannon Gateway supports API key authentication for all protected endpoints.API Key Authentication
Include your API key in theX-API-Key header:
Authentication Errors
401 Unauthorized - Missing or invalid API key:- Missing
X-API-Keyheader - Invalid API key format
- Disabled or expired API key
- Wrong authentication endpoint
Request Headers
Required Headers
X-API-Key
Purpose: Authentication Required: Yes (unlessGATEWAY_SKIP_AUTH=1)
Format: String
Content-Type (POST requests)
Purpose: Specify request body format Required: Yes for POST requests Format:application/json
Optional Headers
Idempotency-Key
Purpose: Prevent duplicate task submissions Required: No (recommended for critical operations) Format: UUID or unique string Cache Duration: 24 hourstraceparent
Purpose: W3C distributed tracing Required: No (recommended for observability) Format:{version}-{trace-id}-{parent-id}-{flags}
- version:
00(current version) - trace-id: 32 hex characters (128 bits)
- parent-id: 16 hex characters (64 bits)
- flags: 2 hex characters (sampled:
01, not sampled:00)
tracestate
Purpose: Vendor-specific trace context Required: No Format: Comma-separated key-value pairsCache-Control
Purpose: Control caching behavior Required: No Format: Standard HTTP cache directivesLast-Event-ID (SSE only)
Purpose: Resume SSE stream from a specific event Required: No Format: Event ID string — either a Redis stream ID (e.g.,1700000000000-0) or a numeric sequence (e.g., 42)
Response Headers
Standard Response Headers
X-Workflow-ID
Purpose: Temporal workflow identifier Present In: POST /api/v1/tasks, GET /api/v1/tasks/ Format: String (same as task_id)X-Session-ID
Purpose: Session identifier for multi-turn conversations Present In: POST /api/v1/tasks Format: UUID stringContent-Type
Purpose: Response body format Present In: All JSON responses Format:application/json
Rate Limiting Headers
X-RateLimit-Limit
Purpose: Maximum requests allowed per window Present In: All authenticated requests Format: IntegerX-RateLimit-Remaining
Purpose: Remaining requests in current window Present In: All authenticated requests Format: IntegerX-RateLimit-Reset
Purpose: Unix timestamp when rate limit resets Present In: All authenticated requests Format: Unix timestamp (seconds)Retry-After
Purpose: Seconds to wait before retrying (429 responses) Present In: 429 Too Many Requests responses Format: Integer (seconds)CORS Headers
Access-Control-Allow-Origin
Purpose: Allowed origins for CORS Present In: All responses (development mode) Format: Domain or*
Access-Control-Allow-Methods
Purpose: Allowed HTTP methods Present In: CORS preflight responses Format: Comma-separated methodsAccess-Control-Allow-Headers
Purpose: Allowed request headers Present In: CORS preflight responses Format: Comma-separated headersHeader Examples
Minimal Request (GET)
Full Request (POST)
Python - All Headers
JavaScript - Fetch API
Security Best Practices
1. Protect API Keys
Never commit API keys to version control:2. Use HTTPS in Production
3. Rotate API Keys Regularly
4. Implement Key Expiration
5. Monitor API Key Usage
Troubleshooting
Authentication Failures
Problem: Getting 401 Unauthorized Solutions:-
Check API key is included:
-
Verify API key format:
-
Check if auth is disabled:
-
Verify key in database:
Rate Limit Issues
Problem: Getting 429 Too Many Requests Solutions:-
Check rate limit headers:
-
Implement exponential backoff:
-
Increase rate limits (if needed):
Idempotency Issues
Problem: Duplicate tasks created Solutions:-
Always include Idempotency-Key:
-
Store idempotency keys:
-
Check Redis cache: