Sanity Webhook to Discord Returns 400 Error: "Cannot send an empty message
The error you're seeing ("Cannot send an empty message", "code": 50006) from Discord is happening because your webhook is sending an empty payload to Discord's webhook endpoint. Discord webhooks require specific fields like content, embeds, or file to be present - they can't accept completely empty messages.
The issue is almost certainly with your Projection field in the Sanity webhook configuration. When you leave the Projection field blank, Sanity sends an empty body to Discord, which triggers this exact error.
Here's how to fix it:
Add a GROQ Projection
In your webhook configuration in Sanity, you need to add a GROQ projection that formats the data specifically for Discord's API. Discord expects a JSON object with at minimum a content field containing the message text.
Try adding this to your Projection field:
{
"content": "New document: " + ^.name + " (Type: " + ^._type + ")"
}This will send a simple text message to Discord with the document name and type. The ^ syntax refers to the document that triggered the webhook.
More Advanced Example
For richer messages, you can use Discord's embed format:
{
"content": "Content updated in Sanity!",
"embeds": [{
"title": ^.title,
"description": ^.description,
"color": 5814783,
"fields": [
{
"name": "Document Type",
"value": ^._type
}
]
}]
}Important Notes
- Make sure your projection always outputs at least a
contentfield with some text - Test your GROQ projection syntax - invalid GROQ will also cause webhook failures
- You can use webhook.site to test what payload Sanity is actually sending before pointing it at Discord
- The projection runs on the document that triggered the webhook, so make sure the fields you reference (like
title,name, etc.) actually exist on your documents
This is a common gotcha when setting up Discord webhooks with Sanity - Discord is strict about requiring actual message content, and an empty projection means an empty message body! You can read more about how projections work in Sanity webhooks to customize your messages further.
Show original thread7 replies
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.