POST/inpaint4 creditsMidjourney only

Inpaint (Vary Region)

Regenerate a specific region of an upscaled Midjourney image while keeping the rest intact. You provide a black-and-white mask (white = regenerate, black = preserve) and an optional prompt for what to fill in. Ideal for fixing faces, swapping objects, adding elements, or cleaning up backgrounds. Returns a new 2×2 grid of inpainted variations to choose from. Requires a prior /upscale-1x task as parent. Midjourney only.

Request Parameters

ParameterTypeRequiredDescription
parent_task_idstringRequiredTask ID of the image to inpaint.
maskstringRequiredBase64-encoded mask image. White areas will be regenerated, black areas preserved.
promptstringOptionalOptional prompt for the masked region. If omitted, Midjourney decides what to fill in.
webhook_urlstringOptionalURL where we POST the completed task result.
webhook_secretstringOptionalSent as x-webhook-secret header in webhook delivery.

Example Request

cURL
curl -X POST https://api.journeyapi.com/api/v1/inpaint \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "parent_task_id": "772a0622-a41d-63f6-c938-668877662222",
    "mask": "iVBORw0KGgoAAAANSUhEUg...",
    "prompt": "a golden crown",
    "webhook_url": "https://your-server.com/webhook"
  }'

Immediate Response

Returns immediately with a task ID. Use /fetch or webhooks to get the result.

200 OK
{
  "task_id": "bb6e4a66-e85h-07j0-g372-002211006666"
}

Response Fields

FieldTypeDescription
task_idstringUUID of the inpaint task.
task_typestringAlways "inpaint".
original_image_urlstringURL of the new 2×2 grid with inpainted results.
image_urlsstring[]Array of 4 individual image URLs.

Tips

  • 1The mask must be the same dimensions as the parent image.
  • 2White = regenerate, black = keep. Use a simple black/white PNG.
  • 3Send the mask as raw base64 without the data:image/png;base64, prefix.
  • 4The parent_task_id must be from /upscale-1x. Inpaint (Vary Region) is only available on upscaled images, not grids.

Quirks & Gotchas

Inpaint produces a new 2×2 grid of variations for the masked area, not a single image.

If the mask covers too small an area, Midjourney may ignore it or produce minimal changes.

Passing a grid task ID (from /imagine or /reroll) as the parent will fail. You must upscale with /upscale-1x first.

Expert Tips & Best Practices

Mask creation tips

Use simple white rectangles for the area to regenerate — avoid complex or feathered shapes. Midjourney reads the mask as binary (white vs. black), so gradients don't add precision. For faces, mask the entire face region with some padding rather than trying to isolate individual features. For backgrounds, mask everything except the foreground subject. Create masks in any image editor (Photoshop, Figma, even MS Paint) and export as PNG.

Use cases: faces, objects, backgrounds

Inpaint excels at three tasks: (1) Fixing faces that look distorted or off — mask the face and let Midjourney regenerate it with the same prompt. (2) Adding or swapping objects — mask the target area and add a specific prompt for what to place there. (3) Cleaning up or changing backgrounds — mask the background and prompt for a new scene while preserving the foreground subject exactly.

Related Endpoints