Skip to main content

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 a buttons 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:

After UPSCALE (single image)

After upscaling, you get access to editing tools:
Note: Button labels and customId formats may vary depending on the MJ version specified in your prompt (e.g., --v 6.1 vs --v 5.2). Always read buttons from the API response.
Inpaint (Vary Region) button only appears after Upscale.

Complete example: Generate and upscale

Step 1: Submit imagine request

Response:

Step 2: Poll task status

Response (when complete):

Step 3: Click U1 to upscale

Response:

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:
Query the new task once. A MODAL status means that the task needs the mask and prompt:
Submit the mask and prompt through the Modal API:

Speed mode selection

Add speed prefix to the path:

Other entry points

These APIs are independent entry points that don’t follow the imagine → action flow:

Troubleshooting tips

Based on the API design and workflow, here are common issues you may encounter:
Last modified on July 31, 2026