[PR #1260] [CLOSED] Add API endpoint to clear a check's events #1101

Closed
opened 2026-02-26 00:30:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/healthchecks/healthchecks/pull/1260
Author: @gniting
Created: 2/1/2026
Status: Closed

Base: masterHead: add-clear-events-api


📝 Commits (1)

  • 8c451bc Add API endpoint to clear a check's events

📊 Changes

9 files changed (+522 additions, -2 deletions)

View changed files

hc/api/tests/test_clear_events.py (+92 -0)
📝 hc/api/urls.py (+5 -0)
📝 hc/api/views.py (+23 -0)
📝 templates/docs/api.html-fragment (+62 -0)
📝 templates/docs/api.md (+72 -0)
📝 templates/docs/apiv1.html-fragment (+62 -0)
📝 templates/docs/apiv1.md (+72 -1)
📝 templates/docs/apiv2.html-fragment (+62 -0)
📝 templates/docs/apiv2.md (+72 -1)

📄 Description

This PR adds a new Management API endpoint to clear a check's events, mirroring the existing "Clear Events" functionality available in the web interface.

Endpoint: POST /api/v{1,2,3}/checks/<uuid>/events/clear

Details → This endpoint resets a check's state and removes all associated event data:

  • Sets status to new
  • Clears last_ping, last_start, last_duration, alert_after
  • Resets the check to a fresh new state (clears all ping-related metadata, deletes pings, notifications, and flips)

The implementation matches the behavior of the web UI's "Clear Events" action (hc/front/views.py:858-875).

Changes

  • hc/api/urls.py - Added route
  • hc/api/views.py - Added clear_events view
  • hc/api/tests/test_clear_events.py - Added 8 test cases
  • templates/docs/api*.md and templates/docs/api*.html-fragment - Added documentation for v1, v2, and v3

Testing

  • All existing tests pass
  • New tests cover: basic functionality, API key in POST body, OPTIONS handling, POST-only validation, ownership validation, invalid UUID, missing check, non-dict body rejection

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/healthchecks/healthchecks/pull/1260 **Author:** [@gniting](https://github.com/gniting) **Created:** 2/1/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `add-clear-events-api` --- ### 📝 Commits (1) - [`8c451bc`](https://github.com/healthchecks/healthchecks/commit/8c451bc5ec80dc1ad1f641e034a3b310ea7aef6f) Add API endpoint to clear a check's events ### 📊 Changes **9 files changed** (+522 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `hc/api/tests/test_clear_events.py` (+92 -0) 📝 `hc/api/urls.py` (+5 -0) 📝 `hc/api/views.py` (+23 -0) 📝 `templates/docs/api.html-fragment` (+62 -0) 📝 `templates/docs/api.md` (+72 -0) 📝 `templates/docs/apiv1.html-fragment` (+62 -0) 📝 `templates/docs/apiv1.md` (+72 -1) 📝 `templates/docs/apiv2.html-fragment` (+62 -0) 📝 `templates/docs/apiv2.md` (+72 -1) </details> ### 📄 Description This PR adds a new Management API endpoint to clear a check's events, mirroring the existing "Clear Events" functionality available in the web interface. **Endpoint**: POST `/api/v{1,2,3}/checks/<uuid>/events/clear` **Details** → This endpoint resets a check's state and removes all associated event data: - Sets status to `new` - Clears `last_ping`, `last_start`, `last_duration`, `alert_after` - Resets the check to a fresh `new` state (clears all ping-related metadata, deletes pings, notifications, and flips) The implementation matches the behavior of the web UI's "Clear Events" action (hc/front/views.py:858-875). **Changes** - `hc/api/urls.py` - Added route - `hc/api/views.py` - Added clear_events view - `hc/api/tests/test_clear_events.py` - Added 8 test cases - `templates/docs/api*.md` and `templates/docs/api*.html-fragment` - Added documentation for v1, v2, and v3 **Testing** - All existing tests pass - New tests cover: basic functionality, API key in POST body, OPTIONS handling, POST-only validation, ownership validation, invalid UUID, missing check, non-dict body rejection --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 00:30:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#1101
No description provided.