┌─────────────────────────────────────────────────────────────────────────────┐
│ MIDJOURNEY API WORKFLOW │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐
│ POST /submit/ │ ← Step 1: Submit prompt, get task_id
│ imagine │
└────────┬─────────┘
│ Returns: { "result": "task_id_1" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← Step 2: Poll until status = "SUCCESS"
│ fetch │
└────────┬─────────┘
│ Returns: imageUrl + buttons[] (U1,U2,U3,U4,V1,V2,V3,V4,🔄)
▼
┌──────────────────┐
│ POST /submit/ │ ← Step 3: Click a button using customId
│ action │
└────────┬─────────┘
│ Returns: { "result": "task_id_2" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← Step 4: Poll the new task
│ fetch │
└────────┬─────────┘
│
├─── status = "SUCCESS" → Done! Get imageUrl
│
└─── status = "MODAL" → Need additional input (see Step 5)
│
▼
┌──────────────────┐
│ POST /submit/ │ ← Step 5: Submit mask/prompt for special operations
│ modal │
└────────┬─────────┘
│ Returns: { "result": "task_id_3" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← Step 6: Poll until SUCCESS
│ fetch │
└──────────────────┘