Background Removal API
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
/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
/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
/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
}'