# Remove background

> Queues a cutout of the subject and returns the task. The result is a transparent image, so ask for a format that carries an alpha channel.

`POST /image/remove-background`

**Auth:** API key or OAuth token

## Request body

- `url` (required, string)
- `access` (object) — Controls whether the create-task response should include a short-lived Public Access Token. That token can be passed to browser or client-side code for polling task status and task images without exposing your API key.
  - `pat` (required, object)
    - `enabled` (boolean) — Default `true`.
- `destination` (string) — ≥ 1 characters, ≤ 64 characters. Example `"bunny-prod"`.
- `metadata` (object)
- `output` (object)
  - `format` (string) — One of: `"png"`, `"webp"`.
- `webhook` (object)
  - `custom` (object[]) — ≥ 1 items, ≤ 5 items.
    - `url` (required, string)
  - `dashboard` (boolean) — Set to false to disable dashboard-managed webhooks for this task. Request-level custom webhooks are still sent.

## Response

### 201 — Image background removal task created

- `data` (required, object)
  - `estimatedCost` (required, string) — Estimated cost in USD reserved for this task. Failed images are refunded, so the final cost may be lower. Example `"0.03"`.
  - `taskId` (required, string) — Task ID Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.
  - `access` (object) — Returned when `access.pat.enabled` is true.
    - `publicAccessToken` (required, string) — Short-lived Public Access Token for polling task status and image results. This token is safe to return to frontend code and can be used instead of your API key for polling public task state. Example `"pat_eyJhbGciOi..."`.

```json
{
  "data": {
    "estimatedCost": "0.03",
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "access": {
      "publicAccessToken": "pat_eyJhbGciOi..."
    }
  }
}
```

### 400 — Validation Error

- `success` (required, false)
- `error` (required, array)
- `data` (required, any)

```json
{
  "success": false,
  "error": []
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/image/remove-background \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "string",
    "destination": "bunny-prod"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/image/remove-background", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "string",
    "destination": "bunny-prod"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
