---
title: "Edit an image using a mask"
method: POST
path: "/v2/workflow/precise-masked-edit"
tags: ["edit-workflow"]
---

# Edit an image using a mask

`POST /v2/workflow/precise-masked-edit`

Applies an instruction using a supplied mask. Optional reference images
can guide the requested appearance. Set `preserve_unmasked_pixels` to
keep decoded pixels outside the mask unchanged in the final image.

The request runs asynchronously. Poll
`GET /v1/generations/{generation_id}` with the returned `generation_id`
until the generation is completed or failed.

## Request body

- PreciseMaskedEditRequest — Exactly one source is normally supplied. Use `source_asset_identifier` for an existing asset or multipart `source_image` bytes. When both are present, `source_asset_identifier` takes precedence.
  - `source_asset_identifier` AssetIdentifier — An identifier for an ideogram asset.
    - `asset_type` 'ASSET' | 'CANVAS_ASSET' | 'LAYERED_ASSET' | 'RESPONSE' | 'UPLOAD', required
    - `asset_id` string, required
  - `source_image` string, binary — Raw source image bytes. Supported formats and the 50 MB limit match the image upload API. Available only with `multipart/form-data`.
  - `mask_asset_identifier` AssetIdentifier, required — An identifier for an ideogram asset.
    - `asset_type` 'ASSET' | 'CANVAS_ASSET' | 'LAYERED_ASSET' | 'RESPONSE' | 'UPLOAD', required
    - `asset_id` string, required
  - `reference_asset_identifiers` AssetIdentifier[] — Optional assets that show the desired appearance of the masked edit.
    - `asset_type` 'ASSET' | 'CANVAS_ASSET' | 'LAYERED_ASSET' | 'RESPONSE' | 'UPLOAD', required
    - `asset_id` string, required
  - `instruction` string, required — Plain-language description of what to change inside the mask.
  - `seed` integer — Optional seed for repeatable results.
  - `num_images` integer — Number of edited images to create.
  - `private` boolean — If true, the user is requesting private generation. If omitted, this defaults to the user's plan entitlement. Enterprise generations are always private.
  - `preserve_unmasked_pixels` boolean — When true, decoded pixels outside the mask are copied from the source image into the final result. When false, the final result is the model's full edited image.
  - `webhook_url` string, uri — HTTPS URL that Ideogram delivers the generated result to. Ideogram sends a JSON POST to this URL once all images for the request have finished generating. The body mirrors the synchronous generate response: `request_id`, `created`, and a `data` array containing every generated image (`url`, `prompt`, `resolution`, `seed`, `is_image_safe`). Each delivery is signed with Ed25519 and verifiable against the public keys at `https://api.ideogram.ai/v1/.well-known/jwks.json`. Must be HTTPS; private and loopback hosts and the cloud metadata service are rejected.

## Response `200`

Precise masked edit accepted for asynchronous processing.

- PreciseMaskedEditResponse — Acknowledgement that the workflow was accepted.
  - `generation_id` string, required — URL-safe base64 ID accepted by the generation polling endpoint.

## Other responses

- `400` — Invalid input provided.
- `401` — Unauthorized.
- `402` — Insufficient credits or quota.
- `403` — Not authorized to use precise masked editing.
- `404` — An input asset was not found or is not readable.
- `429` — Too many requests.
- `503` — Precise masked editing is temporarily unavailable.

---

[API](https://skmtc.net/ideogram/apis/ideogram-openapi-3-0.md) · [All operations](https://skmtc.net/ideogram/apis/ideogram-openapi-3-0/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ideogram/ideogram-openapi-3-0/revisions/898026c78d68/schema)
