OptStuff

Key Management

Best practices for API key lifecycle management — creation, rotation, revocation, expiration, and environment-specific strategies.

Every OptStuff API key goes through a lifecycle: creation, active use, and eventual rotation or revocation. Managing this lifecycle well is critical for keeping your integration secure.

API Key Structure

Each API key consists of a dual-key pair:

ComponentFormatPurposeVisibility
Public Keypk_ + 22 characters (25 total)Identifies requests in URLsViewable anytime in dashboard
Secret Keysk_ + base64urlSigns URLs (HMAC-SHA256)Shown only once at creation/rotation

For details on how keys are used in requests, see URL Signing.

Key Lifecycle

Creation

  1. Create a key from the dashboard (see Quick Start)
  2. Configure: name and optional expiration
  3. Copy the secret key immediately — it cannot be retrieved later

The public key can always be viewed and copied from the API key list.

Rotation

Rotation revokes the old key and creates a new one in a single database transaction. The new key inherits all settings from the old key.

Use rotation when:

  • A key may have been compromised
  • Your regular rotation schedule triggers (recommended: every 90 days)

After rotation:

  1. Copy the new secret key
  2. Update your environment variables
  3. Deploy the change

Revocation

Revocation immediately disables a key. All subsequent requests using it will receive 401.

Use revocation when:

  • A key is confirmed compromised and you don't need a replacement
  • A key is no longer needed
  • You want to disable access for a specific integration

Expiration

Set an optional expiration date when creating a key. After this date, the key is automatically rejected. This limits the damage window if a key is compromised and goes undetected.

Best Practices

PracticeWhy
Set expiration datesLimits damage window if a key is compromised
Rotate every 90 daysReduces long-term exposure risk
Use separate keys per environmentIsolates production from development/staging
Revoke compromised keys immediatelyStops unauthorized access instantly
Sign URLs server-side onlySecret key never exposed to browsers
Store secret keys in environment variablesNever hard-code or commit to version control

Environment Strategy

EnvironmentRecommended Setup
DevelopmentSeparate key with short expiration
StagingSeparate key matching production configuration
ProductionSeparate key, appropriate expiration, and monitored traffic profile (not yet available in the dashboard)

Last updated on

On this page