Sanity Webhooks POST requests received without body

18 replies
Last updated: Aug 5, 2021
Hello everyone,
I’m having a problem with Sanity Webhooks.
I’m receiving a Post as expected but without a body.
This started to happen yesterday (08/03/2021).
My Node application is hosted on Vercel, so the first thing I did was to remove Vercel from the problem, and for this, I created an Express locally and with ngrok, I added on sanity.

With this I’m receiving normally the requests but without the body equal on Vercel environment.
Anyone here is having this same issue?
What can I do to solve this problem?
AI Update

I can see you're experiencing an issue where Sanity webhooks are delivering POST requests but with empty bodies. This is a common problem that's typically related to how the webhook payload is being parsed in your application.

The most likely cause is missing or incorrect body parsing middleware in your Express/Node application. Sanity webhooks send their payload with a specific content type that requires proper parsing.

Here's what you need to check:

1. Add the correct body parser middleware

Sanity webhooks send data as application/json, so you need to ensure your Express app is configured to parse JSON bodies:

const express = require('express');
const app = express();

// This is crucial - add BEFORE your webhook route
app.use(express.json());

app.post('/webhook', (req, res) => {
  console.log(req.body); // Should now contain the webhook payload
  res.status(200).send('OK');
});

2. For Vercel serverless functions

If you're using Vercel serverless functions (API routes), the body parsing works differently. Make sure you're not disabling the default body parser:

// api/webhook.js
export default function handler(req, res) {
  if (req.method === 'POST') {
    console.log(req.body); // Vercel parses JSON automatically
    res.status(200).json({ received: true });
  }
}

3. Check your webhook configuration in Sanity

Make sure your webhook in the Sanity management console is properly configured to send the payload. The webhook should be sending a JSON payload by default.

4. Verify the Content-Type header

Sanity webhooks typically send with Content-Type: application/json. If your middleware is expecting a different content type, it might skip parsing the body. You can log the headers to verify:

app.post('/webhook', (req, res) => {
  console.log('Headers:', req.headers);
  console.log('Body:', req.body);
  res.status(200).send('OK');
});

Why this might have "started yesterday"

If this suddenly started happening on March 8, 2021, it's possible that:

  • A deployment changed your middleware configuration
  • Dependencies were updated (check if body-parser or express versions changed)
  • The webhook configuration in Sanity was modified

Since you're seeing the same issue both on Vercel and locally with ngrok, this strongly suggests the issue is in your application code rather than the hosting environment.

Make sure express.json() or equivalent body parsing middleware is added before your webhook route handler, and that should resolve the empty body issue.

Show original thread
18 replies
Yes, this is still happen with new webhook.
If you run
sanity hook logs --detailed
in your terminal, do you see a payload?
If you run
sanity hook logs --detailed
in your terminal, do you see a payload?
user A
I did some tests here and Sanity is not sending the Content-Length header in the request, with seems to be mandatory for Vercel to parse the body using their helper.
Interesting. I tested on webhook.site and that header was sent. Can one of you DM your project ID? I’ll do what I can to get this resolved.
Sure. it is tgw6qmr7
Thanks. That’s been passed along.
Thanks. That’s been passed along.
if it helps, these are the headers that I’m receiving on Vercel:
{
    headers: {
        host: '<http://test-ochre-five.vercel.app|test-ochre-five.vercel.app>',
        'content-type': 'application/json',
        'x-real-ip': '34.78.88.4',
        'x-forwarded-host': '<http://test-ochre-five.vercel.app|test-ochre-five.vercel.app>',
        'x-vercel-forwarded-for': '34.78.88.4',
        'x-vercel-deployment-url': '<http://test-ip6v1crs4-businessloans.vercel.app|test-ip6v1crs4-businessloans.vercel.app>',
        'x-vercel-ip-country': 'BE',
        'x-vercel-ip-country-region': 'BRU',
        'x-forwarded-for': '34.78.88.4',
        'x-forwarded-proto': 'https',
        'transfer-encoding': 'chunked',
        'x-vercel-ip-city': 'Brussels',
        'x-vercel-id': 'cdg1::nbmj7-1628138209268-de345b460a33',
        connection: 'close'
    },
    body: {}
}
Can you confirm that you are not receiving the body in any webhook delivery?
user L
I’m working with
user A
and I can confirm that since 2-days ago we are not recieving body in any Webhook delivered.
We found an issue with the JavaScript library used for HTTP requests, are working on a fix
Thanks
user L
, do you have any ETA to this be on production?
user R
Thanks in advance for your work. For now seems to be work again, I will keep a close eye on this for the rest of day and if anything happens I will warn you guys again. Thanks again!
user R
and
user A
thank you for your support in this case. The webhooks are working again.
user R
and
user A
thank you for your support in this case. The webhooks are working again.
Thanks for you too
user L
. Great work guys!
Thank you guys, I was tearing my hair out over this as well

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?