Skip to main content
Moonshadow webhooks let you receive real-time HTTP callbacks to your server whenever events occur in your workspace. Instead of polling the API for changes, your application gets notified immediately when integrations fire events, automations complete, or other actions trigger.

What Are Webhooks

A webhook is an HTTP POST request that Moonshadow sends to a URL you control. When a subscribed event occurs, Moonshadow packages the event data as JSON and delivers it to your endpoint. This is more efficient than polling because your server only receives data when something actually happens.

Register a Webhook Endpoint

Create a webhook endpoint through the Moonshadow API. You need to provide a target URL and a list of event types to subscribe to.
Response:
string
required
The HTTPS endpoint where Moonshadow sends event payloads.
array
required
List of event types to subscribe to. Use ["*"] to receive all events.
string
required
The workspace that owns this webhook.
string
required
A secret string used to sign webhook payloads for verification.

Webhook Payload Shape

Every webhook payload has a consistent envelope. The data field contains the event-specific details.
string
Unique identifier for this event delivery.
string
The event type that triggered this webhook.
string
ISO 8601 timestamp of when the event occurred.
object
Event-specific data, including the source integration and original payload.

Verify the Signature

Moonshadow signs every webhook payload with HMAC-SHA256 using the secret you provided during registration. Verify the signature to ensure requests come from Moonshadow and have not been tampered with. The signature is sent in the X-Moonshadow-Signature header as a hex string.
Always verify the signature before processing the payload. Never trust unverified webhook requests.

Retries and Failure Handling

Moonshadow expects your endpoint to respond with a 2xx HTTP status code within 30 seconds. If your endpoint fails or times out, Moonshadow retries the delivery with exponential backoff. After 5 failed attempts, Moonshadow marks the delivery as failed and stops retrying. You can view failed deliveries in the Events dashboard and manually retry them if needed. Your webhook endpoint should return a 2xx response immediately after receiving the payload. Do any heavy processing asynchronously to avoid timeouts.
Respond with 200 OK as soon as you validate the signature and queue the event for processing. Handle the business logic in a background worker.

Full Webhook Handler Example

Here is a complete example that receives webhooks, verifies the signature, and handles different event types:

Next Steps

  • Configure Notifications

    Route events to Slack, email, or other channels with notification rules
  • API Rate Limits

    Understand request limits and how to handle rate limiting