id: wholesale_feed_bulk_webhooks
version: "1.0.0"
title: "Wholesale feed bulk-change webhook registration"
category: account_lifecycle
summary: "Validates account-level notification_configs[] registration for agents that advertise wholesale_feed.bulk_change webhook events."
track: core
introduced_in: "3.1"

requires_capability:
  path: wholesale_feed_webhooks.event_types
  contains: "wholesale_feed.bulk_change"

required_tools:
  - sync_accounts

narrative: |
  Agents that advertise the bulk-change wholesale feed webhook event must accept
  that account-level event type through `sync_accounts.accounts[].notification_configs[]`.
  The event tells consumers to repair by re-reading the affected wholesale feed.

agent:
  interaction_model: marketplace_catalog
  capabilities:
    - wholesale_feed_webhooks

caller:
  role: buyer_agent
  example: "Compliance test harness"

prerequisites:
  description: |
    The agent advertises `wholesale_feed.bulk_change` in
    `wholesale_feed_webhooks.event_types`.
  test_kit: "test-kits/acme-outdoor.yaml"

phases:
  - id: register
    title: "Register bulk-change webhook"
    steps:
      - id: register_bulk_change_webhook
        title: "Register wholesale_feed.bulk_change subscriber"
        task: sync_accounts
        schema_ref: "account/sync-accounts-request.json"
        response_schema_ref: "account/sync-accounts-response.json"
        doc_ref: "/accounts/tasks/sync_accounts"
        stateful: true
        sample_request:
          accounts:
            - brand:
                domain: "acmeoutdoor.example"
              operator: "pinnacle-agency.example"
              billing: "operator"
              payment_terms: "net_60"
              sandbox: true
              notification_configs:
                - subscriber_id: "bulk-feed-sync"
                  url: "https://example.com/webhooks/adcp/bulk-feed"
                  event_types:
                    - "wholesale_feed.bulk_change"
                  active: false
          idempotency_key: "$generate:uuid_v4#wholesale_feed_bulk_webhooks"
          context:
            correlation_id: "wholesale_feed_bulk_webhooks--register"
        validations:
          - check: response_schema
            description: "Response matches sync-accounts-response.json schema"
          - check: field_value
            path: "accounts[0].notification_configs[0].subscriber_id"
            value: "bulk-feed-sync"
            description: "Subscriber key is echoed"
          - check: field_value
            path: "accounts[0].notification_configs[0].event_types[0]"
            value: "wholesale_feed.bulk_change"
            description: "Bulk-change event is persisted"
          - check: field_value
            path: "accounts[0].notification_configs[0].active"
            value: false
            description: "Paused subscriber can be persisted without activation proof"
          - check: field_value
            path: "context.correlation_id"
            value: "wholesale_feed_bulk_webhooks--register"
            description: "Context correlation_id returned unchanged"
