Skip to content

feat(webhooks): Adding event search option in the webhooks page#9907

Merged
likhinbopanna merged 5 commits into
mainfrom
webhook_filters
Oct 24, 2025
Merged

feat(webhooks): Adding event search option in the webhooks page#9907
likhinbopanna merged 5 commits into
mainfrom
webhook_filters

Conversation

@VenuMadhav2541

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

  • Added search functionality in the WebHooks page to allow filtering events using event_id.
  • Users can now quickly locate specific webhook events without manually scrolling through the list.
  • Search supports filtering alongside existing primary object ID filters.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

  • Previously, users could not search webhooks directly by event_id, making it difficult to debug or verify individual events.
  • This feature improves usability and helps developers trace and identify webhook activities more efficiently.

How did you test it?

  1. Total list:
curl 'http://localhost:9000/api/events/profile/list' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -b 'login_token=****' \
  -H 'Origin: http://localhost:9000' \
  -H 'Referer: http://localhost:9000/dashboard/webhooks' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: ****' \
  -H 'X-Merchant-Id: ****' \
  -H 'X-Profile-Id: ****' \
  -H 'api-key: ****' \
  -H 'authorization: Bearer ****' \
  -H 'sec-ch-ua: ****' \
  -H 'sec-ch-ua-mobile: ****' \
  -H 'sec-ch-ua-platform: ****' \
  --data-raw '{"start_time":"****","limit":50,"offset":0,"created_after":"****","created_before":"****"}'
  • Response:
{
    "events": [
        {
            "event_id": "evt_300000000000000000000000000000002",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000002",
            "event_type": "payment_failed",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000002",
            "created": "2025-10-16T11:05:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000016",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "dispute_challenged",
            "event_class": "disputes",
            "is_delivery_successful": false,
            "initial_attempt_id": "evt_300000000000000000000000000000016",
            "created": "2025-10-15T13:15:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000001",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "payment_succeeded",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000001",
            "created": "2025-10-15T10:00:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000015",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "dp_30000015",
            "event_type": "dispute_cancelled",
            "event_class": "disputes",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000015",
            "created": "2025-09-29T12:10:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000013",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "dp_30000013",
            "event_type": "dispute_expired",
            "event_class": "disputes",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000013",
            "created": "2025-09-27T10:00:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000012",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "dp_30000012",
            "event_type": "dispute_opened",
            "event_class": "disputes",
            "is_delivery_successful": false,
            "initial_attempt_id": "evt_300000000000000000000000000000012",
            "created": "2025-09-26T21:55:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000027",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "dp_30000027",
            "event_type": "dispute_opened",
            "event_class": "disputes",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000027",
            "created": "2025-09-26T12:10:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000011",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "rfnd_30000011",
            "event_type": "refund_failed",
            "event_class": "refunds",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000011",
            "created": "2025-09-25T20:50:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000026",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_30000026",
            "event_type": "payment_captured",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000026",
            "created": "2025-09-25T11:05:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000010",
            "merchant_id": "merchant_dummy",
            "profile_id": "pro_dummy",
            "object_id": "rfnd_30000010",
            "event_type": "refund_succeeded",
            "event_class": "refunds",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000010",
            "created": "2025-09-24T19:45:00.000Z"
        }
    ],
    "total_count": 24
}


  1. Search by event_id
curl 'http://localhost:9000/api/events/profile/list' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -b 'login_token=****' \
  -H 'Origin: http://localhost:9000' \
  -H 'Referer: http://localhost:9000/dashboard/webhooks' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: ****' \
  -H 'X-Merchant-Id: ****' \
  -H 'X-Profile-Id: ****' \
  -H 'api-key: ****' \
  -H 'authorization: Bearer ****' \
  -H 'sec-ch-ua: ****' \
  -H 'sec-ch-ua-mobile: ****' \
  -H 'sec-ch-ua-platform: ****' \
  --data-raw '{"object_id":"evt_300000000000000000000000000000002","event_id":"evt_300000000000000000000000000000002"}'
  • Response
{
    "events": [
        {
            "event_id": "evt_300000000000000000000000000000002",
            "merchant_id": "mer_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000002",
            "event_type": "payment_failed",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000002",
            "created": "2025-10-16T11:05:00.000Z"
        }
    ],
    "total_count": 1
}
  1. Search by Profile ID:
