{
  "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\n"
                    },
                    "description": {
                      "type": "string"
                    },
                    "properties": {
                      "type": "object",
                      "properties": {}
                    },
                    "result": {
                      "type": "integer",
                      "description": "The task ID of the returned task\n"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/mj/submit/modal \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n      \"taskId\": \"<task_id>\",\n      \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\",\n      \"prompt\": \"a small red lantern on the boat\",\n      \"maskBase64\": \"data:image/png;base64,<your-mask-base64>\"\n    }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/mj/submit/modal\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n            \"taskId\": \"<task_id>\",\n            \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\",\n            \"prompt\": \"a small red lantern on the boat\",\n            \"maskBase64\": \"data:image/png;base64,<your-mask-base64>\"\n    },\n)\n\ntask = response.json()\nprint(task[\"code\"], task.get(\"result\"))  # code 1 means submitted; result is the task id\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\"https://api.cometapi.com/mj/submit/modal\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n            \"taskId\": \"<task_id>\",\n            \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\",\n            \"prompt\": \"a small red lantern on the boat\",\n            \"maskBase64\": \"data:image/png;base64,<your-mask-base64>\"\n        }),\n});\n\nconst task = await response.json();\nconsole.log(task.code, task.result); // code 1 means submitted; result is the task id\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
