Skip to main content
See platform-level auth: /en/api/authentication

Authentication

Shannon Gateway supports two authentication methods for all protected endpoints.

API Key Authentication

Include your API key in the X-API-Key header:

Bearer Token Authentication

Alternatively, use the Authorization: Bearer header with an API key or JWT token:
Both methods are equivalent — use whichever fits your tooling.

Authentication Errors

401 Unauthorized - Missing or invalid credentials:
Common causes:
  • Missing X-API-Key or Authorization header
  • Invalid API key format
  • Disabled or expired API key
  • Expired JWT token

Request Headers

Required Headers

X-API-Key

Purpose: Authentication Required: Yes (unless GATEWAY_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 hours
Example:

traceparent

Purpose: W3C distributed tracing Required: No (recommended for observability) Format: {version}-{trace-id}-{parent-id}-{flags}
Format Specification:
  • 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)
Example:

tracestate

Purpose: Vendor-specific trace context Required: No Format: Comma-separated key-value pairs

Cache-Control

Purpose: Control caching behavior Required: No Format: Standard HTTP cache directives

Last-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)
Used for SSE reconnection:

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)
Use Case: Track workflow execution in Temporal UI

X-Session-ID

Purpose: Session identifier for multi-turn conversations Present In: POST /api/v1/tasks Format: UUID string

Content-Type

Purpose: Response body format Present In: All JSON responses Format: application/json
For SSE:

Rate Limiting Headers

X-RateLimit-Limit

Purpose: Maximum requests allowed per window Present In: All authenticated requests Format: Integer

X-RateLimit-Remaining

Purpose: Remaining requests in current window Present In: All authenticated requests Format: Integer

X-RateLimit-Reset

Purpose: Unix timestamp when rate limit resets Present In: All authenticated requests Format: Unix timestamp (seconds)
Example - Check Rate Limit:

Retry-After

Purpose: Seconds to wait before retrying (429 responses) Present In: 429 Too Many Requests responses Format: Integer (seconds)
Example - Handle Rate Limit:

CORS Headers

Access-Control-Allow-Origin

Purpose: Allowed origins for CORS Present In: All responses (development mode) Format: Domain or *
Production: Configure specific domains:

Access-Control-Allow-Methods

Purpose: Allowed HTTP methods Present In: CORS preflight responses Format: Comma-separated methods

Access-Control-Allow-Headers

Purpose: Allowed request headers Present In: CORS preflight responses Format: Comma-separated headers

Header 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:
Store in secure configuration:

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:
  1. Check API key is included:
  2. Verify API key format:
  3. Check if auth is disabled:
  4. Verify key in database:

Rate Limit Issues

Problem: Getting 429 Too Many Requests Solutions:
  1. Check rate limit headers:
  2. Implement exponential backoff:
  3. Increase rate limits (if needed):

Idempotency Issues

Problem: Duplicate tasks created Solutions:
  1. Always include Idempotency-Key:
  2. Store idempotency keys:
  3. Check Redis cache:

REST API Overview

Complete API reference

Submit Task

POST /api/v1/tasks

Rate Limiting

Rate limit details

Distributed Tracing

Tracing setup