Midjourney
Create a Midjourney editor task
Use CometAPI Submit Editor API (POST /mj/submit/edits) to edit Midjourney images with maskBase64, prompts, optional originals, and transparent edits.
POST
/
mj
/
submit
/
edits
cURL
curl https://api.cometapi.com/mj/submit/edits \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Change to white background",
"image": "https://your-image-host/source.png"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/mj/submit/edits",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"prompt": "Change to white background",
"image": "https://your-image-host/source.png",
},
)
task = response.json()
print(task["code"], task.get("result"))
const response = await fetch("https://api.cometapi.com/mj/submit/edits", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "Change to white background",
image: "https://your-image-host/source.png",
}),
});
const task = await response.json();
console.log(task.code, task.result);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Change to white background',
'image' => 'https://your-image-host/source.png'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/mj/submit/edits"
payload := strings.NewReader("{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/mj/submit/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"result": "<string>"
}Use this endpoint to edit a Midjourney image with a mask, or to generate a transparent-background result from a prompt plus source image.
Two common modes
- Masked edit: send
maskBase64plusprompt, and optionally the originalimage - Transparent drawing: send
imagepluspromptwhen you want a transparent-background result without a separate mask
Task flow
1
Submit the editor task
Choose the editing mode, send the prompt and source data, then store the returned task id.
2
Poll the task
Use Fetch Single Task until the task reaches a terminal state.
3
Continue from the result
Use the final asset directly, or trigger Action when the edited result exposes follow-up buttons.
Body
application/json
Response
200 - application/json
Success
Last modified on June 23, 2026
⌘I
cURL
curl https://api.cometapi.com/mj/submit/edits \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Change to white background",
"image": "https://your-image-host/source.png"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/mj/submit/edits",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"prompt": "Change to white background",
"image": "https://your-image-host/source.png",
},
)
task = response.json()
print(task["code"], task.get("result"))
const response = await fetch("https://api.cometapi.com/mj/submit/edits", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "Change to white background",
image: "https://your-image-host/source.png",
}),
});
const task = await response.json();
console.log(task.code, task.result);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Change to white background',
'image' => 'https://your-image-host/source.png'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/mj/submit/edits"
payload := strings.NewReader("{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/mj/submit/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Change to white background\",\n \"image\": \"https://your-image-host/source.png\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"result": "<string>"
}