Symptom
When making an API request using Messages API, the request is rejected with an API response "422 Unprocessable Entity" and an error title: Invalid message type ( "detail": "The `message_type` parameter is invalid for the given channel.").
Applies To
- Messages API
Resolution
There are currently two versions of Messages API, version 0 (v0.1) and version 1(v1), please note there are some differences between the two versions as outlined below and if you are using v1 ensure you make the necessary changes in your code for successful API response.
- In version v1 "to" and "from" are single value nodes instead of objects.
- The "channel" object needs to be specified only once in v1.
- The "message" object has been replaced by a "message_type" in v1.
Cause
This error usually occurs if you did not replace your "message" object with "message_type" when using the v1 endpoint. Please see below articles WhatsApp v0.1 to v1 Migration Guide and Messages API Reference for more details on the code changes you need to implement when migrating to v1.
Additional Information
Articles in this section
- WhatsApp Per User Marketing Template Messaging Limits
- Why did I receive rejected status delivery receipts although my WhatsApp messages were delivered to enduser?
- WhatsApp Quality Rating and Messaging Limits
- WhatsApp Platform: Phone Number Limits
- WhatsApp Business Platform Policy Enforcement: Review and Appeal Process for WhatsApp Disabled Account
- WhatsApp Local Data Storage
- Why am I receiving an error "We could not set up your number for the selected API key. Please try a different API key"
- WhatsApp One WABA Policy Enforcement Jan 2024
- WhatsApp Authentication Template Compliance May 2024
- Error code 1022 Template name does not exist in the translation