Power Automate: Remove Image Backgrounds from SharePoint or OneDrive with the HTTP Action
Microsoft 365 shops keep product and staff photos in SharePoint and OneDrive, and the request is always the same: when a photo lands in this library, give me a version with the background removed. Power Automate can do it with one premium action. This guide builds the flow against the bgclear API using a base64 body — which matters because SharePoint files are private and an API cannot fetch them by URL — and writes the result back into the same library.
In this guide
Before you start: the licensing caveat
The HTTP action is a premium connector in Power Automate, so the flow owner needs a Power Automate premium (per-user or per-flow) licence or a trial. There is no standard-licence route to an arbitrary REST API. On the API side you need a key from the bgclear dashboard; the first key includes 10 free full-resolution credits and preview-size results are free without limit, which is enough to build and test the flow at no cost.
The flow, step by step
Trigger: SharePoint — "When a file is created in a folder" (or OneDrive for Business — "When a file is created"). Point it at the library/folder where originals arrive.
Step 2 — Get file content. SharePoint "Get file content" with the trigger's file identifier. (OneDrive's trigger already returns the content; skip this step there.)
Step 3 — HTTP (premium).
Method: POST
URI: https://www.bgclear.ai/api/v1/remove
Headers:
Authorization Bearer bgc_live_YOUR_KEY
Content-Type application/json
Accept application/json
Idempotency-Key @{triggerOutputs()?['body/{Identifier}']}
Body:
{
"image_file_b64": "@{base64(body('Get_file_content'))}",
"size": "auto",
"format": "png"
}The base64() expression turns the binary file content into the string the API expects, so the file never has to be public. The Idempotency-Key is the file's identifier: if the flow retries, the API returns the cached result instead of charging again (24-hour window).
Step 4 — Parse JSON on the HTTP body with this schema, so later steps get typed fields:
{ "type": "object", "properties": { "url": {"type": "string"}, "width": {"type": "integer"}, "height": {"type": "integer"}, "credits_charged": {"type": "integer"}, "credits_remaining": {"type": "integer"} } }Step 5 — HTTP (GET) with URI = @{body('Parse_JSON')?['url']} and no headers; the result URL needs no auth and is valid for 24 hours. The body of this action is the PNG.
Step 6 — Create file (SharePoint or OneDrive): folder = a cutouts subfolder, file name = @{replace(triggerOutputs()?['body/{FilenameWithExtension}'], '.', '-cutout.')} adjusted to end in .png, file content = @{body('HTTP_2')}.
Save and drop a JPG into the folder; the PNG appears in cutouts within a few seconds. For a white background instead of transparency (product photos), set "format": "jpg", "bg_color": "ffffff" in step 3 and name the output .jpg.
Errors, size limits and cost
Add a Configure run after on step 4 for "has failed" and a Condition on outputs('HTTP')?['statusCode']: 402 means the account is out of credits (insufficient_credits), 429 means more than 60 requests in a minute (retry after the X-RateLimit-Reset seconds), 400 image_too_large means the file is over 25 MB. Base64 inflates the payload by a third, so keep source images under roughly 18 MB; synchronous full-size requests are also capped at 4 megapixels — larger originals should go to POST /api/v1/jobs with a second flow (an "HTTP request received" trigger) as the callback receiver, as described in the bulk guide.
Cost: previews are free; full-resolution images are one credit — $9 for 100, $39 for 500, $129 for 2,000, credits never expire, failed calls never charged (pricing). A catalogue of 300 product photos is the $39 pack. If you previously used a remove.bg connector or HTTP action, the body fields are the same; only the URI and the header change before remove.bg's API closes on 1 December 2026 — mapping here. The same flow shape works in Logic Apps, and the no-code alternatives are covered in the n8n/Zapier/Make guide.
Frequently asked questions
Can I do this without a premium licence?
Not with an external API — the HTTP action and custom connectors are both premium. A trial licence covers building and testing; production needs the per-user or per-flow plan.
Why base64 instead of a file URL?
SharePoint and OneDrive files are private, so the API cannot fetch them by URL. Sending image_file_b64 from Get file content works without making anything public.
Can the flow process existing files in bulk?
Yes — swap the trigger for a manual or scheduled one, add Get files (properties only) over the folder, and put steps 2–6 inside an Apply to each with concurrency set to 1–3 to respect the 60-requests-a-minute limit.
What does each image cost?
Preview size (≤800 px) is free. Full resolution is one credit, from $0.065 to $0.09 depending on pack, no subscription.