Midjourney API 400 Error: Step-by-Step Fixes
Updated 10/27/2026
Because Midjourney does not offer an official public REST API, developers must rely on third-party API gateways, custom Discord bot integrations, or webhook relays to automate image generation. When your integration returns an HTTP 400 Bad Request error, it means the API gateway or Discord's servers rejected your incoming payload because it was malformed, contained invalid syntax, or violated platform limits.
Follow these troubleshooting steps to identify where your payload is breaking and resolve the Midjourney API 400 error.
1. Validate Your Prompt and Flag Syntax The most common cause of a 400 error is a malformed Midjourney prompt string. If your script passes invalid flags or unsupported arguments to the API, the backend parser will reject the request.
- Check double hyphens: Ensure all parameter flags use two hyphens (e.g., --ar 16:9, not -ar 16:9 or —ar 16:9). Smart punctuation conversion on mobile devices or text editors often turns double hyphens into em dashes.
- Verify argument values: Ensure your values match Midjourney's current version capabilities. For example, setting --version 6 or --v 6 is correct, but passing an unsupported version like --v 6.5 will trigger a bad request error.
- Remove conflicting parameters: You cannot combine certain flags. For example, using --test or --creative with incompatible version models will fail. Check Midjourney’s active documentation to ensure your parameters are mutually compatible.
Agent Builder turns a task you repeat into a reusable assistant with setup text for each app.
Tickd is independent and not affiliated with any AI company.
2. Check JSON Payload Formatting and Content-Type Headers If you are sending requests to a third-party API wrapper or a self-hosted Discord interaction script, a syntax error in your JSON payload will trigger an immediate 400 Bad Request.
- Set the correct header: Ensure your HTTP POST request explicitly includes the header Content-Type: application/json.
- Escape special characters: If your prompt text contains double quotes, backslashes, or unescaped control characters, the JSON parser will fail. Ensure your integration code properly serializes the payload using a robust JSON library (such as json.dumps() in Python or JSON.stringify() in JavaScript) rather than manual string building.
- Verify required fields: Ensure you are not missing mandatory fields required by your API wrapper, such as prompt, channelId, guildId, or token.
3. Resolve Discord Interaction Lifecycle Issues If you are interacting directly with the Discord Interaction API to trigger the Midjourney bot `/imagine` command, Discord enforces strict lifecycle rules.
- Respect the 3-second limit: Discord requires an acknowledgement response to slash commands within 3 seconds. If your wrapper or bot takes longer than 3 seconds to defer or respond to the interaction, Discord's gateway will close the channel and return an HTTP 400 error to your server.
- Implement Deferrals: Ensure your code immediately sends an InteractionResponseType 5 (DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE) response to Discord before processing the generation. This buys your application 15 minutes to edit the original response with the completed Midjourney output.
4. Keep Prompts Within Character and Size Limits An exceptionally long payload can exceed maximum buffer limits on either the API gateway or Discord’s webhook endpoints.
- Prompt length: Discord slash commands limit input parameters to 2,000 characters. If your code generates dynamic, highly descriptive prompts that exceed this length, the API gateway will return a 400 Bad Request.
- Image URL payload limits: If you are using image-to-image prompts, keep the input URLs short. Use a URL shortener if your image hosting service generates extremely long query strings.
When to Escalate If you have verified that your JSON payload, prompt syntax, and headers are perfectly formed but continue to receive 400 errors, the issue likely lies with the downstream API gateway.
Check the status page or GitHub repository of the third-party Midjourney API wrapper you are using. Changes to Discord's backend API or updates to the Midjourney slash command schema frequently break unofficial integrations, requiring the wrapper maintainers to release a hotfix.