Authentication
All /api/v1/* routes authenticate requests using customer API keys bound strictly to one owning user.
Headers & Token Format
Present your key using either header on HTTPS requests:
- Recommended (
x-api-key):x-api-key: YOUR_API_KEY - Standard Bearer (
Authorization):Authorization: Bearer YOUR_API_KEY
Key Structure
Customer keys follow the format:
gpk_live_<8-char public ID>_<32-char secret>
- Only an HMAC-SHA256 hash (
keyHash), a non-secret display prefix (gpk_live_<publicId>), and the last 4 characters (lastFour) are persisted on the server. - Both
x-api-keyandAuthorizationheaders are redacted from server application logs and audit payloads.
Request Validation Pipeline
On every /api/v1/* request, the API executes this ordered verification pipeline before running route logic:
- IP Cooldown Check: Rejects IPs currently blocked due to repeated failed authentication attempts.
- Format & Cryptographic Verification: Validates prefix/pattern (
^gpk_live_[A-Za-z0-9]+_[A-Za-z0-9]+$, length24–128), computes HMAC-SHA256 digest, checks active cache, and verifies DBkeyHashwith constant-timetimingSafeEqual. - Key Lifecycle Status: Rejects revoked keys, disabled keys, and expired keys (
expiresAt <= now). - Owning User Active Check: Rejects keys whose owning user is suspended (
status !== 'ACTIVE'), immediately evicting all cached keys for that user. - Fraud & Abuse Checks: Evaluates key multi-IP anomalies (
5distinct IPs in15minutes) and cooldown blocks. - Rate Limits: Increments per-key and per-user rate counters (with tighter windows on purchase/action endpoints).
- Balance Check: Verifies the owning user's balance record exists and is non-negative (
available >= 0) before any downstream route runs.
Authentication & Security Failure Reference
| HTTP | error.code | Reason / Trigger | Client Action |
|---|---|---|---|
401 | UNAUTHORIZED | Missing header or malformed key format (MISSING_CREDENTIALS, INVALID_FORMAT) | Verify x-api-key or Authorization: Bearer header format. |
401 | UNAUTHORIZED | Unknown key digest (KEY_NOT_FOUND) | Confirm you are using the latest key and target base URL. |
401 | UNAUTHORIZED | Key permanently revoked (KEY_REVOKED) | Switch to a newly provisioned key; revoked keys cannot be restored. |
401 | UNAUTHORIZED | Key past expiresAt (KEY_EXPIRED) | Rotate key and update secret storage. |
403 | FORBIDDEN | Key temporarily disabled (KEY_DISABLED) | Re-enable the key or switch to an active backup key. |
403 | FORBIDDEN | Owning user account suspended (USER_SUSPENDED) | Halt automated retries and contact support (@Etkeys). |
403 | FRAUD_DETECTED | IP blocked after 8 failed auth attempts in 10 minutes, or key flagged across 5 distinct IPs in 15 minutes | Wait until details.blockedUntil, fix credentials/IP routing, and inspect audit logs. |
Every authentication failure is recorded in the append-only audit log (AUTH_FAILED) using only the non-secret prefix—never the full key.