Troubleshooting webhook issues between different environments

3 replies
Last updated: May 30, 2024
Is there a way to see if a webhook was received correctly or failed? I'm seeing webhooks sucessfully being triggered to my local / dev environment but not to my staging environment. Code handling them are the same and I don't see any requests coming through on staging
AI Update

I understand your frustration with webhooks not reaching your staging environment. Unfortunately, Sanity doesn't currently provide a built-in UI for viewing webhook delivery logs or status directly in the dashboard. This makes debugging webhook issues like yours more challenging.

Here's what you can do to troubleshoot:

Debugging Webhook Delivery

1. Test the webhook endpoint directly Use tools like webhook.site or Beeceptor to create a temporary endpoint and update your webhook configuration to point there. This will help you verify that Sanity is actually sending the webhooks.

2. Check your staging endpoint

  • Verify your staging URL is publicly accessible (not behind a firewall or VPN)
  • Ensure it accepts POST requests with JSON payloads
  • Check that SSL/TLS certificates are valid (Sanity webhooks use HTTPS)
  • Look for any authentication requirements that might be blocking the request

3. Monitor webhook attempts on your end Set up logging on your staging server to capture all incoming requests, not just successful ones. This will help you see if requests are arriving but failing.

4. Use Request Logs (Enterprise/Growth plans) If you're on a Growth or Enterprise plan, you can enable Request Logs which will capture webhook delivery attempts. However, this feature delivers logs as NDJSON files rather than a real-time dashboard, and you'll need to filter for webhook-related requests.

Consider Sanity Functions Instead

For your use case, I'd actually recommend considering Sanity Functions instead of webhooks. Functions are the modern, recommended approach for reacting to content changes because:

  • They run directly on Sanity's infrastructure (no external endpoint needed)
  • Built-in monitoring and error logging
  • No need to worry about network issues or endpoint availability
  • Automatic retries on failures
  • Better security (no exposed endpoints)

Functions can handle the same use cases as webhooks but with much better observability. If you need to notify external systems, you can call them from within a Function.

Common Staging Environment Issues

Since your dev environment works but staging doesn't, check:

  • Firewall rules: Staging might have stricter network policies
  • Environment variables: Different webhook URLs configured?
  • Rate limiting: Some hosting providers rate-limit incoming webhooks
  • IP whitelisting: If your staging has IP restrictions, you'll need to allow Sanity's webhook IPs

Without built-in webhook delivery logs, debugging requires checking both ends of the connection. If you continue having issues, consider sharing your webhook configuration and staging setup in the Sanity Community Slack where others might have encountered similar issues.

You can take a look at this section of the docs for debugging tips and how to access your attempt log.
thanks! was able to figure it out. only had create for prod, but create and update for lower environments
Great!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?