David - Musings of an SRE

AWS SNS Webhooks: Stop fighting text/plain and use application/json instead

If you’ve ever worked with Amazon SNS and subscribed an HTTP/HTTPS endpoint, you’ve probably hit this gotcha:

SNS sends you a JSON payload… but sets the Content-Type header to text/plain.

🤨 Why Is That a Problem?

When SNS sends messages like SubscriptionConfirmation or Notification, the body is valid JSON. But since the header says text/plain, most web frameworks (like Rails, Django, Express, etc.) don’t parse it into params or req.body.

So instead of:

params["SubscribeURL"]

You’re stuck doing:

body = request.body.read
json = JSON.parse(body)
json["SubscribeURL"]

📦 Example SNS Payload

POST /webhook HTTP/1.1
Content-Type: text/plain; charset=UTF-8

{
  "Type": "SubscriptionConfirmation",
  "SubscribeURL": "https://sns.us-east-1.amazonaws.com/..."
}

✅ The Fix: Use application/json for SNS Webhooks

Since 2023, AWS finally allows you to change the content type for SNS HTTP(S) subscriptions to application/json 🎉

According to the official AWS documentation:

“You can configure Amazon SNS to send POST messages with a content type of either application/json or text/plain.”

🔧 How to Enable It (via AWS Console)

  1. Go to your SNS Topic in the AWS Console
  2. Click on the Subscriptions tab
  3. Find your HTTPS endpoint and click Edit
  4. Under Delivery Policy (HTTP/S), set “Content-Type” to application/json
  5. Save your changes

Going forward, SNS will now send webhooks with:

Content-Type: application/json

🚀 Conclusion

Amazon SNS has historically defaulted to text/plain, which made JSON payloads a pain to work with. But now, thanks to a long-awaited update, you can make it send real application/json — and your webhooks will just work™️.

If you’re building an SNS webhook, switch the content-type early, save yourself the parsing trouble, and get clean params from day one.

References

🔒 Want Better Webhook Dev Tools?

If you’re tired of debugging webhook payloads like SNS manually, you’re going to love what we’re building.

Relaye.io is a modern webhook gateway and debugger built for developers — with features like:

  • 💡 Real-time payload inspection
  • 🔁 Replay failed requests
  • 🔒 Secure endpoints for dev and prod
  • 🌍 Support for AWS SNS, Stripe, GitHub, and more

We’re currently in private beta — and we’d love your feedback.

👉 Join the waitlist at relaye.io to get early access!