API folder workflow

Batch Background Removal with an API: A Folder Workflow

Your script processed several photos, then stopped. Running the folder again should preserve completed downloads and resume uncertain uploads without creating duplicate jobs.

This guide shows developers how to batch remove background through individual API tasks. RemoveBGKit's website processes one image at a time; its Download All button packages icons extracted from one source image. For independent photos, the folder queue belongs to your script.

Test the inputs and prepare your account

Choose a straightforward photo and harder examples with narrow parts or small lettering. Inspect their cutouts on contrasting backgrounds. If important details disappear, solve that problem before repeating the settings across a folder.

Original input

Original portrait used in the October 3 RemoveBGKit processing sample

Actual transparent PNG

Unretouched transparent portrait PNG returned by the live RemoveBGKit service
Original image · Actual output PNG · Processing provenance

Actual single-image result from October 3, 2026, using generic mode and portrait quality through the website. The output is unretouched; the checkerboard shows transparency. Inspect hair and the remaining glasses detail on the right before accepting this sample. This illustrates visual review, not an authenticated API batch benchmark or the fast-quality output of the script below.

Create an API key in your account and check available credits. The current API reserves five credits per image; completed processing consumes them, while terminal processing failure releases the reservation. Website guest trials do not supply API credits.

Use the API reference for current limits and settings. The example uses generic mode and fast quality. Change the helper's options only after testing, and issue new request IDs when image bytes or processing settings change.

Run a folder through the single-image helper

Download the site's TypeScript upload-to-download helper into your working directory. It submits one image, polls its task, and downloads its authenticated ZIP, with bounded retries and checks on returned URL origins.

Use Node.js 22.18 or newer. Put inputs in an `images` folder, provide `RMBG_API_KEY` through your server environment, and run this Bash example from that directory:

#!/usr/bin/env bash
set -euo pipefail
: "${RMBG_API_KEY:?Set your private API key}"
mkdir -p results request-ids
for input in ./images/*; do
  [[ -f "$input" ]] || continue
  case "$input" in
    *.png|*.jpg|*.jpeg|*.webp|*.PNG|*.JPG|*.JPEG|*.WEBP) ;;
    *) continue ;;
  esac
  name=$(basename "$input")
  output="results/$name.zip"
  [[ -s "$output" ]] && continue
  idfile="request-ids/$name.id"
  [[ -s "$idfile" ]] || uuidgen > "$idfile"
  export RMBG_REQUEST_ID
  RMBG_REQUEST_ID=$(< "$idfile")
  if node remove-background.mts "$input" "$output.part"; then
    mv "$output.part" "$output"
  else
    printf 'Stopped at %s; retain its request ID.\n' "$name" >&2
    exit 1
  fi
  sleep 4
done

This requires Bash, `uuidgen`, and the downloaded helper. It handles one flat folder, retains input extensions in output names, and submits sequentially. A ZIP becomes complete only after the helper succeeds and its temporary file is renamed. Run one instance against a dedicated batch folder.

Resume without blindly creating new tasks

Keep originals, filenames, settings, and request-ID files unchanged when restarting after a network error. Completed ZIPs are skipped. An uncertain upload reuses its ID so the API can return the existing task during its retention period.

If processing itself failed, replaying that ID returns the failure; correct the cause and deliberately create a new ID. Authentication, credit, or format errors also need correction. The script stops at an error, preserving earlier downloads for inspection.

Results expire 24 hours after submission, and deduplication is tied to retained task records. This small example is not a permanent job ledger. For production queues and task-status details, follow the complete API recovery tutorial.

For a changed input, move its old ZIP and ID out of the batch folders before submitting it again. Leaving an old ZIP in place would skip the replacement image. Keep separate folders for separate runs. The four-second pause reduces upload bursts, but does not guarantee compliance when other clients share your IP; the helper handles temporary rate-limit responses with bounded retries. A production worker should additionally persist task IDs and explicit review states instead of treating file presence as its whole ledger.

Inspect the downloaded folder

Each ZIP belongs to one input; this is not a combined archive for the whole folder. Extract it and check the PNG against its original. Review fine lettering, narrow connections, and missing internal spaces at the intended display size.

A saved ZIP means transport completed, not that every cutout passed visual review. Keep rejected outputs separate and record the reason. Use the PNG transparency check if a downloaded image still appears white. Your acceptance criteria decide which files reach the final design.

Prepared with AI assistance and reviewed against the existing API helper and processing record. The sample is not a live API batch benchmark. Questions: support@removebgkit.com.