Skip to main content
POST
/
v1
/
upload-paint
Advanced Edit with Canvas
curl --request POST \
  --url https://api.legnext.ai/api/v1/upload-paint \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-api-key: <api-key>' \
  --form 'imgUrl=<string>' \
  --form 'canvas={
  "width": 123,
  "height": 123
}' \
  --form 'imgPos={
  "width": 123,
  "height": 123,
  "x": 123,
  "y": 123
}' \
  --form 'mask={
  "areas": [
    {
      "width": 2298,
      "height": 2298,
      "points": [
        123
      ]
    }
  ],
  "url": "<string>"
}' \
  --form 'remixPrompt=<string>' \
  --form 'callback=<string>'
Perform advanced image editing operations using custom uploaded images with precise mask control and canvas positioning.

Endpoint

POST https://api.legnext.ai/api/v1/upload-paint

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key

Request Body

ParameterTypeRequiredDescription
imgUrlstringYesURL of the source image (max length: 1024 characters)
canvasCanvasYesTarget canvas dimensions
imgPosCanvasImgYesImage position and size on canvas
remixPromptstringYesText prompt for the editing operation
maskMaskYesAreas to edit 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 edit (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/upload-paint" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "imgUrl": "https://cdn.legnext.ai/mj/ba5d06e1-5078-4465-adc1-a4264ecdfac7_0.png",
    "canvas": {
        "width": 1024,
        "height": 1024
    },
    "imgPos": {
        "width": 512,
        "height": 512,
        "x": 256,
        "y": 256
    },
    "mask": {
        "areas": [
            {
                "width": 500,
                "height": 500,
                "points": [
                    10,
                    10,
                    10,
                    100,
                    100,
                    100,
                    100,
                    10
                ]
            }
        ]
    },
    "remixPrompt": "A beautiful mountain scene with trees",
    "callback": "https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67"
  }'

Response

Returns a task object containing the task information.
{
    "job_id": "aa7bd9d9-e20d-408d-b031-46cde06ee888",
    "model": "midjourney",
    "task_type": "upload_paint",
    "status": "completed",
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67",
            "secret": ""
        }
    },
    "input": null,
    "output": {
        "image_url": "https://cdn.legnext.ai/mj/aa7bd9d9-e20d-408d-b031-46cde06ee888_grid.png",
        "image_urls": [
            "",
            "https://cdn.legnext.ai/temp/1760683054288.png",
            "https://cdn.legnext.ai/temp/1760683054157.png",
            "https://cdn.legnext.ai/temp/1760683054555.png"
        ],
        "seed": "647656403",
        "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-17T06:37:11Z",
        "started_at": "2025-10-17T06:37:11Z",
        "ended_at": "2025-10-17T06:37:41Z",
        "usage": {
            "type": "point",
            "frozen": 120,
            "consume": 120
        }
    },
    "detail": null,
    "logs": [
        "task aa7bd9d9-e20d-408d-b031-46cde06ee888 0 failed"
    ],
    "error": {
        "code": 0,
        "raw_message": "",
        "message": "",
        "detail": null
    }
}

Authorizations

x-api-key
string
header
required

API key for authentication

Body

multipart/form-data
imgUrl
string<uri>
required

URL of the source image

Maximum string length: 1024
canvas
object
required

Target canvas dimensions

imgPos
object
required

Image position relative to canvas

mask
object
required

Areas to edit on the original image

remixPrompt
string
required

Text prompt for the editing operation

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

Callback URL for task completion notifications

Response

200

Upload paint task created successfully