{
  "openapi": "3.1.0",
  "info": {
    "title": "Submit Editor API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/mj/submit/edits": {
      "post": {
        "summary": "Submit Editor",
        "operationId": "submit_editor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt",
                  "image"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "Text prompt describing the desired edit.",
                    "default": "Change to white background"
                  },
                  "image": {
                    "type": "string",
                    "description": "Image to edit. Pass a public URL or a base64-encoded data URI.",
                    "default": "https://your-image-host/source.png"
                  },
                  "state": {
                    "type": "string",
                    "description": "Custom state string. Returned as-is in the task result and webhook callback for your own tracking."
                  },
                  "notifyHook": {
                    "type": "string",
                    "description": "Webhook URL to receive task status updates. Falls back to your account-level webhook if omitted."
                  },
                  "noStorage": {
                    "type": "boolean",
                    "description": "When `true`, return the original provider image URL instead of a CometAPI-proxied link."
                  }
                },
                "default": {
                  "prompt": "Change to white background",
                  "image": "https://your-image-host/source.png"
                }
              },
              "examples": {
                "Edit by image URL": {
                  "summary": "Edit an existing image referenced by URL (replace the URL with your image)",
                  "value": {
                    "prompt": "Change to white background",
                    "image": "https://your-image-host/source.png"
                  }
                },
                "Edit by base64 image": {
                  "summary": "Edit an inline base64 image. Replace the data URI with your own image data.",
                  "value": {
                    "prompt": "Change to white background",
                    "image": "data:image/jpeg;base64,<your-image-base64>"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "Submission status code. `1` = submitted successfully (`result` carries the task id). `21` = the action opened a confirmation modal; continue with `/mj/submit/modal` using the returned task id. `4` = parameter error; `description` explains the cause."
                    },
                    "description": {
                      "type": "string"
                    },
                    "result": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/mj/submit/edits \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"Change to white background\",\n    \"image\": \"https://your-image-host/source.png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/mj/submit/edits\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n        \"prompt\": \"Change to white background\",\n        \"image\": \"https://your-image-host/source.png\",\n    },\n)\n\ntask = response.json()\nprint(task[\"code\"], task.get(\"result\"))\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\"https://api.cometapi.com/mj/submit/edits\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n        prompt: \"Change to white background\",\n        image: \"https://your-image-host/source.png\",\n    }),\n});\n\nconst task = await response.json();\nconsole.log(task.code, task.result);\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
