---
title: "Remove the background of an image"
method: POST
path: "/removebg"
tags: ["Background Removal"]
---

# Remove the background of an image

`POST /removebg`

Removes the background of a JPG/PNG/WebP image.

* File size: up to 22 MB
* Input resolution: up to 50 megapixels
* Image source: File upload (binary or as base64 encoded string) or download from URL
* Image Content: Any photo with a foreground [(e.g. people, products, animals, cars, etc.)](/supported-images)
* Output resolutions available: Preview (up to 0.25 megapixels), Full (up to 25 megapixels), 50MP (up to 50 megapixels)

Requires either an API Key to be provided in the `X-API-Key` request header or an OAuth 2.0 access token to be provided in the `Authorization` request header.

## Request body

- RemoveBgJson
  - `image_file_b64` string — Source image file (base64-encoded string). (If this parameter is present, the other image source parameters must be empty.)
  - `image_url` string — Source image URL. (If this parameter is present, the other image source parameters must be empty.)
  - `size` 'preview' | 'full' | 'auto' — Maximum output image resolution: - **"preview"** (default) = Resize image to 0.25 megapixels (e.g., 625×400 pixels) – 0.25 credits per image - **"full"** = Use original image resolution, up to 25 megapixels (e.g., 6250×4000) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image - **"50MP"** = Use original image resolution, up to 50 megapixels (e.g., 8000×6250) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image - **"auto"** = Use highest available resolution, up to 25 megapixels (e.g. 6250×4000) (based on image size and available credits). For backwards-compatibility this parameter also accepts the values "medium" (up to 1.5 megapixels) and "hd" (up to 4 megapixels) for 1 credit per image. The value "full" is also available under the name "4k" and the value "preview" is aliased as "small" and "regular".
  - `type` 'auto' | 'car' | 'product' | 'person' | 'animal' | 'graphic' | 'transportation' — Detect or set a foreground **type**. We recommend using **type = auto** to automatically detect the **type** of foreground. To specify only one type of foreground, set **type** to one of these values:<br> **car, product, person, animal, graphic, transportation**.
  - `type_level` string — Classification level of the detected foreground type: - **"none"** = No classification (X-Type Header won't bet set on the response) - **"1"** = Use coarse classification classes: [person, product, animal, car, other] - **"2"** = Use more specific classification classes: [person, product, animal, car, car_interior, car_part, transportation, graphics, other] - **"latest"** = Always use the latest classification classes available
  - `format` 'auto' | 'png' | 'jpg' | 'zip' | 'webp' — Result image format: - **"auto"** = Use PNG format if transparent regions exist, otherwise use JPG format (default), - **"png"** = PNG format with alpha transparency, - **"webp"** = WebP format with alpha transparency, - **"jpg"** = JPG format, no transparency, - **"zip"** = ZIP format, contains color image and alpha matte image, supports transparency (recommended for fastest processing).
  - `roi` string — Region of interest: Only contents of this rectangular region can be detected as foreground. Everything outside is considered background and will be removed. The rectangle is defined as two x/y coordinates in the format "x1 y1 x2 y2". The coordinates can be in absolute pixels (suffix 'px') or relative to the width/height of the image (suffix '%'). By default, the whole image is the region of interest ("0% 0% 100% 100%").
  - `crop` boolean — Whether to crop off all empty regions (default: false).<br> _Note_: Cropping has no effect on the amount of charged credits.
  - `crop_margin` string — Adds a margin around the cropped subject (default: 0). Can be an absolute value (e.g. "30px") or relative to the subject size (e.g. "10%"). Can be a single value (all sides), two values (top/bottom and left/right) or four values (top, right, bottom, left). This parameter only has an effect when "crop=true". The maximum margin that can be added on each side is 50% of the subject dimensions or 500 pixels.
  - `scale` string — Scales the subject relative to the total image size. Can be any value from "10%" to "100%", or "original" (default). Scaling the subject implies "position=center" (unless specified otherwise).
  - `position` string — Positions the subject within the image canvas. Can be "original" (default unless "scale" is given), "center" (default when "scale" is given) or a value from "0%" to "100%" (both horizontal and vertical) or two values (horizontal, vertical).
  - `channels` 'rgba' | 'alpha' — Request either the finalized image ("rgba", default) or an alpha mask ("alpha").<br> _Note_: Since remove.bg also applies RGB color corrections on edges, using only the alpha mask often leads to a lower final image quality. Therefore "rgba" is recommended.
  - `add_shadow` boolean — Warning: **add_shadow** is deprecated and will be removed in the next major release, version 2.0. Please use **shadow_type** instead.<br> Setting **add_shadow = true** will set the **shadow_type** parameter to **shadow_type [car] = car**. A **car** shadow will only be generated if the foreground type is detected or specified as **car**.
  - `shadow_type` string — Generate shadows based on your foreground **type**. remove.bg supports four different shadow types: [**car, 3D, drop, none**](/help/a/enhance-your-images-with-the-ai-shadow-feature). Use **shadow_type = auto** to automatically assign the most suitable **shadow_type** for each foreground **type**. See the default assignments below. Use **shadow_type = $shadow_type** to specify a single type of shadow for all foreground types. Replace **shadow_type = auto** with **shadow_type [$type] = $shadow_type** to assign specific shadow types per foreground **type**. Unmentioned foreground **type(s)** will return no shadow. Default assignments:<br> **shadow_type [car] = car,**<br> **shadow_type [product] = drop,**<br> **shadow_type [person] = 3D,**<br> **shadow_type [animal] = drop,**<br> **shadow_type [transportation] = 3D,**<br> **shadow_type [graphic] = drop,**<br> **shadow_type [other] = drop**
  - `shadow_opacity` string — Set a shadow's opacity, i.e. darkness. Can be set to any value from **0** (lightest) to **100** (darkest) or auto for default values, shown below. **shadow_opacity = n (0 - 100), auto** Replace **shadow_opacity = auto** with **shadow_opacity [$type] = $n** to assign specific opacity values per foreground **type**. Unmentioned foreground type(s) with set shadows will fall back on default opacity assignments. Default values:<br> **shadow_opacity [car] = 90**<br> **shadow_opacity [product] = 50**<br> **shadow_opacity [person] = 50**<br> **shadow_opacity [animal] = 50**<br> **shadow_opacity[transportation] = 50**<br> **shadow_opacity [graphic] = 50**<br> **shadow_opacity [other] = 50**<br>
  - `semitransparency` boolean — Whether to have semi-transparent regions in the result (default: true).<br> _Note_: Semitransparency is currently only supported for car windows (this might change in the future). Other objects are returned without semitransparency, even if set to true.
  - `bg_color` string — Adds a solid color background. Can be a hex color code (e.g. 81d4fa, fff) or a color name (e.g. green). For semi-transparency, 4-/8-digit hex codes are also supported (e.g. 81d4fa77). (If this parameter is present, the other bg_ parameters must be empty.)
  - `bg_image_url` string — Adds a background image from a URL. The image is centered and resized to fill the canvas while preserving the aspect ratio, unless it already has the exact same dimensions as the foreground image. (If this parameter is present, the other bg_ parameters must be empty.)

## Response `200`

Image background removed

- RemoveBgJsonResponse
  - `data` object
    - `result_b64` string — Base64 encoded string of result image
    - `foreground_top` integer — Top position of the foreground image along the vertical axis. In case the input image resolution is higher than the limit (> 50 megapixels) this value is expressed with respect to the input image resolution.
    - `foreground_left` integer — Left position of the foreground image along the horizontal axis. In case the input image resolution is higher than the limit (> 50 megapixels) this value is expressed with respect to the input image resolution.
    - `foreground_width` integer — Width of the foreground image. In case the input image resolution is higher than the limit (> 50 megapixels) this value is expressed with respect to the input image resolution.
    - `foreground_height` integer — Height of the foreground image. In case the input image resolution is higher than the limit (> 50 megapixels) this value is expressed with respect to the input image resolution.

## Other responses

- `400` — Error: Invalid parameters or input file unprocessable (no credits charged)
- `402` — Error: Insufficient credits (no credits charged)
- `403` — Error: Authentication failed (no credits charged)
- `429` — Error: Rate limit exceeded (no credits charged)

---

[API](https://skmtc.dev/remove/apis/background-removal-api.md) · [All operations](https://skmtc.dev/remove/apis/background-removal-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/remove/background-removal-api/revisions/d155c05b2a6f/schema)
