Midjourney API Invalid Request Error: How to Fix
Updated 10/19/2026
If you are building custom integrations, Discord bots, or utilizing third-party wrappers to automate Midjourney, encountering an "invalid request" or HTTP 400 Bad Request error is a common roadblock. Because Midjourney does not offer an official public REST API, most automated workflows rely on Discord’s interactions API (slash commands) or self-hosted API gateways.
An invalid request error indicates that your endpoint sent data that the receiving server (either Discord or your API wrapper) could not interpret. Below is a structured, step-by-step troubleshooting guide to resolve this issue and restore your generation pipeline.
1. Verify and Sanitize Prompt Parameters The most common cause of an invalid request is malformed syntax inside the `prompt` string payload. Midjourney is highly sensitive to parameter formatting.
- Check Double Hyphens: Ensure all parameters use two hyphens (--ar 16:9, not —ar 16:9 or -ar 16:9). Text editors often auto-correct double hyphens into em-dashes.
- Remove Unsupported Combinations: Ensure you are not combining incompatible parameters. For example, --stylize values must fall between 0 and 1000, and --tile is not supported with certain model versions.
- Check Parameter Types: If you are passing parameters via JSON keys in a wrapper, ensure numeric values are passed as numbers (e.g., 16 and 9 for aspect ratios) and not as raw strings unless the wrapper specifically requires it.
2. Validate JSON Payload Structure If you are calling Discord’s interaction endpoint (`https://discord.com/api/v10/interactions`) directly to trigger the `/imagine` command, your JSON payload must strictly match Discord’s gateway schema. A single missing field will trigger an invalid request error.
Ensure your JSON payload includes the following structure: * type: Must be set to 2 (Application Command). * application_id: Must match Midjourney’s official application ID (936929561302675456). * guild_id and channel_id: Must be valid snowflakes (strings) representing a server and channel where the Midjourney bot is present. * data: Must contain the command metadata, including the command name (imagine) and an options array containing your input string.
Example of a correct payload structure: `json { "type": 2, "application_id": "936929561302675456", "guild_id": "YOUR_GUILD_ID", "channel_id": "YOUR_CHANNEL_ID", "session_id": "YOUR_SESSION_ID", "data": { "version": "1234567890", "id": "938101452914757632", "name": "imagine", "type": 1, "options": [ { "type": 3, "name": "prompt", "value": "a futuristic city skyline --ar 16:9" } ] } } `
3. Check for Discord API Schema Changes Discord frequently updates its gateway version and command schemas. If your script uses hardcoded command version IDs or application IDs, these may have become deprecated.
- Fetch Active Commands: Periodically query Discord’s application commands endpoint to fetch the current version ID of the /imagine command. Do not rely permanently on hardcoded version IDs.
- Update API Version: Ensure your request headers and endpoints use an active API version (e.g., /api/v10 or /api/v9). Obsolete API versions will return hard 400 Bad Request errors.
4. Inspect Request Headers and Content-Type Malformed request headers will prevent your payload from being parsed correctly.
- Content-Type: Ensure your request headers explicitly declare Content-Type: application/json.
- Authorization Token: Ensure your bot token or user token is formatted correctly. User tokens should be sent as raw strings in the Authorization header, while bot tokens must be prefixed with Bot (e.g., Authorization: Bot <token>).
- User-Agent: Some API gateways block requests with missing or generic user-agents. Set a recognizable User-Agent header in your HTTP client.
5. Verify Bot Permissions and Channel Access An invalid request can occur if your integration attempts to run commands in a channel where it lacks authorization.
- Channel Permissions: Ensure the executing account has the "Use Application Commands", "Send Messages", and "View Channel" permissions in the target Discord channel.
- Direct Messages (DM): If you are attempting to trigger Midjourney in DMs, ensure your direct message settings permit interactions from bot accounts, or switch to a dedicated guild channel for more reliable operations.
When to Escalate If you are utilizing a third-party Midjourney API wrapper service and continue to receive invalid request errors despite matching their documentation, the issue likely stems from upstream changes in Discord or the wrapper provider's server. Check your provider's status page or API changelog. For custom implementations, consult the Discord Developer Portal documentation to verify if any breaking changes have been introduced to the interactions endpoint.
Related Midjourney help
Set up your AI once so you repeat yourself less.
Try AI Setup ProfileTickd is independent and not affiliated with any AI company.