---
title: "Erase Foreground"
method: POST
path: "/erase_foreground"
tags: ["v2 endpoints"]
---

# Erase Foreground

`POST /erase_foreground`

[**Try out this capability in Bria's sandbox**](https://platform.bria.ai/image-editing/erase-foreground)



**Description**



The **Erase Foreground** endpoint removes the primary subject (foreground) from the input image and intelligently generates the background to fill the erased area.  

**Output Characteristics**  
- Returns the edited image at its original resolution, ensuring full visual fidelity without any automatic resizing or downscaling.  
- Only the foreground is removed; all other areas remain unaltered, preserving pixel-perfect accuracy in untouched regions.  
- When `preserve_alpha=true` and the input image includes an alpha channel, the output maintains original transparency values (both full and partial).  




 **Content Moderation**

This endpoint includes granular content moderation controls to ensure safe usage across all stages of processing:

- **Input Image Moderation** – Scans the uploaded image and stops processing if inappropriate or restricted content is detected.
- **Output Image Moderation** – Evaluates the generated image and blocks the response if it violates safety guidelines.

## Headers

- `api_token` string, required

## Request body

- object
  - `image` string, required — The image that you would like to remove the background from. Supported input types: - **Base64-encoded string** - **URL** pointing to an image file that is publicly accessible and available at the time of processing. Accepted formats: **JPEG**, **JPG**, **PNG**, **WEBP**.
  - `preserve_alpha` boolean — Controls whether the alpha channel values from the input image are retained in the output, if the input includes an alpha channel. - When true: The output image maintains the original transparency of fully and partially transparent pixels. - When false: The output image is fully opaque. - Has no effect if the input image does not include an alpha channel.
  - `sync` boolean — Specifies the response mode. - When `false` (default), the request is processed asynchronously: the API immediately returns a status URL to track progress. - When `true`, the request is processed synchronously: the API hold the connection open until the proccess is complete and then returns the final image URL in the response.
  - `webhook_url` string, uri — Optional URL for receiving the result via webhook when the async job completes. See [Webhooks](https://docs.bria.ai/webhooks).
  - `visual_input_content_moderation` boolean — When enabled, applies content moderation to input visual. Expected behavior: - Processing stops if the image fails moderation. - Returns a 422 error with details about which parameter failed.
  - `visual_output_content_moderation` boolean — When enabled, applies content moderation to result visual. Expected behavior: - If the modified image fails moderation, returns a 422 error.

## Response `200`

Successful operation (Synchronous Success)

- SyncSuccessResponse
  - `result` object, required
    - `image_url` string, required
  - `request_id` string, required

## Other responses

- `202` — Accepted (Asynchronous). You can track the progress and retrieve the final result using the Status Service. For more details, refer to the [Status Service](https://docs.bria.ai/status) section.
- `400` — Bad request.
- `401` — Unauthorized.
- `403` — Forbidden.
- `404` — Not found. Image could not be found at the provided URL.
- `415` — Unsupported media type.
- `422` — Unprocessable Entity
- `429` — Request limit exceeded.
- `460` — Failed to download image.
- `5XX` — **Internal Server Error** – A critical failure occurred in Bria's infrastructure, preventing the Status Service from responding. - This response indicates a service outage or unexpected runtime failure. - Check [Bria's Status Page](https://status.bria.ai) for real-time updates. - Contact [Support](mailto:support@bria.ai).

---

[API](https://skmtc.net/bria-ai/apis/image-editing-api-reference.md) · [All operations](https://skmtc.net/bria-ai/apis/image-editing-api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bria-ai/image-editing-api-reference/versions/53e73f49bf9f/schema)
