---
title: "Remove Background"
method: POST
path: "/remove"
tags: ["Image Processing"]
---

# Remove Background

`POST /remove`

## Request

- Base URL: `https://api.poof.bg/v1`
- URL: `https://api.poof.bg/v1/remove`
- Auth: API key in header `x-api-key`

Remove the background from an image. This is a synchronous endpoint that returns the processed image directly in the response body. Each successful request costs 1 credit regardless of parameters. Failed requests are not billed.

## Request body `multipart/form-data`

- object: Provide exactly one image input: image_file (upload), image_file_b64 (base64) or image_url (public URL). If several are sent, image_file wins, then image_file_b64, then image_url.
  - `image_file` string, binary: The image file to process (JPEG, PNG or WebP). Max 20MB. Required unless image_file_b64 or image_url is given.
  - `image_file_b64` string, byte: The image as a base64 string, with or without a data:<mime>;base64, prefix. Max 20MB decoded. Alternative to image_file.
  - `image_url` string, uri: Public http(s) URL of the image to process; Poof downloads it server-side (max 20MB, up to 3 redirects, 15s timeout). URLs pointing at private, loopback or link-local addresses are rejected. Alternative to image_file.
  - `format` 'png' | 'jpg' | 'webp': Resulting image format. For remove.bg compatibility, auto is accepted and treated as png; zip is not supported.
  - `channels` 'rgba' | 'rgb' | 'alpha': Output color channels. Use 'rgba' for transparency, 'rgb' for an opaque image (background filled with bg_color, white by default), or 'alpha' for the grayscale alpha mask only.
  - `bg_color` string: Background color (hex, rgb, or color name). Applies when channels is 'rgb' or 'rgba'.
  - `size` 'full' | 'preview' | 'medium' | 'hd': Output image size preset (megapixel cap). Ignored when width or height is set. For remove.bg compatibility the aliases auto, 4k and 50MP (treated as full) and small and regular (treated as preview) are also accepted.
  - `crop` union: Crop the image to the subject bounds. Pass true/false or an aspect ratio like '1:1', '4:3', '16:9'.
    - boolean
    - string
  - `padding` string: Padding around the subject when crop is enabled, added to each side as a fraction (e.g. '0.1') or percentage (e.g. '10%') of the subject's size on that axis. Pass one value for both axes, or two comma-separated values as horizontal,vertical (e.g. '10%,7.5%' gives a canvas 120% of subject width and 115% of subject height). Default '10%'.
  - `crop_margin` string: remove.bg-compatible alias for padding, using CSS margin shorthand with one to four space-separated values (e.g. '10%' or '0px 5%'). Percentages map onto padding; a zero pixel margin means a tight crop; other pixel margins cannot be honoured and are ignored. Ignored when padding is set.
  - `width` integer: Output width in pixels (1-6000). On its own, the height follows the image's aspect ratio. Together with height, the image is fitted into a width x height canvas according to fit. The aspect ratio is always preserved (never stretched); smaller images are upscaled unless fit is 'scale-down'. Overrides size.
  - `height` integer: Output height in pixels (1-6000). On its own, the width follows the image's aspect ratio. Together with width, the image is fitted into a width x height canvas according to fit. The aspect ratio is always preserved (never stretched); smaller images are upscaled unless fit is 'scale-down'. Overrides size.
  - `fit` 'contain' | 'cover' | 'scale-down': How to fit the image into width/height. 'contain' scales the image to fit inside and centres it, filling the remaining area with transparency (or bg_color). 'cover' scales the image to fill the canvas and crops the overflow, keeping the subject centred. 'scale-down' is like 'contain' but never enlarges: a smaller image keeps its native size (centred on the canvas when both dimensions are set). contain and cover only differ when both width and height are set.

## Response `200`

Successfully processed image

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `402`: Payment Required
- `403`: Forbidden
- `413`: Payload Too Large
- `422`: Unprocessable Entity
- `429`: Too Many Requests
- `500`: Internal Server Error
- `502`: Bad Gateway
- `503`: Service Unavailable
- `504`: Gateway Timeout

## Changes

- **2026-09-07** `aa9dcb8be405`: 3 warning
  - the optional response header `X-Credits-Charged` removed for the status `200`
  - the optional response header `X-Height` removed for the status `200`
  - the optional response header `X-Width` removed for the status `200`
- **2026-09-07** `e03864b5c9e6`: 4 info
  - added the new optional request property `crop_margin`
  - added the new optional request property `image_file_b64`
  - added the new optional request property `image_url`
  - the request property `image_file` became optional
- **2026-09-07** `9fe914d42247`: 7 breaking, 21 warning, 11 info
  - response property `details` list-of-types was widened by adding types `object` to media type `application/json` of response `400`
  - response property `details` list-of-types was widened by adding types `object` to media type `application/json` of response `401`
  - response property `details` list-of-types was widened by adding types `object` to media type `application/json` of response `402`
  - response property `details` list-of-types was widened by adding types `object` to media type `application/json` of response `403`
  - …35 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/poof-bg/apis/poof-api/changes/remove/post.md)

---

[API](https://skmtc.dev/poof-bg/apis/poof-api.md) - [All operations](https://skmtc.dev/poof-bg/apis/poof-api/llms.txt) - [OpenAPI document](https://skmtc.dev/poof-bg/apis/poof-api/revisions/aa9dcb8be405?raw)
