Partner Gateway Setup
The Partner API Gateway provides enterprise partners with secure, rate-limited access to Pillexa services.
Partner Authentication
Database Schema
Partner API keys are stored in D1 database:
CREATE TABLE partner_api_keys (
id TEXT PRIMARY KEY,
api_key TEXT UNIQUE NOT NULL,
tenant_id TEXT NOT NULL,
partner_name TEXT NOT NULL,
is_active INTEGER DEFAULT 1,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);Creating Partner API Keys
- Generate a secure API key (minimum 32 characters)
- Create partner record in D1 database
- Associate API key with tenant ID
- Set
is_active = 1to enable
Authentication Flow
- Partner sends request with API key and tenant ID
- Middleware validates credentials against D1
- Partner context attached to request
- Route handler executes with partner info
Partner Configuration
Partners can be configured with:
- Rate limits (requests per minute/hour/day)
- Allowed services (brand, clinician, pharmacy, shared)
- Webhook URLs for event notifications
- Custom metadata
File: packages/api/src/services/partner-config.ts
Service Access Control
Partners can be granted access to specific services:
- All services (default)
- Specific services only
- Service-level permissions
Access is checked before routing requests to backend services.