Midjourney API Request Failed: How to Resolve
Updated 10/9/2026
Because Midjourney does not offer an official, publicly documented REST API, developers and teams automate generation workflows using unofficial third-party API providers, custom Discord bots, or Discord Gateway API integrations. When these connections break, it usually results in failed requests, HTTP error codes, or unfulfilled webhooks.
Use this practical guide to isolate where the API request is failing and restore your automated Midjourney image generation workflow.
1. Verify Discord Gateway and Session Token Validity If your script or third-party service interacts with Discord to trigger Midjourney (via slash commands like `/imagine`), the connection relies heavily on active user tokens or bot authorization.
- Check for Token Invalidation: Discord user tokens (used in self-botting setups) rotate frequently. If you receive an HTTP 401 Unauthorized or 403 Forbidden error, print your authorization headers and verify that the token has not expired or been revoked.
- Inspect the Discord Channel ID: Ensure the target Discord Channel ID and Guild ID configured in your API call are correct. If the bot or user account was kicked from the server or lost write/view permissions for that channel, the API request will fail immediately.
- Test Command Authorization: Manually log into the Discord account or bot environment and attempt to run a /imagine prompt in the designated channel. If it fails manually, your automated API script will also fail.
2. Format JSON Payloads Correctly Midjourney parameters must be formatted precisely. Sending incorrect data types or invalid parameter flags in your payload will cause the Discord interaction or third-party API gateway to throw a `400 Bad Request` or silently fail.
- Check Parameter Syntax: Ensure there are no double hyphens on unsupported parameters or trailing spaces. For example, use --ar 16:9 (not --ar 16-9 or --aspect 16 : 9).
- Sanitize Prompt Inputs: Strip any special characters, line breaks, or system control characters from user-generated prompts before appending them to your payload.
- Validate Version Flags: If your payload specifies a version (e.g., --v 6), ensure it matches the current supported versions. Combining incompatible parameters (like --tile with certain older model versions) will result in a payload rejection.
3. Handle Rate Limits and Implement Exponential Backoff If your API script sends requests too rapidly, Discord or your third-party API provider will return an HTTP `429 Too Many Requests` error. Midjourney accounts also have strict concurrency limits (usually a maximum of 3 to 15 fast jobs running simultaneously depending on the plan).
- Implement a Request Queue: Do not send requests concurrently without limit. Build a queue mechanism in your SDK or script that limits concurrent generations to match your Midjourney subscription tier.
- Apply Exponential Backoff: When your application detects an HTTP 429 status code, parse the Retry-After header if available. If not, pause the thread or loop, doubling the wait time on each consecutive failure (e.g., pause 2s, then 4s, then 8s) before retrying.
- Monitor Discord Rate Limits: Discord limits gateway interactions. Ensure your script listens to rate limit headers in the Discord API response to prevent temporary IP bans.
4. Resolve Webhook and Callback Failures Most Midjourney API setups run asynchronously. You send a prompt request, and the API calls your webhook URL once the image generation is complete. If you aren't receiving images, your callback listener is likely failing.
- Verify Your Server's Public URL: Ensure your webhook listener URL is publicly accessible and not blocked behind a local firewall, VPN, or local development host (use tools like ngrok for local testing).
- Check Port and Protocol: Ensure your listener accepts HTTPS requests on standard ports (443). Many third-party APIs refuse to send webhooks to unencrypted HTTP addresses.
- Respond with HTTP 200 OK: Your webhook endpoint must immediately return an HTTP 200 OK or 201 Created status upon receiving the payload. If your server takes too long to process the image and delays its response, the API provider will timeout and flag your webhook as dead.
5. Bypass Cloudflare and Cloud-Hosted IP Blocks Discord uses aggressive Cloudflare protection. If you are hosting your API integration script on popular cloud providers (AWS, DigitalOcean, Heroku), Discord's security systems may flag and block the hosting IP ranges, resulting in persistent timeouts or HTTP `403` errors.
- Route Through Proxies: Configure your HTTP client (e.g., Axios, Python Requests) to route traffic through residential or high-quality rotating proxies.
- User-Agent Spoofing: Ensure your request headers include a valid, modern browser User-Agent string rather than the default library identifier (like python-requests/2.x or Go-http-client).
When to escalate Because Midjourney does not offer an official public API, Midjourney's official Discord support team will not help debug API scripts, SDKs, or third-party wrappers.
If you are using a commercial third-party Midjourney API wrapper, check their status page or open a ticket directly with their technical support. If you are self-hosting your integration, check the Discord Developer Portal Status page to confirm if the Discord API itself is experiencing global downtime.