Skip to content

feat: add CRUD REST API for saved searches (/api/v2/saved-searches) #2543

Description

@ankitcharolia

Problem

Saved searches exist in the data model (SavedSearch collection, savedSearchId is already referenced in alerts) but there are no external API endpoints to create, read, update, or delete them. This makes infrastructure-as-code workflows impossible — teams cannot version-control or automate saved search provisioning.

Proposed solution

Add GET/POST /api/v2/saved-searches and GET/PUT/DELETE /api/v2/saved-searches/:id endpoints, following the same pattern as the existing dashboards/alerts external API.

The SavedSearch mongoose model and toExternalJSON() method are already implemented in packages/api/src/models/savedSearch.ts; only the router and index registration are missing.

Use case

IaC tooling (Terraform, Helm, scripts) that provisions HyperDX saved searches alongside dashboards and alerts without requiring UI interaction.

Scope of changes

  • New file: packages/api/src/routers/external-api/v2/savedSearches.ts — 5 endpoints with OpenAPI JSDoc annotations
  • Edit: packages/api/src/routers/external-api/v2/index.ts — register /saved-searches route
  • New file: packages/api/src/routers/external-api/__tests__/savedSearches.test.ts — integration tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions