#51 [Admin Panel] API Key Management - Rotate API Key
Description
EditImplement POST /api/v1/admin/api-keys/<api_key_id>/rotate endpoint to rotate an API key.
**API Specification:**
- Endpoint: POST /api/v1/admin/api-keys/<api_key_id>/rotate
- Permission Required: manage_users
- Path Parameter: api_key_id (UUID)
- Request Body: {grace_period_hours?: number} (default: 24)
- Response: {api_key_id, new_api_key, old_key_expires_at, new_key_active_at}
**Requirements:**
- Generate new API key
- Old key remains valid for grace period (default 24h)
- Both keys work during grace period for zero-downtime rotation
- New key shown ONLY once
- Log audit event
**Grace Period Logic:**
- old_key_expires_at = now + grace_period_hours
- During grace period, both old and new keys accepted
- After grace period, old key automatically invalidated
**IMPORTANT:** Implement with ultra attention to details and correctness.
**BEFORE CLOSING:** Take screenshot showing API key rotation. Add comment summarizing implementation.
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...