> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch (query task)

> GET /mj/task/{id}/fetch — poll a Midjourney task's status

Get a Midjourney task's current status, progress and result-image link.

## Request

```bash theme={null}
curl https://openp.ai/mj/task/1737200000000000/fetch \
  -H "Authorization: Bearer $OPENPAI_API_KEY"
```

## Response

```json theme={null}
{
  "id": "1737200000000000",
  "action": "IMAGINE",
  "status": "SUCCESS",
  "progress": "100%",
  "prompt": "A futuristic cyberpunk city at night",
  "promptEn": "A futuristic cyberpunk city at night, neon lights, --ar 16:9 --v 6",
  "description": "Submit success",
  "submitTime": 1715750400000,
  "startTime": 1715750405000,
  "finishTime": 1715750460000,
  "imageUrl": "https://...",
  "failReason": null,
  "properties": {
    "finalPrompt": "A futuristic cyberpunk city...",
    "messageId": "...",
    "discordChannelId": "..."
  },
  "buttons": [
    {"customId": "MJ::JOB::upsample::1::...", "emoji": "", "label": "U1", "style": 2, "type": 2},
    {"customId": "MJ::JOB::variation::1::...", "emoji": "", "label": "V1", "style": 2, "type": 2}
  ]
}
```

### status values

| Value         | Meaning                               |
| ------------- | ------------------------------------- |
| `NOT_START`   | Not started yet                       |
| `SUBMITTED`   | Submitted, waiting on the upstream    |
| `IN_PROGRESS` | Generating (see the `progress` field) |
| `SUCCESS`     | Succeeded                             |
| `FAILURE`     | Failed                                |

### buttons

After a Midjourney task completes, the clickable Discord buttons (U1-U4, V1-V4, 🔄) are returned as a `buttons` array.
To perform a button's action, use [change](/en/api-reference/midjourney/change) + `customId`.

## Batch query

```bash theme={null}
curl -X POST https://openp.ai/mj/task/list-by-condition \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "ids": ["task1", "task2", "task3"] }'
```

Returns an array of task objects to reduce the number of polling requests.

## Callback vs. polling

* **Callback (notifyHook)**: OpenPAI proactively POSTs to your service when the task status changes — recommended for production.
* **Polling (fetch)**: simple but with latency, suited to local scripts.

Example callback request (POST to notifyHook):

```json theme={null}
{
  "id": "1737200000000000",
  "action": "IMAGINE",
  "status": "SUCCESS",
  "imageUrl": "https://...",
  "state": "<the state passed in at submission>"
}
```
