Background Removal API Reference
Remove image backgrounds programmatically. Authenticate with an API key and POST an image — you get the cut-out back in the response.
Quick start
- Create an API key in your dashboard.
- Send your image to the endpoint below with the key as a Bearer token.
- Receive the background-removed image in the response.
Base URL
https://api.remover.bgAuthentication
Pass your API key as a Bearer token. Create and manage keys in your dashboard. Keep keys secret — anyone with a key can spend your credits.
Authorization: Bearer rmbg_YOUR_API_KEYRemove background
/remove-bgSend the image as multipart/form-data under the file field. Accepts PNG, JPEG or WebP up to 10 MB. The response body is the processed image; the remaining balance is returned in the X-Credits-Remaining header. An optional bg_image_file field can carry a background image (see below).
Parameters
All parameters are sent in the query string, except bg_image_file, which is a multipart field.
| Parameter | Type | Default | Description |
|---|---|---|---|
| format | png | jpeg | jpg | webp | png | Output image format. |
| quality | number 0–1 | 1 | Compression quality (jpeg/webp only). |
| trim | boolean | true | Trim transparent edges around the subject. Trimming does not affect credit usage. |
| trim_margin | string | 0 | Space to leave around the subject when trimming, e.g. "30px" or "10%" (relative to subject size). One value (all sides), two (top/bottom, left/right) or four (top, right, bottom, left). Capped at 50% of the subject size or 500 px per side; never extends past the original image borders. Only applies when trim is enabled. |
| transparent_windows | boolean | true | Car photos only: cleans up the old background visible through the windows and keeps a natural, slightly transparent glass look. Set to false to get fully opaque windows. Images without car windows are unaffected. |
| shadow_type | auto | car | drop | none | none | Adds a soft drop shadow under the subject. car uses a larger, softer shadow suited to vehicles; drop a tighter one for smaller objects. auto picks car for detected vehicles and drop for everything else. The shadow falls straight down by default (see shadow_direction) and is baked into the transparency, so it works on transparent results and with bg_ options alike. |
| shadow_opacity | number 0–100 | auto | auto | Shadow darkness from 0 (lightest) to 100 (darkest). auto uses 90 for car shadows and 50 for drop shadows. Only applies when a shadow is requested. |
| shadow_direction | number −60–60 | 0 | Shadow tilt in degrees. 0 (default) drops the shadow straight down; positive tilts it to the right, negative to the left. Applies to both car and drop shadows. |
| bg_color | string | — | Adds a solid color background. Hex code (e.g. 81d4fa, fff) or color name (e.g. green). 4-/8-digit hex codes add semi-transparency (e.g. 81d4fa77). If present, the other bg_ options 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 its aspect ratio, unless it already has the exact same dimensions as the foreground. If present, the other bg_ options must be empty. |
| bg_image_file | file | — | Adds a background image from a file, sent as a second multipart/form-data field (not a query parameter). PNG, JPEG or WebP up to 10 MB; scaled like bg_image_url. If present, the other bg_ options must be empty. |
| response | image | url | image | Binary image (default) or JSON with a temporary download URL (kept for 24 hours). |
Examples
curl -X POST "https://api.remover.bg/remove-bg?format=png" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@photo.jpg" \
--output result.pngTransparent car windows
On car photos, the old background showing through the windows is cleaned up automatically and the glass keeps a natural, slightly transparent look (transparent_windows=true, the default). Prefer solid windows? Pass transparent_windows=false and they come back fully opaque. This only applies to vehicle photos — images without car windows are unaffected either way.
curl -X POST "https://api.remover.bg/remove-bg?transparent_windows=false" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@car.jpg" \
--output result.pngShadows
Add a soft drop shadow under the subject with shadow_type. car uses a larger, softer shadow suited to vehicles; drop a tighter one for smaller objects; auto picks car for detected vehicles and drop otherwise. Tune the darkness with shadow_opacity (0–100; auto uses 90 for car shadows, 50 for drop shadows), and tilt it with shadow_direction(−60 to 60 degrees; 0 falls straight down). The shadow is part of the image's transparency, so it also works together with the bg_ options below and costs no extra credits.
curl -X POST "https://api.remover.bg/remove-bg?shadow_type=auto" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@car.jpg" \
--output result.pngBackgrounds
Replace the removed background in the same call. Pass bg_color for a solid color (hex or color name; use a 4-/8-digit hex code for semi-transparency), bg_image_url to load a background image from a URL, or upload one directly as a bg_image_file multipart field. Background images are centered and scaled to fill the canvas while keeping their aspect ratio. Only one bg_ option can be used per request, and backgrounds do not affect credit usage.
# Solid color
curl -X POST "https://api.remover.bg/remove-bg?bg_color=81d4fa" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@photo.jpg" \
--output result.png
# Background image from a URL
curl -X POST "https://api.remover.bg/remove-bg?bg_image_url=https%3A%2F%2Fexample.com%2Fbeach.jpg" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@photo.jpg" \
--output result.png
# Background image from a file
curl -X POST "https://api.remover.bg/remove-bg" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@photo.jpg" \
-F "bg_image_file=@beach.jpg" \
--output result.pngResponse formats
By default the response body is the processed image (binary). Pass ?response=url to instead receive JSON with a temporary download URL:
curl -X POST "https://api.remover.bg/remove-bg?response=url" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY" \
-F "file=@photo.jpg"{
"url": "https://.../outputs/.../abc.png?X-Amz-...",
"format": "png",
"model": "quality",
"expiresAt": "2026-06-20T10:00:00.000Z"
}Stored results — including the URL above — are automatically deleted after 24 hours. Download promptly or use the default binary response.
Get account
/accountReturns your remaining credits, active subscription and recent usage. Does not consume credits. Also available at /me.
Examples
curl "https://api.remover.bg/account" \
-H "Authorization: Bearer rmbg_YOUR_API_KEY"Response
{
"credits": 142,
"subscription": {
"plan": "pro_yearly",
"status": "active",
"currentPeriodEnd": "2027-01-15T00:00:00.000Z"
},
"usage": { "last30Days": 37 }
}Responses & errors
/remove-bg returns the processed image (binary) on 200, with headers X-Credits-Remaining (balance after the call) and X-Output-File (suggested filename). Errors return JSON: { "error": "message" }.
| Status | Meaning |
|---|---|
| 400 | Missing file or invalid parameter. |
| 401 | Missing or invalid API key. |
| 402 | Insufficient credits. |
| 413 | File too large (max 10 MB). |
| 415 | Unsupported file type (use PNG, JPEG or WebP). |
| 503 | Server busy — retry shortly. |
| 504 | Processing timed out. |
Credits & pricing
Each successful /remove-bg call consumes 1 credit. Failed requests are not charged. Top up or subscribe on the pricing page.
API changelog
Most recent API updates:
- New
Added
shadow_direction(−60 to 60 degrees) — 0 drops the shadow straight down, positive tilts it right, negative left. Applies to bothcaranddropshadows. - New
Added shadows:
shadow_type(auto,car,drop,none) withshadow_opacity(0–100 orauto) — a soft drop shadow under the subject (a larger, softer one for vehicles), falling straight down by default. Shadows do not affect credit usage. - New
Added background replacement:
bg_color(solid color, semi-transparent hex supported),bg_image_urlandbg_image_file(custom image, centered and scaled to fill the canvas). Backgrounds do not affect credit usage. - New
Added the
trim_marginparameter — leave a pixel (30px) or percentage (10%) margin around the subject when trimming. - New
Added the
transparent_windowsparameter — choose between naturally transparent or fully opaque car windows. - Improved
Car photos now get clean windows automatically: the old background visible through the glass is removed and a subtle transparency is kept.
- Changed
Simplified to a single high-quality model. Every call now costs exactly 1 credit; the
typeparameter is no longer needed and is ignored. - New
The
X-Trimresponse header now reports how much was trimmed from each edge, so results can be repositioned precisely over the original. - Improved
response=urldownload links are now signed, private URLs that expire together with the stored result (24 hours). - New
Added
response=url— receive JSON with a temporary download URL instead of the binary image. - Launch
Public API launch:
POST /remove-bgandGET /accountwith API-key authentication. PNG, JPEG and WebP supported as input and output formats.