Skip to main content

API Key Management

Overview

This guide provides detailed instructions for managing API keys in ASCEND, including generating new keys, monitoring usage, and securely revoking keys when necessary. API keys enable programmatic access to the ASCEND API for SDK integrations, automation, and third-party applications.

Prerequisites

  • Admin role or higher
  • Access to Settings section
  • Secure storage solution for generated keys

Step-by-Step Guide

Generating a New API Key

  1. Access the API Key Section

    • Click the Settings icon (gear) in the sidebar
    • Select the "API Keys" tab
    • Click the "Generate New Key" button
  2. Configure Key Properties

    Name (Required)

    • Enter a descriptive name
    • Best practice: Include purpose and environment
    • Examples:
      • "Production - Main Backend Service"
      • "Development - Local Testing"
      • "CI/CD - GitHub Actions"

    Description (Optional)

    • Document the key's purpose
    • Include owner/team information
    • Note any specific permissions or restrictions

    Expiration (Required)

    • Select from dropdown:
      • Never expires
      • 30 days
      • 60 days
      • 90 days (recommended)
      • 180 days
      • 365 days
  3. Generate the Key

    • Click "Generate" button
    • Wait for the key to be created
  4. Save the Key Securely

    Critical Warning:

    • The full API key is displayed only once
    • It cannot be recovered after you dismiss the dialog
    • Copy immediately to a secure location

    Copy Options:

    • Click the "Copy" button to copy to clipboard
    • Verify the key was copied correctly
    • Store in your secret management system
  5. Confirm Storage

    • Click "I've Saved My Key" button
    • The dialog closes
    • Key appears in the list with masked value

Viewing API Keys

The API key list displays all keys for your organization:

ColumnDescription
NameKey identifier you provided
KeyMasked prefix and suffix
DescriptionPurpose documentation
CreatedGeneration timestamp
ExpiresExpiration date or "Never"
Last UsedMost recent API call
StatusActive, Expired, or Revoked
ActionsView usage, Revoke

Viewing Key Usage Statistics

  1. Access Usage Stats

    • Find the key in the list
    • Click the "View Activity" icon (graph)
    • Modal displays usage statistics
  2. Available Metrics

    • Total requests (all time)
    • Requests in last 24 hours
    • Requests in last 7 days
    • Last used timestamp
    • Top endpoints by request count
    • Error rate
  3. Usage Insights

    • Identify unused keys
    • Detect unusual activity
    • Plan key rotation timing

Revoking an API Key

  1. Initiate Revocation

    • Find the key in the list
    • Click the revoke icon (trash)
    • Confirmation modal appears
  2. Confirm Revocation

    • Review the key name
    • Understand the impact:
      • Immediate effect
      • Cannot be undone
      • All applications using this key will fail
    • Click "Revoke Key"
  3. Post-Revocation

    • Key status changes to "Revoked"
    • Key remains visible for audit purposes
    • Audit log records the revocation

Rotating API Keys

Follow this process to safely rotate keys:

  1. Generate New Key

    • Create new key with descriptive name
    • Include "rotation" or date in name
    • Set appropriate expiration
  2. Update Applications

    • Deploy new key to applications
    • Update secret management systems
    • Verify applications work with new key
  3. Monitor Transition

    • Watch usage stats on both keys
    • Confirm old key usage drops to zero
    • Allow overlap period (24-48 hours)
  4. Revoke Old Key

    • Once old key shows no usage
    • Revoke the old key
    • Document rotation in change log

Configuration Options

Key Generation Options

OptionDescriptionDefaultConstraints
nameKey identifierRequired1-255 characters
descriptionPurpose documentationOptional0-500 characters
expires_in_daysDays until expiration90null, 30, 60, 90, 180, 365

Key Properties

PropertyDescriptionMutable
idUnique identifierNo
nameDisplay nameNo
descriptionPurposeNo
key_prefixMasked keyNo
created_atCreation timeNo
expires_atExpiration timeNo
last_used_atLast API callAuto-updated
statusCurrent stateVia revocation

API Reference

Generate API Key

POST /api/keys/generate
Authorization: Bearer <session_token>
Content-Type: application/json

{
"name": "Production Backend",
"description": "Main production service API access",
"expires_in_days": 90
}

Response:

