asyncapi: 2.6.0

info:
  title: amplify-svc Async API
  version: 1.0.0
  description: >
    Kafka event schemas for amplify-svc — Marketing Automation, Omnichannel
    Messaging & Cloud Telephony. All events follow CloudEvents 1.0 specification
    and are partitioned by tenantId for multi-tenant isolation.
  contact:
    name: EventZR Platform Team
    email: platform@eventzr.com
  license:
    name: Proprietary

servers:
  staging:
    url: boot-gpm4u49z.c2.kafka-serverless.us-east-1.amazonaws.com:9098
    protocol: kafka-secure
    description: Amazon MSK Serverless — staging environment (us-east-1)
    security:
      - saslScram: []

defaultContentType: application/json

channels:
  # ---------------------------------------------------------------------------
  # PRODUCER TOPICS (16) — amplify-svc publishes these
  # ---------------------------------------------------------------------------

  # Audience Management (4)
  eventzr.amplify.audience.created.v1:
    description: Published when a new audience segment is created.
    publish:
      operationId: publishAudienceCreated
      summary: Audience segment created
      message:
        $ref: '#/components/messages/AudienceCreated'

  eventzr.amplify.audience.updated.v1:
    description: Published when an audience segment definition is updated.
    publish:
      operationId: publishAudienceUpdated
      summary: Audience segment updated
      message:
        $ref: '#/components/messages/AudienceUpdated'

  eventzr.amplify.audience.deleted.v1:
    description: Published when an audience segment is deleted.
    publish:
      operationId: publishAudienceDeleted
      summary: Audience segment deleted
      message:
        $ref: '#/components/messages/AudienceDeleted'

  eventzr.amplify.audience.refreshed.v1:
    description: Published when an audience segment membership is refreshed.
    publish:
      operationId: publishAudienceRefreshed
      summary: Audience segment refreshed
      message:
        $ref: '#/components/messages/AudienceRefreshed'

  # Broadcast Campaign (7)
  eventzr.amplify.broadcast.created.v1:
    description: Published when a new broadcast campaign is created.
    publish:
      operationId: publishBroadcastCreated
      summary: Broadcast campaign created
      message:
        $ref: '#/components/messages/BroadcastCreated'

  eventzr.amplify.broadcast.scheduled.v1:
    description: Published when a broadcast campaign is scheduled for future delivery.
    publish:
      operationId: publishBroadcastScheduled
      summary: Broadcast campaign scheduled
      message:
        $ref: '#/components/messages/BroadcastScheduled'

  eventzr.amplify.broadcast.started.v1:
    description: Published when a broadcast campaign begins sending messages.
    publish:
      operationId: publishBroadcastStarted
      summary: Broadcast campaign started
      message:
        $ref: '#/components/messages/BroadcastStarted'

  eventzr.amplify.broadcast.completed.v1:
    description: Published when a broadcast campaign finishes sending all messages.
    publish:
      operationId: publishBroadcastCompleted
      summary: Broadcast campaign completed
      message:
        $ref: '#/components/messages/BroadcastCompleted'

  eventzr.amplify.broadcast.failed.v1:
    description: Published when a broadcast campaign fails during execution.
    publish:
      operationId: publishBroadcastFailed
      summary: Broadcast campaign failed
      message:
        $ref: '#/components/messages/BroadcastFailed'

  eventzr.amplify.broadcast.paused.v1:
    description: Published when a broadcast campaign is paused mid-execution.
    publish:
      operationId: publishBroadcastPaused
      summary: Broadcast campaign paused
      message:
        $ref: '#/components/messages/BroadcastPaused'

  eventzr.amplify.broadcast.cancelled.v1:
    description: Published when a broadcast campaign is cancelled before completion.
    publish:
      operationId: publishBroadcastCancelled
      summary: Broadcast campaign cancelled
      message:
        $ref: '#/components/messages/BroadcastCancelled'

  # Workflow Automation (4)
  eventzr.amplify.workflow.created.v1:
    description: Published when a new automation workflow is created.
    publish:
      operationId: publishWorkflowCreated
      summary: Automation workflow created
      message:
        $ref: '#/components/messages/WorkflowCreated'

  eventzr.amplify.workflow.activated.v1:
    description: Published when an automation workflow is activated and begins processing triggers.
    publish:
      operationId: publishWorkflowActivated
      summary: Automation workflow activated
      message:
        $ref: '#/components/messages/WorkflowActivated'

  eventzr.amplify.workflow.paused.v1:
    description: Published when an automation workflow is paused.
    publish:
      operationId: publishWorkflowPaused
      summary: Automation workflow paused
      message:
        $ref: '#/components/messages/WorkflowPaused'

  eventzr.amplify.workflow.completed.v1:
    description: Published when an automation workflow run completes.
    publish:
      operationId: publishWorkflowCompleted
      summary: Automation workflow completed
      message:
        $ref: '#/components/messages/WorkflowCompleted'

  # Template (1)
  eventzr.amplify.template.created.v1:
    description: Published when a new message template is created.
    publish:
      operationId: publishTemplateCreated
      summary: Message template created
      message:
        $ref: '#/components/messages/TemplateCreated'

  # ---------------------------------------------------------------------------
  # CONSUMER TOPICS (22) — amplify-svc subscribes to these
  # ---------------------------------------------------------------------------

  # Campaign (3)
  eventzr.campaign.created.v1:
    description: Consumed when a campaign is created in campaign-svc.
    subscribe:
      operationId: onCampaignCreated
      summary: React to new campaign creation
      message:
        $ref: '#/components/messages/CampaignCreated'

  eventzr.campaign.activated.v1:
    description: Consumed when a campaign is activated in campaign-svc.
    subscribe:
      operationId: onCampaignActivated
      summary: React to campaign activation
      message:
        $ref: '#/components/messages/CampaignActivated'

  eventzr.campaign.completed.v1:
    description: Consumed when a campaign completes in campaign-svc.
    subscribe:
      operationId: onCampaignCompleted
      summary: React to campaign completion
      message:
        $ref: '#/components/messages/CampaignCompleted'

  # IoT (3)
  eventzr.iot.geofence.entered.v1:
    description: Consumed when a user enters a geofence zone (from iot-svc).
    subscribe:
      operationId: onGeofenceEntered
      summary: Trigger location-based messaging on geofence entry
      message:
        $ref: '#/components/messages/GeofenceEntered'

  eventzr.iot.geofence.exited.v1:
    description: Consumed when a user exits a geofence zone (from iot-svc).
    subscribe:
      operationId: onGeofenceExited
      summary: Trigger follow-up messaging on geofence exit
      message:
        $ref: '#/components/messages/GeofenceExited'

  eventzr.iot.beacon.detected.v1:
    description: Consumed when a BLE beacon is detected near a user (from iot-svc).
    subscribe:
      operationId: onBeaconDetected
      summary: Trigger proximity-based messaging on beacon detection
      message:
        $ref: '#/components/messages/BeaconDetected'

  # Leadgen (2)
  eventzr.leadgen.lead.captured.v1:
    description: Consumed when a new lead is captured (from leadgen-svc).
    subscribe:
      operationId: onLeadCaptured
      summary: Trigger lead nurture workflows
      message:
        $ref: '#/components/messages/LeadCaptured'

  eventzr.leadgen.lead.qualified.v1:
    description: Consumed when a lead is qualified (from leadgen-svc).
    subscribe:
      operationId: onLeadQualified
      summary: Trigger qualified lead workflows
      message:
        $ref: '#/components/messages/LeadQualified'

  # Compliance (2)
  eventzr.compliance.unsubscribe.requested.v1:
    description: Consumed when a user requests to unsubscribe from communications.
    subscribe:
      operationId: onUnsubscribeRequested
      summary: Suppress messaging for unsubscribed user
      message:
        $ref: '#/components/messages/UnsubscribeRequested'

  eventzr.compliance.gdpr.erasure.requested.v1:
    description: Consumed when a GDPR data erasure request is received.
    subscribe:
      operationId: onGdprErasureRequested
      summary: Purge user data from amplify-svc for GDPR compliance
      message:
        $ref: '#/components/messages/GdprErasureRequested'

  # Delivery Status (2)
  eventzr.notify.message.bounced.v1:
    description: Consumed when a message delivery bounces (from notify-svc).
    subscribe:
      operationId: onMessageBounced
      summary: Handle message bounce for delivery analytics
      message:
        $ref: '#/components/messages/MessageBounced'

  eventzr.notify.message.complained.v1:
    description: Consumed when a recipient files a spam complaint (from notify-svc).
    subscribe:
      operationId: onMessageComplained
      summary: Handle spam complaint and suppress future messaging
      message:
        $ref: '#/components/messages/MessageComplained'

  # Ticketing (3)
  eventzr.ticketing.cart.abandoned.v1:
    description: Consumed when a ticketing cart is abandoned (from ticketing-svc).
    subscribe:
      operationId: onCartAbandoned
      summary: Trigger cart abandonment recovery workflow
      message:
        $ref: '#/components/messages/CartAbandoned'

  eventzr.ticketing.ticket.purchased.v1:
    description: Consumed when a ticket is purchased (from ticketing-svc).
    subscribe:
      operationId: onTicketPurchased
      summary: Trigger post-purchase messaging workflow
      message:
        $ref: '#/components/messages/TicketPurchased'

  eventzr.ticketing.ticket.refunded.v1:
    description: Consumed when a ticket is refunded (from ticketing-svc).
    subscribe:
      operationId: onTicketRefunded
      summary: Trigger refund confirmation messaging
      message:
        $ref: '#/components/messages/TicketRefunded'

  # Integration Hub (2)
  eventzr.integrationhub.delivery.status.v1:
    description: Consumed when a delivery status update is received (from integration-hub-svc).
    subscribe:
      operationId: onDeliveryStatus
      summary: Update broadcast analytics with delivery status
      message:
        $ref: '#/components/messages/DeliveryStatus'

  eventzr.integrationhub.whatsapp.status.v1:
    description: Consumed when a WhatsApp message status update is received (from integration-hub-svc).
    subscribe:
      operationId: onWhatsAppStatus
      summary: Update broadcast analytics with WhatsApp delivery status
      message:
        $ref: '#/components/messages/WhatsAppStatus'

  # Wallet (2)
  eventzr.wallet.deduction.confirmed.v1:
    description: Consumed when a wallet deduction is confirmed (from wallet-svc).
    subscribe:
      operationId: onWalletDeductionConfirmed
      summary: Proceed with broadcast sending after credit confirmation
      message:
        $ref: '#/components/messages/WalletDeductionConfirmed'

  eventzr.wallet.deduction.failed.v1:
    description: Consumed when a wallet deduction fails (from wallet-svc).
    subscribe:
      operationId: onWalletDeductionFailed
      summary: Abort broadcast sending due to insufficient credits
      message:
        $ref: '#/components/messages/WalletDeductionFailed'

  # User (2)
  eventzr.user.user.created.v1:
    description: Consumed when a new user is created (from user-svc).
    subscribe:
      operationId: onUserCreated
      summary: Add user to default audience segments and trigger welcome workflows
      message:
        $ref: '#/components/messages/UserCreated'

  eventzr.user.user.updated.v1:
    description: Consumed when a user profile is updated (from user-svc).
    subscribe:
      operationId: onUserUpdated
      summary: Refresh audience segment memberships based on updated user attributes
      message:
        $ref: '#/components/messages/UserUpdated'

  # Subscriptions (1)
  eventzr.subscriptions.plan.changed.v1:
    description: Consumed when a tenant subscription plan changes (from subscriptions-svc).
    subscribe:
      operationId: onPlanChanged
      summary: Update rate limits and feature flags based on new subscription tier
      message:
        $ref: '#/components/messages/PlanChanged'

