Webhook Subscriptions API

Webhook subscriptions let external systems receive Mailrith events for syncs, dashboards, fulfillment, and audit trails. This guide explains when to use webhooks, how to manage subscriptions, why you must store the signing secret immediately, and how receivers should verify and deduplicate deliveries.

7 min read

Subscribe External Systems to Mailrith Events

Webhook subscriptions let an external system receive event notifications from Mailrith. Use webhook subscriptions for CRM updates, internal dashboards, fulfillment systems, audit pipelines, reporting, and workflow tools that need to react when an event happens.

A webhook uses a push model. Instead of polling Mailrith repeatedly, your system exposes an HTTPS endpoint, and Mailrith sends events to that endpoint.

Use a public HTTPS receiver URL. Mailrith does not send webhook events to localhost, private network, link-local, or reserved destinations.

Keep webhook endpoints stable and observable. If your receiver URL or receiver behavior changes, update the Mailrith subscription before you rely on the event stream.

  1. Build and deploy your HTTPS webhook receiver before you create the Mailrith webhook subscription.
  2. Create the Mailrith webhook subscription with the receiver URL and a clear description.
  3. Copy and store the signing secret immediately because Mailrith returns the signing secret only when the subscription is created.
  4. Implement signature verification before your receiver trusts event payloads.
  5. Store received event IDs so duplicate deliveries do not create duplicate downstream work.
  6. Return a success response only after your receiver has accepted the event for processing.
  7. Regularly review webhook subscriptions in API Keys and Authorized Apps or in your internal integration inventory. Confirm each subscription has the correct endpoint, owner, and purpose.
  • Use webhooks when another system needs to react soon after a Mailrith event.
  • Use polling when the external system only needs occasional reporting and does not need event-by-event updates.
  • Store received event IDs so your system can ignore duplicate deliveries safely.
  • Return a successful response only after your receiver has accepted the event for processing.
  • Keep webhook receiver logs private because event payloads may contain workspace or subscriber data.

Endpoint Overview

Use webhook subscription endpoints to list, create, inspect, update, and delete event subscriptions for the authenticated workspace.

POST /v1/webhook-subscriptions creates a subscription and returns the signing secret once. Store the signing secret immediately because your receiver needs the secret to verify that future event deliveries came from Mailrith.

Before you update a subscription, confirm that the new endpoint is deployed and can receive events successfully. Before you delete a subscription, confirm that the downstream system no longer depends on those events.

Create a Webhook Subscription
curl -X POST https://api.mailrith.com/v1/webhook-subscriptions \
  -H "Authorization: Bearer mrk_example_secret_key" \
  -H "Idempotency-Key: crm-webhook-v1" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/mailrith/events",
    "description": "Send Mailrith events to the CRM sync service",
    "enabled": true
  }'

Verify Webhook Delivery

Webhook deliveries are signed. Verify the signature before you trust the event payload. Signature verification protects your endpoint from accepting fake Mailrith events.

Mailrith includes delivery metadata in headers such as webhook-id, webhook-timestamp, and webhook-signature. Use the signing secret returned at subscription creation to verify the signature according to the webhook verification logic used by your receiver.

After verification, process events idempotently. Network retries can deliver the same event more than once, and your receiver must not create duplicate downstream work.

  • Store the signing secret in a secret manager, not in source control.
  • Reject events with missing or invalid signatures.
  • Reject very old timestamps if your receiver enforces a replay window.
  • Use the event ID or delivery ID to deduplicate downstream processing.
  • Return a non-2xx response only when you want Mailrith to consider the delivery failed.

Need Help Shipping an Integration?

Reach the Mailrith team if you need help planning a sync, validating a webhook flow, or troubleshooting a request.

Contact Mailrith

On this page

Jump to the section you need.