Remove Background (Asset)
GET/api/v1/assets/:asset_id/addons/bg_remove
Remove background from an existing asset by asset ID. The original file for the given asset is downloaded and processed.
Behaviour and response type are controlled by the mode and disposition query parameters.
Mode
| Value | Meaning |
|---|---|
get_image | Return the processed PNG only. No save. disposition is ignored. |
save_image | Save the result only. Response is JSON (no PNG). Requires disposition. |
get_image_and_save | Return the PNG and also save in the background. Requires disposition. |
Disposition
| Value | Meaning |
|---|---|
add_conversion | Save the result as a named conversion on the asset identified by {asset_id}. conversion_name controls the conversion key. |
add_new_asset | Save the result as a new asset. Optional: metadata=inherit to copy source asset custom data and set lineage. |
Validation Rules
- If mode is
save_imageorget_image_and_save, disposition is required. - If disposition is
add_conversion, conversion_name must match^[a-zA-Z0-9_-]{1,30}$. - metadata is only allowed when disposition is
add_new_asset. Allowed value:inherit.
Response
- mode =
get_image(default):Content-Type: image/png— PNG bytes in body. - mode =
get_image_and_save:Content-Type: image/png— PNG bytes in body (save happens in background). - mode =
save_image, disposition =add_conversion:\{ "status": "ok", "mode": "save_image", "disposition": "add_conversion", "asset_id": "<id>", "conversion_name": "<name>" \} - mode =
save_image, disposition =add_new_asset:(\{ "status": "ok", "mode": "save_image", "disposition": "add_new_asset", "source_asset_id": "<id>", "metadata": "inherit", "new_asset_id": "<id>" \}source_asset_idandmetadataonly present when provided;new_asset_idwhen save succeeds.)
Request
Responses
- 200
- 400
- 401
- 403
- 500
Successful operation. Response depends on mode:
get_imageorget_image_and_save: PNG image bytes withContent-Type: image/png.save_image: JSON object with save details.
Bad request — invalid mode/disposition/conversion_name; missing required parameters; metadata used with non-add_new_asset disposition; asset not ready.
Unauthorized - Invalid or missing authentication
Forbidden - Insufficient permissions
Internal server error - Processing or save failure