Agent Authentication Contract
This document defines the authentication contract for programmatic (agent/bot) access to ASG Agent Cloud.Authentication Hierarchy
ASG Gateway supports two authentication methods, evaluated in order:- SIWS Session Cookie (
asg_session) — For console UI users - Bearer Token API Key — For agents and programmatic access
API Key Format
| Prefix | Environment | Example |
|---|---|---|
asc_sk_live_ | Production | asc_sk_live_abc123... |
asc_sk_test_ | Staging/Dev | asc_sk_test_xyz789... |
Security Model
Key Storage
- Plain-text key: Shown ONCE at creation time — user must save it
- Server stores: BCrypt hash only (cost=10)
- No recovery: Lost keys cannot be retrieved; user must rotate
Scopes
| Scope | Description |
|---|---|
read | Query balance, history, usage stats (default) |
fund | Initiate deposits, manage billing (requires opt-in) |
Rate Limits
| Tier | RPM Limit | Default |
|---|---|---|
| Free | 60 | ✓ |
| Plus | 300 | |
| Pro | 1000 |
Retry-After header.
Endpoints (Billing Plane)
Create Key
List Keys
Revoke Key
Rotate Key
Validate Key (Internal)
Gateway Auth Middleware
The gateway validates keys via billing-plane/keys/validate with 5-minute caching.
Error Responses
| Status | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 403 | FORBIDDEN | Missing required scope |
| 429 | RATE_LIMITED | Rate limit exceeded |