SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Error "12300 Invalid Content-Type" for Incoming Webhooks

Issue

When handling incoming calls or SMS webhooks, Twilio may return the error 12300 – Invalid Content-Type. This occurs even when the endpoint returns a 200 OK response, leading customers to believe their webhook is configured correctly.

 

Product

Twilio Programmable SMS
Twilio Programmable Voice
Twilio Webhooks

 

Cause

Twilio requires TwiML in XML format for incoming call and incoming SMS webhook responses. If your application responds with JSON, HTML, or any content type other than XML, Twilio cannot parse the response and raises the 12300 Invalid Content-Type error.

Common problematic responses include:

Content-Type: application/json

{"message":"ok"}

Content-Type: text/html

<body>…</body>

Redirects that result in an HTML response because Twilio is expecting valid XML TwiML, any non-XML content triggers the error.

 

Resolution

Ensure your webhook returns TwiML with a Content-Type of text/xml (or application/xml).

Here is an example using Node.js + Express to return valid XML for SMS:

const express = require('express');
const { twiml: { VoiceResponse, MessagingResponse } } = require('twilio');

const app = express();

app.post('/sms', (req, res) => {
  const response = new MessagingResponse();
  response.message('Thanks for your message!');

  res.type('text/xml');        // MUST RETURN XML
  res.send(response.toString());
});

Key requirements:

  • Set Content-Type to text/xml
  • Return a valid TwiML XML body (e.g., <Response><Message>...</Message></Response>)

Once your webhook returns valid TwiML, Twilio will stop returning the 12300 error.

 

Additional Information 

  • This requirement applies specifically to incoming SMS and Voice webhooks, where TwiML is expected.
  • Outbound status callbacks and event webhooks can safely return JSON.
  • Frameworks like Flask, Express, Laravel, and Ruby on Rails may default to HTML unless explicitly set to XML.
Have more questions? Submit a request
Powered by Zendesk