Rotate Service Key
Rotate a service API key.
Creates a new key with the same name, permissions, and settings as the existing key, then revokes the old key. This is an atomic operation.
Args: key_id: UUID of the key to rotate admin_key: Validated admin API key (from dependency) db: Database session
Returns: RotateServiceKeyResponse with old key info and new key details
Raises: 404: If key not found or already revoked
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Header Parameters
Section titled “Header Parameters ”Responses
Section titled “ Responses ”Key rotated successfully
Response schema for service key rotation (FR-ROTATE-005).
Attributes: old_key_id: ID of the revoked key old_key_revoked_at: Timestamp when old key was revoked new_key: Details of the newly created key (includes plaintext)
object
ID of the revoked key
Timestamp when old key was revoked
New key details (includes plaintext)
object
Key UUID
Key name
Plaintext key (shown once - store securely!)
Creation timestamp
Multi-tenant enabled
Service permissions
Invalid API key
Standard error response for Admin API.
Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message
object
Error code
Human-readable error message
Missing admin:keys permission
Standard error response for Admin API.
Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message
object
Error code
Human-readable error message
Key not found or already revoked
Standard error response for Admin API.
Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message
object
Error code
Human-readable error message
Validation Error
object
object
object
Rate limited
Standard error response for Admin API.
Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message
object
Error code
Human-readable error message