Skip to main content
POST
/
v1
/
edit
Edit Image
curl --request POST \
  --url https://api.legnext.ai/api/v1/edit \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "jobId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "imageNo": 0,
  "canvas": {
    "width": 123,
    "height": 123
  },
  "imgPos": {
    "width": 123,
    "height": 123,
    "x": 123,
    "y": 123
  },
  "remixPrompt": "<string>",
  "callback": "<string>"
}
'
Edit and repaint specific areas of existing images generated by previous tasks.

Endpoint

POST https://api.legnext.ai/api/v1/edit

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key

Request Body

ParameterTypeRequiredDescription
jobIdstringYesID of the original image generation task
imageNointegerYesImage number to edit (0/1/2/3)
canvasCanvasYesTarget canvas dimensions
imgPosCanvasImgYesImage position relative to canvas
remixPromptstringYesText prompt for the edit
maskMaskNoAreas to repaint on the original image
callbackstringNoCallback URL for task completion notifications

Data Types

Canvas

FieldTypeDescription
widthintegerCanvas width in pixels
heightintegerCanvas height in pixels

CanvasImg

FieldTypeDescription
widthintegerImage width in pixels
heightintegerImage height in pixels
xintegerHorizontal offset from canvas top-left
yintegerVertical offset from canvas top-left

Mask

FieldTypeDescription
areasPolygon[]Polygonal areas to repaint (optional)
urlstringBlack and white mask image URL (optional)

Polygon

FieldTypeDescription
widthintegerImage width in pixels (500-4096)
heightintegerImage height in pixels (500-4096)
pointsinteger[]Polygon coordinates in XYXY format, clockwise from top-left

Example Request

curl -X POST "https://api.legnext.ai/api/v1/edit" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jobId": "c6821434-5e41-408f-b42b-2562306b109c",
    "imageNo": 1,
    "canvas": {
        "width": 1024,
        "height": 1024
    },
    "imgPos": {
        "width": 512,
        "height": 512,
        "x": 256,
        "y": 256
    },
    "remixPrompt": "A beautiful landscape with mountains",
    "mask": {
        "areas": [
            {
                "width": 500,
                "height": 500,
                "points": [10, 10, 10, 100, 100, 100, 100, 10]
            }
        ]
    }
  }'

Response

Returns a task object containing the task information.
{
    "job_id": "4017934e-35dd-4640-9585-68c224a66f3b",
    "model": "midjourney",
    "task_type": "edit",
    "status": "completed",
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "",
            "secret": ""
        }
    },
    "input": null,
    "output": {
        "image_url": "https://cdn.legnext.ai/temp/1760422236695.png",
        "image_urls": [
            "https://cdn.legnext.ai/mj/4017934e-35dd-4640-9585-68c224a66f3b_0.png",
            "https://cdn.legnext.ai/mj/4017934e-35dd-4640-9585-68c224a66f3b_1.png",
            "https://cdn.legnext.ai/mj/4017934e-35dd-4640-9585-68c224a66f3b_2.png",
            "https://cdn.legnext.ai/mj/4017934e-35dd-4640-9585-68c224a66f3b_3.png"
        ],
        "seed": "933539835",
        "available_actions": {
            "edit": [
                0,
                1,
                2,
                3
            ],
            "inpaint": [
                0,
                1,
                2,
                3
            ],
            "outpaint": [
                0,
                1,
                2,
                3
            ],
            "pan": [
                0,
                1,
                2,
                3
            ],
            "remix": [
                0,
                1,
                2,
                3
            ],
            "reroll": true,
            "upscale": [
                0,
                1,
                2,
                3
            ],
            "variation": [
                0,
                1,
                2,
                3
            ]
        }
    },
    "meta": {
        "created_at": "2025-10-14T06:09:55Z",
        "started_at": "2025-10-14T06:09:56Z",
        "ended_at": "2025-10-14T06:10:47Z",
        "usage": {
            "type": "point",
            "frozen": 120,
            "consume": 120
        }
    },
    "detail": null,
    "logs": [],
    "error": {
        "code": 0,
        "raw_message": "",
        "message": "",
        "detail": null
    }
}

Authorizations

x-api-key
string
header
required

API key for authentication

Body

application/json
jobId
string<uuid>
required

ID of the original image generation task

imageNo
integer
required

Image number to edit (0, 1, 2, or 3)

Required range: 0 <= x <= 3
Example:

0

canvas
object
required

Target canvas dimensions

imgPos
object
required

Image position relative to canvas

remixPrompt
string
required

Text prompt for the edit

Required string length: 1 - 8192
callback
string<uri>

Callback URL for task completion notifications

Response

200

Edit task created successfully