> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://uploadcare.com/docs/_mcp/server.

# Execute Remove.bg

POST https://api.uploadcare.com/addons/remove_bg/execute/
Content-Type: application/json

Execute [remove.bg](https://remove.bg/) background image removal Add-On for a given target.

Reference: https://uploadcare.com/docs/api/rest/add-ons/remove-bg-execute

## Authentication

- `Authorization` header (required) — Every request made to `https://api.uploadcare.com/` MUST be signed. HTTPS SHOULD be used with any authorization scheme. Requests MUST contain the `Authorization` header defining `auth-scheme` and `auth-param`: `Authorization: auth-scheme auth-param`. Every request MUST contain the `Accept` header identifying the REST API version: `Accept: application/vnd.uploadcare-v0.7+json`. There are two available authorization schemes: * For production: `Uploadcare`, a scheme where a `signature`, not your Secret API Key MUST be specified. Signatures SHOULD be generated on backend. * For quick tests: `Uploadcare.Simple`, a simple scheme where your [Secret API Key](https://app.uploadcare.com/projects/-/api-keys/) MUST be specified in every request's `auth-param`.

## Request

### Headers

- `Accept` (string, required) — Version header.

### Body (application/json)

This endpoint expects an object.

- `target` (string, required) — Unique ID of the file to process
- `params` (AddonsRemoveBgExecutePostRequestBodyContentApplicationJsonSchemaParams, optional, default: {}) — Optional object with Add-On specific parameters

## Response

### 200

Add-On execution response.

- `request_id` (string, optional) — Request ID.

## Errors

### 400 Bad Request Error

Simple authentication over HTTP is forbidden. Please, use HTTPS or signed requests instead.

- `detail` (string, optional, default: Simple authentication over HTTP is forbidden. Please, use HTTPS or signed requests instead.)

### 401 Unauthorized Error

Authorization errors.

- `detail` (enum, optional)
  - Allowed values: `Incorrect authentication credentials.`, `Public key {public_key} not found.`, `Secret key not found.`, `Invalid signature. Please check your Secret key.`

### 406 Not Acceptable Error

Invalid version header `Accept` for this endpoint.

- `detail` (string, optional, default: Incorrect Accept header provided. Make sure to specify API version. Refer to REST API docs for details.)

### 409 Conflict Error

Add-On concurrent call attempt.

- `detail` (string, optional, default: Concurrent call attempted)

### 429 Too Many Requests Error

Request was throttled.

- `detail` (string, optional)

## Types

### AddonsRemoveBgExecutePostRequestBodyContentApplicationJsonSchemaParams

Optional object with Add-On specific parameters

- `crop` (boolean, optional, default: false) — Whether to crop off all empty regions
- `crop_margin` (string, optional, default: 0) — Adds a margin around the cropped subject, e.g 30px or 30%
- `scale` (string, optional) — Scales the subject relative to the total image size, e.g 80%
- `add_shadow` (boolean, optional, default: false) — Whether to add an artificial shadow to the result
- `type_level` (enum, optional, default: none) — "none" = No classification (foreground_type won't bet set in the application data) "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
  - Allowed values: `none`, `1`, `2`, `latest`
- `type` (enum, optional) — Foreground type.
  - Allowed values: `auto`, `person`, `product`, `car`
- `semitransparency` (boolean, optional, default: true) — Whether to have semi-transparent regions in the result
- `channels` (enum, optional, default: rgba) — Request either the finalized image ('rgba', default) or an alpha mask ('alpha').
  - Allowed values: `rgba`, `alpha`
- `roi` (string, optional) — 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%").
- `position` (string, optional) — 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).

## Examples

**Request**

```json
{
  "target": "21975c81-7f57-4c7a-aef9-acfe28779f78"
}
```

**Response**

```json
{
  "request_id": "8db3c8b4-2dea-4146-bcdb-63387e2b33c1"
}
```

**SDK Code**

```php PHP
<?php
$configuration = Uploadcare\Configuration::create((string) $_ENV['UPLOADCARE_PUBLIC_KEY'], (string) $_ENV['UPLOADCARE_SECRET_KEY']);

$api = (new Uploadcare\Api($configuration))->addons();
$resultKey = $api->requestRemoveBackground('21975c81-7f57-4c7a-aef9-acfe28779f78');
echo \sprintf('Remove background requested. Key is \'%s\'', $resultKey);

```

```python Python
from pyuploadcare import Uploadcare
uploadcare = Uploadcare(public_key='YOUR_PUBLIC_KEY', secret_key='YOUR_SECRET_KEY')

remove_bg_params = AddonRemoveBGExecutionParams(
    crop=True,
    crop_margin="20px",
    scale="15%",
    position ='',
    roi = ''
)

target_file = uploadcare.file("1bac376c-aa7e-4356-861b-dd2657b5bfd2")
remove_bg_result = uploadcare.addons_api.execute(
    target_file,
    AddonLabels.REMOVE_BG,
    remove_bg_params
)

```

```ruby Ruby
require 'uploadcare'
Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'

uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
Uploadcare::Addons.remove_bg(uuid, crop: true)

```

```swift Swift
import Uploadcare

let uploadcare = Uploadcare(withPublicKey: "YOUR_PUBLIC_KEY", secretKey: "YOUR_SECRET_KEY")

let parameters = RemoveBGAddonExecutionParams(crop: true, typeLevel: .two)
let response = try await uploadcare.executeRemoveBG(fileUUID: "1bac376c-aa7e-4356-861b-dd2657b5bfd2", parameters: parameters)
print(response) // contains requestID

// Execute and wait for completion:
let status = try await uploadcare.performRemoveBG(fileUUID: "1bac376c-aa7e-4356-861b-dd2657b5bfd2")
print(status)

```

```kotlin Kotlin
import com.uploadcare.android.library.api.UploadcareClient

val uploadcare = UploadcareClient(publicKey = "YOUR_PUBLIC_KEY", secretKey = "YOUR_SECRET_KEY")

val addOn = RemoveBgAddOn(uploadcare)
val response = addOn.execute(fileId = "1bac376c-aa7e-4356-861b-dd2657b5bfd2")
Log.d("TAG", response.toString())

```

```javascript
const url = 'https://api.uploadcare.com/addons/remove_bg/execute/';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.uploadcare-v0.7+json',
    Authorization: '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"target":"21975c81-7f57-4c7a-aef9-acfe28779f78"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.uploadcare.com/addons/remove_bg/execute/"

	payload := strings.NewReader("{\n  \"target\": \"21975c81-7f57-4c7a-aef9-acfe28779f78\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/vnd.uploadcare-v0.7+json")
	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.uploadcare.com/addons/remove_bg/execute/")
  .header("Accept", "application/vnd.uploadcare-v0.7+json")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"target\": \"21975c81-7f57-4c7a-aef9-acfe28779f78\"\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.uploadcare.com/addons/remove_bg/execute/");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.uploadcare-v0.7+json");
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"target\": \"21975c81-7f57-4c7a-aef9-acfe28779f78\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```