Phoenix Gamification

Rate Limits and Quotas

This section outlines the rate limits, quotas, endpoints, and error-handling rules for the Phoenix Gamification Ingestion Gateway.

Base URLs

EnvironmentURL(Sample until deployment)
Productionhttps://api.phoenix-gamification.com
Staginghttps://staging-api.phoenix-gamification.com
Local Developmenthttp://localhost:3000

POST /v1/events

Submit an event for processing.

Request:

POST /v1/events HTTP/1.1
Host: api.phoenix-gamification.com
Content-Type: application/json
X-Tenant-Id: acme-corp
X-Signature: hmac-sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Timestamp: 1730113200

{
  "event_id": "evt_12345",
  "event_type": "transaction.completed",
  "tenant_id": "acme-corp",
  "user_id": "user_789",
  "timestamp": "2025-10-28T10:00:00Z",
  "attributes": {
    "amount": 299.99,
    "currency": "USD",
    "product_id": "prod_xyz"
  }
}

Success Response (200 OK):

{
  "status": "accepted",
  "event_id": "evt_12345"
}

Error Response (401 Unauthorized):

{
  "error": "Invalid signature",
  "code": "AUTH_001"
}

GET /health

Health check endpoint (no authentication required).

Response (200 OK):

{
  "status": "healthy"
}

GET /ready

Readiness check with dependency status (no authentication required).

Response (200 OK):

{
  "status": "ready",
  "database": "connected",
  "message_queue": "connected"
}

Error Handling

HTTP Status Codes

StatusMeaningAction
200OKEvent accepted successfully
400Bad RequestFix request format
401UnauthorizedCheck authentication
403ForbiddenContact support (account suspended)
422Unprocessable EntityFix validation errors
429Too Many RequestsImplement backoff and retry
500Internal Server ErrorRetry with exponential backoff
503Service UnavailableService temporarily down, retry later

Common Error Codes

CodeDescriptionResolution
AUTH_001Invalid signatureVerify signature generation
AUTH_002Missing headerInclude all required headers
AUTH_004Timestamp expiredCheck clock synchronization
AUTH_005Tenant not foundVerify tenant ID
VAL_001Missing required fieldInclude all required event fields
VAL_002Invalid field formatCheck field validation rules
RATE_001Rate limit exceededImplement backoff, reduce request rate

Retry Strategy

Implement exponential backoff for transient errors (5xx, 429):

import time
import random

def send_with_retry(event, max_retries=3):
    for attempt in range(max_retries):
        try:
            return send_event(event)
        except ServerError as e:
            if attempt == max_retries - 1:
                raise

            # Exponential backoff with jitter
            delay = min(60, (2 ** attempt) + random.uniform(0, 1))
            time.sleep(delay)

Rate Limits

Default Limits

PeriodLimit
Per second1,000
Per minute10,000
Per hour100,000
Per day1,000,000

Contact support for higher limits.

Rate Limit Headers

Responses include rate limit information:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 1730113260