[➕ Feature]: Delete Alerts using an API for all timestamps altogether
Is your feature request related to a problem? Please describe. How can we delete all the timestamps of a particular alert, I want to remove the whole alert for all timestamps.
Describe the solution you'd like Delete all the timestamps of a particular alert and perhaps expose an endpoint for that
Describe alternatives you've considered keep hitting the delete API for an Alert repeatedly for all timestamps
Additional context NA
hey @debashishDev - are you willing to contribute this feature? :)
Ya sure!
Labeling this one as a Good First Issue.
The solution could be making lastReceived an optional field here: https://docs.keephq.dev/api-ref/alerts/delete-alert
If you want to work on this, join Slack and we will help: https://slack.keephq.dev/ !
Hi, I’m interested in implementing this feature. Has anyone officially claimed it yet? If not, can it be assigned to me? @Matvey-Kuk
+1 that is what i need as well
+1 that is what i need as well
Just to make sure I understand this issue properly: would you like to be able to delete an alert completely from Keep, using API request?
An open questions for anybody on this issue :)
@talboren
would you like to be able to delete an alert completely from Keep, using API request?
yes, that what we need in our use case
Hey @debashishDev! 👋
I totally understand the pain point here. Having to hit the delete API repeatedly for each timestamp is definitely not ideal, especially when dealing with alerts that have accumulated many occurrences over time.
I've been looking at the codebase and I'd be happy to help implement this feature. Here's my proposed approach:
Proposed Solution
Option 1: Query Parameter Approach (Recommended)
Extend the existing delete endpoint with a all_timestamps flag:
DELETE /alerts/{fingerprint}?all_timestamps=true
This keeps the API clean and backward compatible.
Option 2: Bulk Delete Endpoint
Create a dedicated endpoint:
DELETE /alerts/{fingerprint}/all
This makes the intent very explicit.
Implementation Thoughts
Looking at the current delete logic, we could:
- Add a query parameter handler for
all_timestamps - Modify the delete query to optionally skip the timestamp filter
- Ensure proper cascading deletes if there are related entities
Database Consideration
Since Keep uses SQLAlchemy, the implementation would be straightforward:
if all_timestamps:
# Delete all records with matching fingerprint
db_session.query(Alert).filter(Alert.fingerprint == fingerprint).delete()
else:
# Current behavior - delete specific timestamp
db_session.query(Alert).filter(
Alert.fingerprint == fingerprint,
Alert.timestamp == timestamp
).delete()
Questions for the Maintainers
A couple of questions:
- Do you prefer Option 1 (query param) or Option 2 (separate endpoint)?
- Should this trigger the same webhook events as individual deletes?
- Any concerns about audit logging for bulk operations?
I'd love to take this on if the approach looks good! 😊
Workaround (Until Implemented)
For anyone needing this right now, here's a quick Python script using the Keep API:
import requests
def delete_all_timestamps(api_url, api_key, fingerprint):
headers = {"Authorization": f"Bearer {api_key}"}
# Fetch alert history
response = requests.get(
f"{api_url}/alerts/{fingerprint}",
headers=headers
)
# Delete each occurrence
for alert in response.json():
requests.delete(
f"{api_url}/alerts/{fingerprint}?timestamp={alert[\'timestamp\']}",
headers=headers
)
Hope this helps! Let me know if you'd like me to proceed with a PR. 🙏