Background Removal API

Remove image backgrounds automatically using our powerful AI API. Perfect for e-commerce products, profile pictures, or any image that needs a clean, professional look.
Remove, blur or replace image backgrounds with one API call
Generate precise masks for foreground and background editing
Process images via URL or file upload in PNG, WebP formats

Remove image background from URL

Send an image URL to our API and get back the processed image without background. Perfect for processing images that are already hosted online.

curl -X POST https://api.removebg.sh/v1/remove \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "format": "png"
  }'

Remove image background by upload

Upload an image directly from your computer or server. Useful when working with local files or user uploads.

curl -X POST https://api.removebg.sh/v1/upload \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "image=@/path/to/image.jpg"

Generate masks

Get a black and white mask of your image where white represents the foreground and black represents the background. Useful for advanced image editing and compositing.

curl -X POST https://api.removebg.sh/v1/mask \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "https://example.com/image.jpg"}'

API Reference

RESTful API for removing image backgrounds using AI

Remove Background from URL

POST /v1/remove

Remove background from an image provided via URL

Authorization

Bearer token required in Authorization header

Request Parameters

Parameter Type Required Default Description
image_url String Yes - URL of the image to process
format String No png Output format: 'png' or 'webp'
color String No Valid RGB color: rgb(255, 0, 0)
blur Boolean No Blur background instead of remove.
reverse Boolean No false If true, removes foreground instead of background

Response (200 OK)

{
  "image_url": "https://storage.example.com/u/{uuid}/bg/{id}.png",
  "size_mb": 0.45,
  "width": 1024,
  "height": 768
}

Example Request

curl -X POST http://api.removebg.sh/v1/remove \
  -H "Authorization: Bearer {your_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "format": "png",
    "reverse": false
  }'

Upload and Process Image

POST /v1/upload

Remove background from an uploaded image file

Authorization

Bearer token required in Authorization header

Request Parameters

Content-Type: multipart/form-data

Parameter Type Required Default Description
image File Yes - Image file to process (JPEG, PNG)
format String No png Output format: 'png' or 'webp'
color String No Valid RGB color: rgb(255, 0, 0)
blur Boolean No Blur background instead of remove.
reverse Boolean No false If true, removes foreground instead of background

Response (200 OK)

{
  "image_url": "https://storage.example.com/u/{uuid}/bg/{id}.png",
  "size_mb": 0.45,
  "width": 1024,
  "height": 768
}

Example Request

curl -X POST http://api.removebg.sh/v1/upload \
  -H "Authorization: Bearer {your_token}" \
  -F "image=@image.jpg" \
  -F "format=png" \
  -F "reverse=false"

Generate Image Mask

POST /v1/mask

Generate background mask from the image provided via URL

Authorization

Bearer token required in Authorization header

Request Parameters

Parameter Type Required Default Description
image_url String Yes - URL of the image to process
format String No png Output format: 'png' or 'webp'
reverse Boolean No false If true, generates mask for foreground instead of background

Response (200 OK)

{
  "mask_url": "https://storage.example.com/u/{uuid}/bg/{id}_mask.png",
  "size_mb": 0.41,
  "width": 2048,
  "height": 2048
}

Example Request

curl -X POST http://api.removebg.sh/v1/mask \
  -H "Authorization: Bearer {your_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "format": "png",
    "reverse": false
  }'

Error Codes

401 Invalid or missing API token
403 Account inactive or monthly limit exceeded
400 Invalid request body or image format
413 Image file too large for plan limit
422 Invalid image format or corrupted image file
429 Rate limit exceeded
500 Internal server error