🎯 Understand the Core Concept
The MidJourney API simulates Discord button interactions. Unlike typical REST APIs, it works as a state machine where each operation returns new buttons for the next step.The 4 Core APIs
| API | Purpose | When to Use |
|---|---|---|
POST /mj/submit/imagine | Text-to-image generation | Starting point for all workflows |
GET /mj/task/\{id\}/fetch | Query task status & get buttons | After every submit (poll until done) |
POST /mj/submit/action | Click a button (upscale, vary, zoom, etc.) | When you want to operate on an image |
POST /mj/submit/modal | Submit additional input | Only when status is MODAL |
📊 Complete Workflow Diagram
🔑 Key Concept: Buttons & customId
Every successful task returns abuttons array. Each button has a customId that you use to trigger the next action.
Example response from /mj/task/\{id\}/fetch:
customId is NOT a fixed value. It changes for every task. Always get it from the buttons array.
📋 Button Reference by Stage
After IMAGINE (4-grid image)
These buttons are returned when your initial image generation completes:| Button | customId Pattern | Action | Result |
|---|---|---|---|
| U1-U4 | MJ::JOB::upsample::1::xxx | Upscale single image | High-res single image |
| V1-V4 | MJ::JOB::variation::1::xxx | Generate variations | New 4-grid |
| 🔄 | MJ::JOB::reroll::0::xxx::SOLO | Regenerate all | New 4-grid |
After UPSCALE (single image)
After upscaling, you get access to editing tools:| Label | Needs Modal? |
|---|---|
| Upscale (Subtle) / Upscale (2x) | ❌ No |
| Upscale (Creative) / Upscale (4x) | ❌ No |
| Vary (Subtle) 🪄 | ❌ No |
| Vary (Strong) 🪄 | ❌ No |
| Vary (Region) 🖌️ | ✅ Yes (mask) |
| Zoom Out 2x / 1.5x 🔍 | ❌ No |
| Custom Zoom 🔍 | ✅ Yes (prompt) |
| ⬅️➡️⬆️⬇️ Pan | ❌ No |
| Animate 🎞️ | ❌ No |
| 🔄 Reroll | ❌ No |
Note: Button labels and⚠️ Inpaint (Vary Region) button only appears after Upscale!customIdformats may vary depending on the MJ version specified in your prompt (e.g.,--v 6.1vs--v 5.2). Always read buttons from the API response.
⚡ Complete Example: Generate & Upscale
Step 1: Submit Imagine Request
Step 2: Poll Task Status
Step 3: Click U1 to Upscale
Step 4: Poll New Task & Get Result
⚠️ When is Modal Required?
When you call/mj/submit/action and the task status becomes MODAL instead of SUCCESS, you must call /mj/submit/modal to provide additional input.
Confirmed Modal Operations
| Operation | Button | What to Submit |
|---|---|---|
| Inpaint | Vary (Region) | maskBase64 (PNG mask) + prompt |
| Custom Zoom | 🔍 Custom Zoom | prompt (e.g., “your prompt —zoom 2”) |
🚀 Speed Mode Selection
Add speed prefix to the path:| Mode | Path Prefix | Example |
|---|---|---|
| Fast | /mj-fast | /mj-fast/mj/submit/imagine |
| Turbo | /mj-turbo | /mj-turbo/mj/submit/imagine |
| Relax | (default) | /mj/submit/imagine |
🔗 Other Entry Points
These APIs are independent entry points that don’t follow the imagine → action flow:| API | Purpose |
|---|---|
POST /mj/submit/blend | Blend 2-5 images into one |
POST /mj/submit/describe | Generate prompt from image |
POST /mj/submit/video | Convert image to video |
POST /mj/submit/edits | Edit image with mask |
❓ Troubleshooting Tips
Based on the API design and workflow, here are common issues you may encounter:| Problem | Likely Cause | Solution |
|---|---|---|
| Can’t find Vary (Region) button | Looking at 4-grid image | Upscale first (click U1-U4), then check buttons |
Task status stuck at MODAL | Operation requires additional input | Call /mj/submit/modal with required data |
customId not working | Using outdated or hardcoded value | Always get fresh customId from /mj/task/\{id\}/fetch response |
Empty buttons array | Task still in progress | Wait for status: "SUCCESS" before accessing buttons |