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.
{
  "id": "job_67890",
  "status": 0,
  "text": "Add a futuristic holographic interface overlay",
  "urls": [],
  "cost": {
    "feeCost": 140,
    "relaxCost": 0
  }
}