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
Complete workflow diagram
Key concept: Buttons and 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:
Button reference by stage
After IMAGINE (4-grid image)
These buttons are returned when your initial image generation completes:After UPSCALE (single image)
After upscaling, you get access to editing tools:Note: Button labels andcustomIdformats 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 and upscale
Step 1: Submit imagine request
Step 2: Poll task status
Step 3: Click U1 to upscale
Step 4: Poll new task and 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
Example: Inpaint Flow
Start the Inpaint action:
MODAL status means that the task needs the mask and prompt: