Skip to content

Outgoing Webhooks

Status: Planned

MIDDAG Account will support outgoing webhooks to notify external systems when domain events occur. This allows you to build custom integrations without modifying the plugin.

How it works

When a significant event happens in the plugin (an entitlement is activated, an order is paid, an organization is updated), the plugin sends an HTTP POST request to one or more configured URLs. The receiving system processes the event and takes whatever action is appropriate.

Event catalog

Organization events

EventFired when
organization.createdA new organization is created
organization.updatedOrganization data is modified
organization.verifiedOrganization verification status changes

Entitlement events

EventFired when
entitlement.activatedAn entitlement becomes active
entitlement.suspendedAn entitlement is suspended
entitlement.expiredAn entitlement reaches its expiration
entitlement.cancelledAn entitlement is cancelled
entitlement.renewedAn entitlement is renewed

Order events

EventFired when
order.createdA new order is placed
order.paidAn order payment is confirmed
order.refundedAn order is refunded

Quote events

EventFired when
quote.createdA new quote is created
quote.acceptedA customer accepts a quote
quote.paidA quote is paid
quote.expiredA quote passes its expiration date

License events

EventFired when
license.activatedA license is activated on a site
license.deactivatedA license is deactivated
license.expiredA license expires

Service request events

EventFired when
ticket.createdA new service request is opened
ticket.completedA service request is resolved
ticket.sla_breachedAn SLA target is breached

Invoice events

EventFired when
invoice.issuedAn invoice is issued
tax_invoice.issuedAn NFSe is successfully issued
tax_invoice.failedAn NFSe emission fails

Payload format

Every webhook payload follows a consistent envelope:

json
{
    "event": "entitlement.activated",
    "timestamp": "2026-05-04T14:30:00Z",
    "version": "1",
    "data": {
        "id": 42,
        "code": "PLG-202605-0001",
        "organization_id": 7,
        "status": "active",
        "class": "plugin"
    }
}
FieldDescription
eventEvent type from the catalog above
timestampISO 8601 timestamp when the event occurred
versionPayload schema version (currently "1")
dataEvent-specific data (the relevant entity or DTO)

The data field contains the same structure returned by the REST API for the corresponding entity.

Retry policy

AttemptDelayNotes
1ImmediateFirst delivery attempt
21 minuteFirst retry
35 minutesSecond retry
430 minutesThird retry
52 hoursFinal retry

A delivery is considered successful when the receiving server responds with an HTTP 2xx status code. Any other response (or a timeout) triggers a retry.

After all retry attempts are exhausted, the event is marked as failed. Failed events are visible in the admin UI and can be retried manually.

Signature verification

Every outgoing webhook includes a signature header so the receiving system can verify the request originated from MIDDAG Account:

X-Middag-Signature: sha256=<HMAC-SHA256 hex digest>

The signature is computed as HMAC-SHA256(webhook_secret, raw_request_body). The receiving system should:

  1. Read the X-Middag-Signature header.
  2. Compute HMAC-SHA256 of the raw request body using the shared secret.
  3. Compare the computed value with the header value using a constant-time comparison.
  4. Reject the request if the values do not match.

Configuration

Webhook endpoints are configured per organization in the admin UI:

SettingDescription
URLThe HTTPS endpoint that receives webhook POSTs
SecretShared secret for HMAC signature verification
EventsWhich events to send (select from the catalog)
ActiveEnable or disable the endpoint

Multiple endpoints can be configured per organization. Each endpoint can subscribe to a different set of events.

Requirements for receiving endpoints

  • Must accept HTTP POST requests.
  • Must respond within 30 seconds.
  • Must use HTTPS (HTTP endpoints are not allowed).
  • Should return HTTP 200 to acknowledge receipt.
  • Should validate the X-Middag-Signature header.

Delivery guarantees

Webhooks use at-least-once delivery. The same event may be delivered more than once (due to retries or infrastructure issues). Receiving systems should be idempotent -- processing the same event twice should produce the same result. Use the event + timestamp + data.id combination to detect duplicates.