curl 'http://localhost:9000/api/events/profile/list' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -b 'login_token=****' \
  -H 'Origin: http://localhost:9000' \
  -H 'Referer: http://localhost:9000/dashboard/webhooks' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: ****' \
  -H 'X-Merchant-Id: ****' \
  -H 'X-Profile-Id: ****' \
  -H 'api-key: ****' \
  -H 'authorization: Bearer ****' \
  -H 'sec-ch-ua: ****' \
  -H 'sec-ch-ua-mobile: ****' \
  -H 'sec-ch-ua-platform: ****' \
  --data-raw '{"object_id":"pay_3000005","event_id":"pay_3000005"}'
  • Response
{
    "events": [
        {
            "event_id": "evt_300000000000000000000000000000016",
            "merchant_id": "mer_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "dispute_challenged",
            "event_class": "disputes",
            "is_delivery_successful": false,
            "initial_attempt_id": "evt_300000000000000000000000000000016",
            "created": "2025-10-15T13:15:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000001",
            "merchant_id": "mer_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "payment_succeeded",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000001",
            "created": "2025-10-15T10:00:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000005",
            "merchant_id": "mer_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "payment_partially_authorized",
            "event_class": "payments",
            "is_delivery_successful": true,
            "initial_attempt_id": "evt_300000000000000000000000000000005",
            "created": "2025-09-19T14:20:00.000Z"
        },
        {
            "event_id": "evt_300000000000000000000000000000004",
            "merchant_id": "mer_dummy",
            "profile_id": "pro_dummy",
            "object_id": "pay_3000005",
            "event_type": "payment_cancelled",
            "event_class": "payments",
            "is_delivery_successful": false,
            "initial_attempt_id": "evt_300000000000000000000000000000004",
            "created": "2025-09-18T13:15:00.000Z"
        }
    ],
    "total_count": 4
}
  1. Verified the WebHooks page manually by searching with multiple event_ids.
  2. Verified combination searches with primary_object_id and event_id.
  3. Ensured pagination, filters, and UI remain consistent.
  4. Confirmed proper handling for invalid or non-existent event_id.

Where to test it?

  • INTEG
  • SANDBOX
  • PROD

Checklist

  • I formatted the code
  • I reviewed the submitted code
  • I verified the UI and API integration for event_id search
  • I added/updated relevant tests where possible

@VenuMadhav2541 VenuMadhav2541 requested review from a team as code owners October 17, 2025 08:38
@semanticdiff-com

semanticdiff-com Bot commented Oct 17, 2025

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/webhooks/webhook_events.rs  90% smaller
  crates/diesel_models/src/query/events.rs  70% smaller
  crates/router/src/types/transformers.rs  41% smaller
  api-reference/v1/openapi_spec_v1.json  0% smaller
  crates/api_models/src/webhook_events.rs  0% smaller
  crates/router/src/db/events.rs  0% smaller
  crates/router/src/db/kafka_store.rs  0% smaller

@VenuMadhav2541 VenuMadhav2541 self-assigned this Oct 17, 2025
@VenuMadhav2541 VenuMadhav2541 added the C-feature Category: Feature request or enhancement label Oct 17, 2025
@VenuMadhav2541 VenuMadhav2541 linked an issue Oct 17, 2025 that may be closed by this pull request
2 tasks
@hyperswitch-bot hyperswitch-bot Bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Oct 17, 2025

@apoorvdixit88 apoorvdixit88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread crates/router/src/types/transformers.rs Outdated
message:
"Either only `object_id` must be specified, or one or more of \
`created_after`, `created_before`, `limit`, `offset`, `event_classes` and `event_types` must be specified"
"Either only `object_id` / `event_id` must be specified, or one or more of \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Either only 'object_id' or 'event_id; must be specified

Comment thread crates/api_models/src/webhook_events.rs Outdated
/// Refund ID, etc.)
pub object_id: Option<String>,

// Filter all events associated with the specified Event_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use documentation comment, that will update the description in openapi_spec.json, thats why its null right now , use triple ///

Comment thread crates/api_models/src/webhook_events.rs
Comment thread crates/diesel_models/src/query/events.rs
@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 24, 2025
Merged via the queue into main with commit b0d5a1b Oct 24, 2025
27 of 30 checks passed
@likhinbopanna likhinbopanna deleted the webhook_filters branch October 24, 2025 08:52
Comment on lines +1823 to +1831
(Some(object_id), None) => Ok(Self::ObjectIdFilter {
event_id: object_id.clone(),
object_id,
}),

(None, Some(event_id)) => Ok(Self::ObjectIdFilter {
object_id: event_id.clone(),
event_id,
}),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we passing object ID as event ID and vice-versa? Won't this slow down the database queries significantly?

drdholu pushed a commit to drdholu/hyperswitch that referenced this pull request Oct 30, 2025
…ay#9907)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] : Add filtering by event_id in WebHooks page

5 participants