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

# Create a Midjourney modal task

> Use POST /mj/submit/modal to submit Midjourney modal output from zoom or area redesign and continue the next image editing step in CometAPI.

## Overview

Submit additional input when an [Action](/api/image/midjourney/action) task returns `status: "MODAL"`. This is required for operations that need extra data, such as inpainting masks or custom zoom prompts.

### When to use

| Operation                   | What to Submit                          |
| --------------------------- | --------------------------------------- |
| **Vary (Region) / Inpaint** | `maskBase64` (PNG mask) + `prompt`      |
| **Custom Zoom**             | `prompt` (e.g., "your prompt --zoom 2") |

<Tip>
  For a complete inpaint flow example, see [Start with Midjourney API](/api/image/midjourney/midjourney-api-quick-start).
</Tip>


## OpenAPI

````yaml api/openapi/image/midjourney/post-modal.openapi.json POST /mj/submit/modal
openapi: 3.1.0
info:
  title: Modal (Area Redesign & Zoom) API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /mj/submit/modal:
    post:
      summary: Modal (Area Redesign & Zoom)
      operationId: modal
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - taskId
                - customId
              properties:
                maskBase64:
                  type: string
                  description: >-
                    Base64-encoded mask image for partial inpainting. White
                    areas are repainted; black areas are preserved.
                prompt:
                  type: string
                  description: >-
                    Text prompt describing the desired change for the selected
                    region.
                taskId:
                  type: string
                  description: >-
                    Task id from the parent task whose modal action you are
                    continuing.
                  default: <task_id>
                customId:
                  type: string
                  description: >-
                    The button `customId` that opened the modal, such as
                    `MJ::Inpaint::1::xxxx::SOLO` from the Vary (Region) button.
                    Required.
              default:
                taskId: <task_id>
            examples:
              Vary Region:
                summary: >-
                  Confirm a Vary (Region) modal. Replace maskBase64 with a PNG
                  mask matching the image size; white marks the area to
                  regenerate.
                value:
                  taskId: <task_id>
                  customId: MJ::Inpaint::1::<custom_id_hash>::SOLO
                  prompt: a small red lantern on the boat
                  maskBase64: data:image/png;base64,<your-mask-base64>
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - description
                  - properties
                  - result
                properties:
                  code:
                    type: integer
                    description: |
                      The status of the task
                  description:
                    type: string
                  properties:
                    type: object
                    properties: {}
                  result:
                    type: integer
                    description: |
                      The task ID of the returned task
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/mj/submit/modal \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "taskId": "<task_id>",
                  "customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
                  "prompt": "a small red lantern on the boat",
                  "maskBase64": "data:image/png;base64,<your-mask-base64>"
                }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            response = requests.post(
                "https://api.cometapi.com/mj/submit/modal",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                        "taskId": "<task_id>",
                        "customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
                        "prompt": "a small red lantern on the boat",
                        "maskBase64": "data:image/png;base64,<your-mask-base64>"
                },
            )


            task = response.json()

            print(task["code"], task.get("result"))  # code 1 means submitted;
            result is the task id
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/mj/submit/modal", {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                        "taskId": "<task_id>",
                        "customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
                        "prompt": "a small red lantern on the boat",
                        "maskBase64": "data:image/png;base64,<your-mask-base64>"
                    }),
            });


            const task = await response.json();

            console.log(task.code, task.result); // code 1 means submitted;
            result is the task id
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````