{
"api_key": "owkai_admin_tUsL7xK9mPqR4wZ2",
"key_id": 1,
"name": "Production Backend",
"description": "Main production service API access",
"expires_at": "2026-04-20T00:00:00Z",
"message": "Store this key securely. It will not be shown again."
}

List API Keys

GET /api/keys/list
Authorization: Bearer <session_token>

Response:

{
"keys": [
{
"id": 1,
"name": "Production Backend",
"key_prefix": "owkai_admin_tUsL...4wZ2",
"description": "Main production service API access",
"created_at": "2026-01-20T10:30:00Z",
"expires_at": "2026-04-20T10:30:00Z",
"last_used_at": "2026-01-20T14:22:15Z",
"status": "active",
"total_requests": 1542
}
],
"total": 1
}

Get Key Usage

GET /api/keys/{key_id}/usage
Authorization: Bearer <session_token>

Response:

{
"key_id": 1,
"key_name": "Production Backend",
"usage": {
"total_requests": 1542,
"requests_24h": 156,
"requests_7d": 892,
"requests_30d": 1542,
"error_count": 12,
"error_rate": 0.78
},
"last_used": "2026-01-20T14:22:15Z",
"top_endpoints": [
{"endpoint": "POST /api/agents/actions", "count": 823},
{"endpoint": "GET /api/alerts", "count": 412},
{"endpoint": "GET /api/policies", "count": 307}
],
"daily_usage": [
{"date": "2026-01-20", "requests": 156},
{"date": "2026-01-19", "requests": 178}
]
}

Revoke API Key

DELETE /api/keys/{key_id}/revoke
Authorization: Bearer <session_token>

Response:

{
"success": true,
"message": "API key revoked successfully",
"key_id": 1,
"revoked_at": "2026-01-20T15:00:00Z"
}

Best Practices

Key Naming Conventions

Use consistent naming patterns:

{environment}_{service}_{purpose}

Examples:

  • prod_backend_main - Production backend main key
  • dev_frontend_local - Development frontend local testing
  • staging_cicd_github - Staging CI/CD GitHub Actions

Secure Storage

Recommended Storage Solutions:

SolutionBest For
AWS Secrets ManagerAWS deployments
HashiCorp VaultMulti-cloud, on-premise
Azure Key VaultAzure deployments
GCP Secret ManagerGCP deployments
1Password/BitwardenSmall teams

Never Store Keys In:

  • Source code repositories
  • Configuration files (committed)
  • Environment variables (in plain text)
  • Log files
  • Chat messages or emails
  • Shared documents

Rotation Schedule

EnvironmentRotation FrequencyExpiration
Production90 days90 days
Staging60 days60 days
Development30 days30 days
CI/CD90 days90 days

Access Control

  • Limit key generation to Admin role
  • Require approval for production keys
  • Document who has access to each key
  • Audit key usage regularly

Troubleshooting

Cannot Generate Key

IssueCauseSolution
Button disabledMissing required fieldEnter key name
403 ForbiddenInsufficient roleRequires Admin role
Rate limitedToo many attemptsWait 1 minute
500 ErrorServer issueTry again, contact support

Key Not Working

IssueCauseSolution
401 Invalid keyTypo in keyVerify key is correct
401 ExpiredPast expirationGenerate new key
401 RevokedKey was revokedGenerate new key
403 Wrong orgOrganization mismatchUse correct key for org

Cannot Revoke Key

IssueCauseSolution
403 ForbiddenNot key ownerAdmin can revoke any key
404 Not foundInvalid key IDVerify key exists
Already revokedDouble revocationKey already inactive

Lost API Key

Unfortunately, lost keys cannot be recovered.

Recovery process:

  1. Generate a new key
  2. Update all applications
  3. Revoke the lost key (if you know which one)
  4. Monitor for unauthorized usage

Security Incident Response

If a Key is Compromised

  1. Immediate Revocation

    • Revoke the key immediately
    • Do not wait to verify
  2. Impact Assessment

    • Review key usage logs
    • Identify unauthorized access
    • Determine data exposure
  3. Generate Replacement

    • Create new key
    • Deploy to legitimate applications
  4. Incident Documentation

    • Record timeline
    • Document scope
    • Note remediation steps
  5. Post-Incident Review

    • Analyze root cause
    • Implement preventive measures
    • Update security procedures