Aller au contenu principal

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-key and Authorization headers 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:

  1. IP Cooldown Check: Rejects IPs currently blocked due to repeated failed authentication attempts.
  2. Format & Cryptographic Verification: Validates prefix/pattern (^gpk_live_[A-Za-z0-9]+_[A-Za-z0-9]+$, length 24–128), computes HMAC-SHA256 digest, checks active cache, and verifies DB keyHash with constant-time timingSafeEqual.
  3. Key Lifecycle Status: Rejects revoked keys, disabled keys, and expired keys (expiresAt <= now).
  4. Owning User Active Check: Rejects keys whose owning user is suspended (status !== 'ACTIVE'), immediately evicting all cached keys for that user.
  5. Fraud & Abuse Checks: Evaluates key multi-IP anomalies (5 distinct IPs in 15 minutes) and cooldown blocks.
  6. Rate Limits: Increments per-key and per-user rate counters (with tighter windows on purchase/action endpoints).
  7. 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​

HTTPerror.codeReason / TriggerClient Action
401UNAUTHORIZEDMissing header or malformed key format (MISSING_CREDENTIALS, INVALID_FORMAT)Verify x-api-key or Authorization: Bearer header format.
401UNAUTHORIZEDUnknown key digest (KEY_NOT_FOUND)Confirm you are using the latest key and target base URL.
401UNAUTHORIZEDKey permanently revoked (KEY_REVOKED)Switch to a newly provisioned key; revoked keys cannot be restored.
401UNAUTHORIZEDKey past expiresAt (KEY_EXPIRED)Rotate key and update secret storage.
403FORBIDDENKey temporarily disabled (KEY_DISABLED)Re-enable the key or switch to an active backup key.
403FORBIDDENOwning user account suspended (USER_SUSPENDED)Halt automated retries and contact support (@Etkeys).
403FRAUD_DETECTEDIP blocked after 8 failed auth attempts in 10 minutes, or key flagged across 5 distinct IPs in 15 minutesWait 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.