Quick Start
Creating your first webhook with Moonbase.1. Create an endpoint
Use the Webhooks API to register the webhook endpoint:secret (prefixed with whsec_). Store this secret securely—required to verify incoming webhooks. This is the only time the secret will be shown.
2. Expose an HTTPS route
Webhook endpoints must:- Be publicly accessible via HTTPS
- Accept POST requests with
application/jsoncontent - Respond within 30 seconds to avoid timeouts
3. Verify the signature
Always verify the webhook signature before processing any data. This ensures:- The request genuinely comes from Moonbase
- The payload hasn’t been tampered with
- Protection against replay attacks
- Use the raw request body (before JSON parsing)
- Verify the signature before any other processing
- Reject requests with invalid signatures immediately
4. Process the payload
After successful verification, parse and process the JSON payload.5. Respond promptly
Return a2XX status code (typically 200 or 204) to acknowledge receipt:
- Respond as quickly as possible (within 30 seconds)
- Process time-consuming operations asynchronously
2XX response, it will retry delivery according to the retry schedule.
Configuration
Additional configurations for webhooks.Payload Format
Each payload includes:id: Unique event identifieroccurred_at: ISO 8601 timestamp indicating when the event occurred.type: Event type (e.g.,activity/item_created)- Related objects (item, collection, etc.)
Example Payload
Verifying webhook signatures
Never process webhook data without first verifying its authenticity. Verification ensures that the request came from Moonbase and hasn’t been tampered with.How signatures work
Moonbase uses the Standard Webhooks specification for signing webhooks:- Each endpoint has a unique signing secret (format:
whsec_0{version}{44-char-base58}) - Every webhook request includes an HMAC-SHA256 signature in the
webhook-signatureheader - The signature covers the event ID, timestamp, and raw request body
Security best practices
- Store secrets securely: Use environment variables or a secrets management service—never commit secrets to version control
- Use raw request bodies: The signature is computed on the exact bytes sent—any modification (even whitespace) will cause verification to fail
- Verify timing: Check that the timestamp is recent (within 5 minutes) to prevent replay attacks
- Reject failures: If verification fails for any reason, reject the request with a
400or401status - Log failures: Monitor verification failures as they may indicate security issues
HTTP Headers
Webhook requests include the following Standard Webhooks headers:webhook-id: Event ID (used for idempotency and doesn’t change between retries)webhook-timestamp: Unix timestamp when the request was sentwebhook-signature: HMAC-SHA256 signature for verificationcontent-type:application/json
Delivery and Retry Logic
Moonbase ensures reliable webhook delivery with automatic retries and intelligent backoff strategies.Response handling
The endpoint’s HTTP response determines how Moonbase handles the delivery:| Status Code | Behavior | Notes |
|---|---|---|
2XX | Success | Delivery marked complete, no retries |
410 Gone | Permanent failure | Endpoint automatically disabled, no retries |
429 Too Many Requests | Rate limited | Honors Retry-After header if present |
All other non-2XX | Temporary failure | Automatic retry with exponential backoff |
Retry schedule
Failed deliveries are retried for up to 24 hours using exponential backoff with 10% jitter to prevent thundering herd issues:| Attempt | Delay | Cumulative Time | Notes |
|---|---|---|---|
| 1 | Immediate | 0 seconds | Initial delivery |
| 2 | ~30 seconds | ~30 seconds | 30s + random jitter (0-3s) |
| 3 | ~1 minute | ~1.5 minutes | 60s + random jitter (0-6s) |
| 4 | ~2 minutes | ~3.5 minutes | 120s + random jitter (0-12s) |
| 5 | ~4 minutes | ~7.5 minutes | 240s + random jitter (0-24s) |
| 6 | ~8 minutes | ~15.5 minutes | 480s + random jitter (0-48s) |
| 7 | ~16 minutes | ~31.5 minutes | 960s + random jitter (0-96s) |
| 8 | ~32 minutes | ~1 hour | 1920s + random jitter (0-192s) |
| 9+ | ~1 hour | Varies | 3600s + random jitter (0-360s), capped |
- Maximum individual retry delay: 1 hour
- Total retry window: 24 hours
- Jitter: 10% of base delay to distribute load
- Guaranteed: At least one delivery attempt per hour during the retry window
Handling failures
To minimize failed deliveries:- Respond quickly: Return a
2XXstatus within 30 seconds - Implement idempotency: Use the
webhook-idheader to handle duplicate deliveries - Monitor endpoint: Track success rates and response times
- Use proper status codes: Return
410if the endpoint is permanently decommissioned - Handle rate limits: Return
429withRetry-Afterheader if you need to throttle
Idempotency
Webhooks guarantee at-least-once message delivery. Moonbase includes awebhook-id header containing a unique identifier for each event. This ID remains the same across all retry attempts for a failed webhook, enabling applications to handle duplicate deliveries by tracking processed event IDs.

