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

# Midjourney Task Submission

> Submit Midjourney imagine, blend, modal, describe, shorten, swap face, video, and Discord image upload tasks.

# Midjourney Task Submission

The Midjourney submission interfaces all belong to the `/mj/submit/*` group. Different actions use different paths, but the success response style is basically the same.

## Common Response

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 1,
    "description": "Submit success",
    "result": "1712158011464906"
  }
  ```
</ResponseExample>

<ResponseField name="code" type="integer">
  Status code. Common values: `1` submission successful, `22` queued, `23` queue full, `24` prompt may contain sensitive words.
</ResponseField>

<ResponseField name="description" type="string">
  Status description.
</ResponseField>

<ResponseField name="result" type="string | array<string>">
  Task ID. The upload Discord image interface returns an array of image URLs.
</ResponseField>

## Authentication

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Submit Imagine Task

```http theme={null}
POST /mj/submit/imagine
```

Perform the `Imagine` action and submit an image generation task.

```json theme={null}
{
  "mode": "RELAX",
  "prompt": "Cat",
  "base64Array": [
    "data:image/png;base64,xxx1",
    "data:image/png;base64,xxx2"
  ],
  "state": "",
  "notifyHook": ""
}
```

<ParamField body="mode" type="string" required>
  Invocation mode, common values are `RELAX` and `FAST`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Prompt.
</ParamField>

<ParamField body="base64Array" type="array<string>">
  Base64 array for image references.
</ParamField>

<ParamField body="state" type="string">
  Custom parameter.
</ParamField>

<ParamField body="notifyHook" type="string">
  Callback URL.
</ParamField>

## Submit Blend Task

```http theme={null}
POST /mj/submit/blend
```

Perform the `Blend` action and submit an image blending task.

```json theme={null}
{
  "mode": "RELAX",
  "base64Array": [
    "data:image/png;base64,xxx1",
    "data:image/png;base64,xxx2"
  ],
  "dimensions": "SQUARE",
  "botType": "mj",
  "notifyHook": "",
  "state": ""
}
```

<ParamField body="mode" type="string" required>
  Invocation mode, common values are `RELAX` and `FAST`.
</ParamField>

<ParamField body="base64Array" type="array<string>" required>
  Image Base64 array.
</ParamField>

<ParamField body="dimensions" type="string">
  Ratio. Common values: `PORTRAIT`, `SQUARE`, `LANDSCAPE`.
</ParamField>

<ParamField body="botType" type="string">
  Bot type, common values: `mj`, `niji`.
</ParamField>

<ParamField body="notifyHook" type="string">
  Callback URL.
</ParamField>

<ParamField body="state" type="string">
  Custom parameter.
</ParamField>

## Submit Modal Task

```http theme={null}
POST /mj/submit/modal
```

When other tasks return `code = 21` or require additional prompt input, you can call this interface to continue submitting.

```json theme={null}
{
  "taskId": "1712204995849323",
  "maskBase64": "data:image/png;base64,xxx1",
  "prompt": "Cat"
}
```

<ParamField body="taskId" type="string" required>
  Original task ID.
</ParamField>

<ParamField body="maskBase64" type="string">
  Base64 for the partial redraw mask.
</ParamField>

<ParamField body="prompt" type="string">
  New prompt.
</ParamField>

## Submit Describe Task

```http theme={null}
POST /mj/submit/describe
```

Perform the `Describe` action and submit an image-to-text task.

```json theme={null}
{
  "mode": "RELAX",
  "base64": "data:image/png;base64,xxx",
  "botType": "mj",
  "notifyHook": "",
  "state": ""
}
```

<Warning>
  The Apifox example you provided uses the `base64` field; however, the current project DTO explicitly accepts `base64Array`. If the upstream channel requires a single-image `base64`, it is recommended to verify it together with the actual gateway behavior. This document preserves the Apifox invocation style here, but on the project side the main guarantee is that this route exists.
</Warning>

## Submit Shorten Task

```http theme={null}
POST /mj/submit/shorten
```

Perform the `Shorten` action.

```json theme={null}
{
  "mode": "RELAX",
  "prompt": "Cat",
  "botType": "mj",
  "notifyHook": "",
  "state": ""
}
```

## Submit SwapFace Task

```http theme={null}
POST /mj/insight-face/swap
```

Submit a `SwapFace` face-swapping task.

The current project code actually parses it in JSON Base64 format:

```json theme={null}
{
  "sourceBase64": "data:image/png;base64,xxx1",
  "targetBase64": "data:image/png;base64,xxx2"
}
```

<Warning>
  This is different from the `multipart/form-data` file upload example you provided in Apifox. The current gateway code actually validates `sourceBase64` and `targetBase64`; if they are missing, it will return `sour_base64_and_target_base64_is_required`.
</Warning>

## Submit Video Task

```http theme={null}
POST /mj/submit/video
```

The Video interface currently supports two modes:

1. Generate a video directly based on `prompt`
2. Continue generating a video based on an existing `taskId`

```json theme={null}
{
  "mode": "FAST",
  "prompt": "a car",
  "taskId": "1712204995849323",
  "index": 1,
  "motion": "low",
  "image": "url",
  "action": "extend",
  "state": "",
  "notifyHook": ""
}
```

<ParamField body="mode" type="string" required>
  Invocation mode, common values are `RELAX` and `FAST`.
</ParamField>

<ParamField body="taskId" type="string">
  Parent task ID. Used when extending a video based on an existing image.
</ParamField>

<ParamField body="index" type="integer">
  Video index number.
</ParamField>

<ParamField body="motion" type="string">
  Motion intensity, common values: `low`, `high`.
</ParamField>

<ParamField body="action" type="string">
  Video task action. In examples, the common value is `extend`.
</ParamField>

## Upload Files to Discord

```http theme={null}
POST /mj/submit/upload-discord-images
```

Upload images to Discord and return a list of image URLs.

```json theme={null}
{
  "mode": "RELAX",
  "base64Array": [
    "data:image/png;base64,xxx1"
  ]
}
```

```json theme={null}
{
  "code": 1,
  "description": "success",
  "result": [
    "https://cdn.discordapp.com/attachments/..."
  ]
}
```

## Common Local Validation Errors

| Description                | Common Trigger Condition                                                           |
| -------------------------- | ---------------------------------------------------------------------------------- |
| `bind_request_body_failed` | Invalid request body format                                                        |
| `prompt_is_required`       | `prompt` not provided for Imagine                                                  |
| `task_id_is_required`      | `taskId` not provided when continuing an operation based on a task                 |
| `action_is_required`       | `action` missing for continuation-type interfaces                                  |
| `index_is_required`        | `index` missing for continuation-type interfaces                                   |
| `content_is_required`      | `content` missing for simple-change type operations                                |
| `task_not_found`           | The original task does not exist                                                   |
| `task_status_not_success`  | When the original task must be in a successful state, but it has not succeeded yet |
| `quota_not_enough`         | Insufficient balance                                                               |

## Related Interfaces

* [Midjourney Overview](/en/images/midjourney/overview)
* [Midjourney Task Query](/en/images/midjourney/query)