components:
  securitySchemes:
    saslScram:
      type: scramSha256
      description: SASL/SCRAM-SHA-256 authentication for Amazon MSK Serverless

  schemas:
    # -------------------------------------------------------------------------
    # Common / Shared Schemas
    # -------------------------------------------------------------------------
    CloudEventHeaders:
      type: object
      description: CloudEvents 1.0 metadata headers present on every message.
      required:
        - specversion
        - type
        - source
        - id
        - time
        - datacontenttype
        - partitionkey
      properties:
        specversion:
          type: string
          const: '1.0'
          description: CloudEvents specification version.
        type:
          type: string
          description: Event type — matches the Kafka topic name.
        source:
          type: string
          const: amplify-svc
          description: Originating service.
        id:
          type: string
          format: uuid
          description: Unique event identifier.
        time:
          type: string
          format: date-time
          description: ISO 8601 timestamp of event emission.
        datacontenttype:
          type: string
          const: application/json
          description: Content type of the data payload.
        partitionkey:
          type: string
          format: uuid
          description: Kafka partition key — always the tenantId.

    TenantId:
      type: string
      format: uuid
      description: Tenant identifier for multi-tenant isolation.

    EntityReference:
      type: object
      description: A lightweight reference to an entity.
      required:
        - id
        - tenantId
      properties:
        id:
          type: string
          format: uuid
        tenantId:
          $ref: '#/components/schemas/TenantId'

    TimestampFields:
      type: object
      properties:
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    # -------------------------------------------------------------------------
    # Audience Schemas
    # -------------------------------------------------------------------------
    AudiencePayload:
      type: object
      required:
        - tenantId
        - audienceId
        - name
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        audienceId:
          type: string
          format: uuid
        name:
          type: string
          description: Human-readable audience segment name.
        description:
          type: string
        memberCount:
          type: integer
          minimum: 0
          description: Current number of members in the segment.
        segmentRules:
          type: object
          description: Rule definitions used to compute segment membership.
        tags:
          type: array
          items:
            type: string

    AudienceRefreshedPayload:
      type: object
      required:
        - tenantId
        - audienceId
        - previousCount
        - newCount
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        audienceId:
          type: string
          format: uuid
        previousCount:
          type: integer
          minimum: 0
        newCount:
          type: integer
          minimum: 0
        addedMembers:
          type: integer
          minimum: 0
        removedMembers:
          type: integer
          minimum: 0

    # -------------------------------------------------------------------------
    # Broadcast Schemas
    # -------------------------------------------------------------------------
    BroadcastPayload:
      type: object
      required:
        - tenantId
        - broadcastId
        - name
        - status
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        broadcastId:
          type: string
          format: uuid
        name:
          type: string
        status:
          type: string
          enum:
            - draft
            - scheduled
            - sending
            - completed
            - failed
            - paused
            - cancelled
        channel:
          type: string
          enum:
            - whatsapp
            - sms
            - email
            - push
            - in_app
          description: Primary delivery channel.
        audienceId:
          type: string
          format: uuid
        templateId:
          type: string
          format: uuid
        scheduledAt:
          type: string
          format: date-time
        totalRecipients:
          type: integer
          minimum: 0
        deliveredCount:
          type: integer
          minimum: 0
        failedCount:
          type: integer
          minimum: 0

    BroadcastFailedPayload:
      type: object
      required:
        - tenantId
        - broadcastId
        - errorCode
        - errorMessage
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        broadcastId:
          type: string
          format: uuid
        errorCode:
          type: string
          description: Machine-readable error code (e.g., ERR_AMPLIFY_INSUFFICIENT_CREDITS).
        errorMessage:
          type: string
        failedAt:
          type: string
          format: date-time
        totalRecipients:
          type: integer
          minimum: 0
        deliveredCount:
          type: integer
          minimum: 0
        failedCount:
          type: integer
          minimum: 0

    # -------------------------------------------------------------------------
    # Workflow Schemas
    # -------------------------------------------------------------------------
    WorkflowPayload:
      type: object
      required:
        - tenantId
        - workflowId
        - name
        - status
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        workflowId:
          type: string
          format: uuid
        name:
          type: string
        status:
          type: string
          enum:
            - draft
            - active
            - paused
            - completed
            - archived
        triggerType:
          type: string
          enum:
            - event
            - schedule
            - api
            - segment_entry
            - segment_exit
          description: What triggers this workflow.
        stepsCount:
          type: integer
          minimum: 0
        enrolledCount:
          type: integer
          minimum: 0
          description: Number of contacts currently enrolled.

    # -------------------------------------------------------------------------
    # Template Schema
    # -------------------------------------------------------------------------
    TemplatePayload:
      type: object
      required:
        - tenantId
        - templateId
        - name
        - channel
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        templateId:
          type: string
          format: uuid
        name:
          type: string
        channel:
          type: string
          enum:
            - whatsapp
            - sms
            - email
            - push
            - in_app
        locale:
          type: string
          description: BCP 47 locale tag (e.g., en-US, hi-IN).
        category:
          type: string
          description: Template category (e.g., marketing, transactional, otp).

    # -------------------------------------------------------------------------
    # Consumer Event Schemas (external services)
    # -------------------------------------------------------------------------
    CampaignEventPayload:
      type: object
      required:
        - tenantId
        - campaignId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        campaignId:
          type: string
          format: uuid
        name:
          type: string
        status:
          type: string

    GeofenceEventPayload:
      type: object
      required:
        - tenantId
        - userId
        - geofenceId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        userId:
          type: string
          format: uuid
        geofenceId:
          type: string
          format: uuid
        latitude:
          type: number
          format: double
        longitude:
          type: number
          format: double
        timestamp:
          type: string
          format: date-time

    BeaconEventPayload:
      type: object
      required:
        - tenantId
        - userId
        - beaconId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        userId:
          type: string
          format: uuid
        beaconId:
          type: string
          format: uuid
        proximity:
          type: string
          enum:
            - immediate
            - near
            - far
        rssi:
          type: integer
          description: Received signal strength indicator.

    LeadEventPayload:
      type: object
      required:
        - tenantId
        - leadId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        leadId:
          type: string
          format: uuid
        email:
          type: string
          format: email
        phone:
          type: string
        source:
          type: string
          description: Lead capture source (e.g., landing_page, whatsapp, form).
        score:
          type: integer
          minimum: 0
          maximum: 100
          description: Lead qualification score.

    UnsubscribePayload:
      type: object
      required:
        - tenantId
        - userId
        - channel
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        userId:
          type: string
          format: uuid
        channel:
          type: string
          enum:
            - whatsapp
            - sms
            - email
            - push
            - all
        reason:
          type: string

    GdprErasurePayload:
      type: object
      required:
        - tenantId
        - userId
        - requestId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        userId:
          type: string
          format: uuid
        requestId:
          type: string
          format: uuid
        requestedAt:
          type: string
          format: date-time

    MessageBouncePayload:
      type: object
      required:
        - tenantId
        - messageId
        - bounceType
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        messageId:
          type: string
          format: uuid
        bounceType:
          type: string
          enum:
            - hard
            - soft
            - undetermined
        recipient:
          type: string
        channel:
          type: string

    MessageComplaintPayload:
      type: object
      required:
        - tenantId
        - messageId
        - userId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        messageId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        complaintType:
          type: string
          enum:
            - spam
            - abuse
            - other

    CartAbandonedPayload:
      type: object
      required:
        - tenantId
        - cartId
        - userId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        cartId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        eventId:
          type: string
          format: uuid
        totalAmount:
          type: number
          format: double
        currency:
          type: string
          minLength: 3
          maxLength: 3
        itemCount:
          type: integer
          minimum: 1
        abandonedAt:
          type: string
          format: date-time

    TicketPurchasedPayload:
      type: object
      required:
        - tenantId
        - ticketId
        - userId
        - eventId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        ticketId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        eventId:
          type: string
          format: uuid
        orderId:
          type: string
          format: uuid
        amount:
          type: number
          format: double
        currency:
          type: string

    TicketRefundedPayload:
      type: object
      required:
        - tenantId
        - ticketId
        - userId
        - refundAmount
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        ticketId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        refundAmount:
          type: number
          format: double
        currency:
          type: string
        reason:
          type: string

    DeliveryStatusPayload:
      type: object
      required:
        - tenantId
        - messageId
        - status
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        messageId:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - sent
            - delivered
            - read
            - failed
            - rejected
        channel:
          type: string
        provider:
          type: string
          description: Delivery provider (e.g., twilio, sendgrid, meta).
        timestamp:
          type: string
          format: date-time

    WhatsAppStatusPayload:
      type: object
      required:
        - tenantId
        - messageId
        - waMessageId
        - status
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        messageId:
          type: string
          format: uuid
        waMessageId:
          type: string
          description: WhatsApp Business API message ID.
        status:
          type: string
          enum:
            - sent
            - delivered
            - read
            - failed
        recipientPhone:
          type: string
        timestamp:
          type: string
          format: date-time
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: integer
              title:
                type: string

    WalletDeductionConfirmedPayload:
      type: object
      required:
        - tenantId
        - transactionId
        - amount
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        transactionId:
          type: string
          format: uuid
        walletId:
          type: string
          format: uuid
        amount:
          type: number
          format: double
        currency:
          type: string
        referenceType:
          type: string
          description: What the deduction was for (e.g., broadcast, workflow).
        referenceId:
          type: string
          format: uuid

    WalletDeductionFailedPayload:
      type: object
      required:
        - tenantId
        - transactionId
        - errorCode
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        transactionId:
          type: string
          format: uuid
        walletId:
          type: string
          format: uuid
        errorCode:
          type: string
          description: Machine-readable error code (e.g., ERR_WALLET_INSUFFICIENT_BALANCE).
        errorMessage:
          type: string
        referenceType:
          type: string
        referenceId:
          type: string
          format: uuid

    UserEventPayload:
      type: object
      required:
        - tenantId
        - userId
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        userId:
          type: string
          format: uuid
        email:
          type: string
          format: email
        phone:
          type: string
        displayName:
          type: string
        locale:
          type: string
          description: BCP 47 locale tag.
        roles:
          type: array
          items:
            type: string

    PlanChangedPayload:
      type: object
      required:
        - tenantId
        - previousTier
        - newTier
      properties:
        tenantId:
          $ref: '#/components/schemas/TenantId'
        subscriptionId:
          type: string
          format: uuid
        previousTier:
          type: string
          enum:
            - BASE
            - STUDENT
            - STARTUP
            - PRO
            - PROMAX
            - ENTERPRISE
            - CUSTOM
        newTier:
          type: string
          enum:
            - BASE
            - STUDENT
            - STARTUP
            - PRO
            - PROMAX
            - ENTERPRISE
            - CUSTOM
        effectiveAt:
          type: string
          format: date-time

  # ---------------------------------------------------------------------------
  # Message Definitions
  # ---------------------------------------------------------------------------
  messages:
    # Producer Messages — Audience
    AudienceCreated:
      name: AudienceCreated
      title: Audience Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AudiencePayload'

    AudienceUpdated:
      name: AudienceUpdated
      title: Audience Updated
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AudiencePayload'

    AudienceDeleted:
      name: AudienceDeleted
      title: Audience Deleted
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/EntityReference'

    AudienceRefreshed:
      name: AudienceRefreshed
      title: Audience Refreshed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AudienceRefreshedPayload'

    # Producer Messages — Broadcast
    BroadcastCreated:
      name: BroadcastCreated
      title: Broadcast Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    BroadcastScheduled:
      name: BroadcastScheduled
      title: Broadcast Scheduled
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    BroadcastStarted:
      name: BroadcastStarted
      title: Broadcast Started
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    BroadcastCompleted:
      name: BroadcastCompleted
      title: Broadcast Completed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    BroadcastFailed:
      name: BroadcastFailed
      title: Broadcast Failed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastFailedPayload'

    BroadcastPaused:
      name: BroadcastPaused
      title: Broadcast Paused
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    BroadcastCancelled:
      name: BroadcastCancelled
      title: Broadcast Cancelled
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BroadcastPayload'

    # Producer Messages — Workflow
    WorkflowCreated:
      name: WorkflowCreated
      title: Workflow Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WorkflowPayload'

    WorkflowActivated:
      name: WorkflowActivated
      title: Workflow Activated
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WorkflowPayload'

    WorkflowPaused:
      name: WorkflowPaused
      title: Workflow Paused
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WorkflowPayload'

    WorkflowCompleted:
      name: WorkflowCompleted
      title: Workflow Completed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WorkflowPayload'

    # Producer Messages — Template
    TemplateCreated:
      name: TemplateCreated
      title: Template Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/TemplatePayload'

    # Consumer Messages — Campaign
    CampaignCreated:
      name: CampaignCreated
      title: Campaign Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/CampaignEventPayload'

    CampaignActivated:
      name: CampaignActivated
      title: Campaign Activated
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/CampaignEventPayload'

    CampaignCompleted:
      name: CampaignCompleted
      title: Campaign Completed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/CampaignEventPayload'

    # Consumer Messages — IoT
    GeofenceEntered:
      name: GeofenceEntered
      title: Geofence Entered
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/GeofenceEventPayload'

    GeofenceExited:
      name: GeofenceExited
      title: Geofence Exited
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/GeofenceEventPayload'

    BeaconDetected:
      name: BeaconDetected
      title: Beacon Detected
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/BeaconEventPayload'

    # Consumer Messages — Leadgen
    LeadCaptured:
      name: LeadCaptured
      title: Lead Captured
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/LeadEventPayload'

    LeadQualified:
      name: LeadQualified
      title: Lead Qualified
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/LeadEventPayload'

    # Consumer Messages — Compliance
    UnsubscribeRequested:
      name: UnsubscribeRequested
      title: Unsubscribe Requested
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/UnsubscribePayload'

    GdprErasureRequested:
      name: GdprErasureRequested
      title: GDPR Erasure Requested
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/GdprErasurePayload'

    # Consumer Messages — Delivery Status
    MessageBounced:
      name: MessageBounced
      title: Message Bounced
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/MessageBouncePayload'

    MessageComplained:
      name: MessageComplained
      title: Message Complained
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/MessageComplaintPayload'

    # Consumer Messages — Ticketing
    CartAbandoned:
      name: CartAbandoned
      title: Cart Abandoned
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/CartAbandonedPayload'

    TicketPurchased:
      name: TicketPurchased
      title: Ticket Purchased
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/TicketPurchasedPayload'

    TicketRefunded:
      name: TicketRefunded
      title: Ticket Refunded
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/TicketRefundedPayload'

    # Consumer Messages — Integration Hub
    DeliveryStatus:
      name: DeliveryStatus
      title: Delivery Status
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeliveryStatusPayload'

    WhatsAppStatus:
      name: WhatsAppStatus
      title: WhatsApp Status
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WhatsAppStatusPayload'

    # Consumer Messages — Wallet
    WalletDeductionConfirmed:
      name: WalletDeductionConfirmed
      title: Wallet Deduction Confirmed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WalletDeductionConfirmedPayload'

    WalletDeductionFailed:
      name: WalletDeductionFailed
      title: Wallet Deduction Failed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WalletDeductionFailedPayload'

    # Consumer Messages — User
    UserCreated:
      name: UserCreated
      title: User Created
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/UserEventPayload'

    UserUpdated:
      name: UserUpdated
      title: User Updated
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/UserEventPayload'

    # Consumer Messages — Subscriptions
    PlanChanged:
      name: PlanChanged
      title: Plan Changed
      contentType: application/json
      headers:
        $ref: '#/components/schemas/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/PlanChangedPayload'
