Security Best Practices
API keys carry live spending authority against your account balance. Treat every key like banking credentials.
1. Secret Storage & Zero Client Exposure
- Backend-Only Execution: Call
/api/v1/*exclusively from secure backend servers. Never embedgpk_live_...tokens in browser JavaScript bundles, React/Vue SPAs, browser extension storage, or mobile APK/IPA clients. - Environment Variables & Secrets Managers: Store keys in server environment variables (
GPKEYS_API_KEY) or vaults (AWS Secrets Manager, GCP Secret Manager, Doppler, HashiCorp Vault). Never check.envfiles into Git. - Log Redaction: Never log
Authorization,x-api-key, or full key strings in application logs, APM breadcrumbs, error trackers (Sentry), or webhook payloads. Log at most the non-secret prefix (gpk_live_ab12cd34).
2. Principle of Least Privilege & Spend Caps
- Separate Keys per Environment & Service: Issue distinct keys for production checkout, staging tests, and reporting workers so compromising one worker never disrupts unrelated workflows.
- Always Set
perRequestCapandmonthlySpendCap: Configure tight caps matching expected SKU pricing so a buggy loop or compromised container cannot drain your balance. - Set
expiresAtfor Scheduled Rotations: Assign finite expiration dates for short-lived migrations or contractor integrations.
3. Rotation, Revocation & Compromise Response
- Provision a replacement key and deploy it to your secrets manager.
- Verify production traffic runs cleanly on the new key via
GET /api/v1/key. - Disable first if confirming zero lingering dependencies (
403 KEY_DISABLEDsurfaces stray callers immediately). - Permanently revoke the old key (
REVOKEDinvalidates cached authorization immediately and blocks forever with401 UNAUTHORIZED).
If you suspect a key leak:
- Revoke immediately (revocation takes effect instantaneously across auth caches).
- Inspect
GET /api/v1/auditandGET /api/v1/ledger(?keyOnly=true) for unexpected IPs, purchases, orMULTI_IP_ABUSEevents. - Watch out for multi-IP blocks: routing one key behind many unpredictable outbound NAT IPs (
>= 5distinct IPs in15minutes) triggers automatic403 FRAUD_DETECTED(MULTI_IP_ABUSE). Route reseller traffic through a consistent static egress IP or dedicated NAT gateway.
4. Handling Account Suspension (403 FORBIDDEN)
If your user account is suspended, cached keys are invalidated immediately and all API calls reject with 403 FORBIDDEN. Build circuit-breaker handling to pause purchase workers, alert operations, and contact support (@Etkeys) rather than retrying infinitely.