Skip to main content
RemoveZero

API Documentation

Endpoint

Server-side image processing

Usage

1 Credit per successful image

Overview

RemoveZero provides one synchronous, server-side API for background removal. Send one JPG, PNG, or WebP image as standard Base64 and receive a PNG or WebP result inline in the JSON response.

Before you start

  1. Sign in, open Personal, and create an API Key.
  2. Copy the full key when it is shown and store it on your server.
  3. Make sure the account has at least 1 available Credit.
  4. Encode one supported image as standard Base64 without a data-URL prefix.

Quickstart

Your first request only needs input.image_base64. Omit input.output to keep the original-size transparent output used by existing clients.

curl --request POST   --url https://removezero.com/api/v1/remove-background   --header "Authorization: Bearer ${REMOVEZERO_API_KEY}"   --header "Content-Type: application/json"   --header "Idempotency-Key: image-2026-08-28-0001"   --data '{"input":{"image_base64":"BASE64_IMAGE_DATA"}}'

Authenticate with a Bearer key

Create an API Key from Personal, then send it in the Authorization header for every request.

Authorization: Bearer rz_live_your_api_key
API Keys are shown in full only when they are created. Store the key in your server secret manager.
  • Keep keys in a server environment variable or secret manager.
  • Never place a key in browser code, mobile bundles, extensions, URLs, public repositories, or logs.
  • Use separate keys for separate services or environments when practical.
  • Revoke and replace a key immediately if it may have been exposed.

Call the API from your server

Use the path browser or client → your server → RemoveZero API. The Bearer key can authorize paid processing, so a public client cannot keep it secret. Paid server requests must omit the Origin header.

Send a background removal request

Send one strict JSON request from your server. Required headers are validated before Credit reservation or image processing.

POST https://removezero.com/api/v1/remove-background
Authorization: Bearer rz_live_your_api_key
Content-Type: application/json
Idempotency-Key: order-2026-08-25-0001

Required headers

  • Authorization: Bearer API Key
  • Content-Type: application/json
  • Idempotency-Key: unique retry key

JSON body

{
  "input": {
    "image_base64": "BASE64_IMAGE_DATA"
  }
}
  • Content-Type must be application/json; a charset parameter is allowed.
  • Content-Encoding must be omitted or identity; compressed request bodies are rejected.
  • Do not send an Origin header.
  • Idempotency-Key must be 1–128 characters using letters, numbers, periods, underscores, colons, or hyphens.
  • image_base64 must contain standard Base64 image bytes without a data:image/... prefix.

Customize the output

The input.output object is optional. It changes the canvas after the same single background-removal inference, so customization does not use another Credit.

{
  "input": {
    "image_base64": "BASE64_IMAGE_DATA",
    "output": {
      "format": "webp",
      "background": "#ffffff",
      "width": 1600,
      "height": 1600,
      "padding_ratio": 0.08
    }
  }
}
format
"png" or "webp"; defaults to "png".
background
"transparent" or a six-digit #RRGGBB color; defaults to "transparent".
width + height
Optional paired canvas dimensions: 32–4,096 px per side and no more than 4,194,304 pixels.
padding_ratio
Optional subject padding from 0 to 0.25 of the shorter canvas side; defaults to 0.

Fixed contain + center behavior

Fit is not a request field. RemoveZero always preserves the subject’s aspect ratio and fits it inside the available canvas.

  • The complete subject remains visible and centered.
  • The subject is not cropped or stretched.
  • Remaining canvas space uses transparency or the requested color.
  • Cover, smart crop, gravity positions, and arbitrary coordinates are not supported.

Backward compatibility

Existing clients can omit input.output and keep sending only input.image_base64. Add output only when you need a custom format, background, canvas, or padding.

Successful response

A successful image returns HTTP 200 and uses 1 Credit. The output includes the exact content type and canvas dimensions, plus Base64 data your server can decode.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "ok": true,
  "id": "REQUEST_ID",
  "status": "COMPLETED",
  "output": {
    "ok": true,
    "content_type": "image/webp",
    "width": 1600,
    "height": 1600,
    "output_base64": "BASE64_IMAGE_RESULT"
  },
  "usage": {
    "units": 1,
    "credits_used": 1
  }
}

Decode the result

  1. Confirm HTTP 200, ok: true, and status: COMPLETED.
  2. Read output.content_type and accept only image/png or image/webp.
  3. Decode output.output_base64 once and save the bytes with the matching extension.
  4. When dimensions were requested, verify output.width and output.height.

The result is returned inline, not as a permanent URL. Save the decoded bytes in your own application if you need to keep or deliver the image.

import { writeFile } from "node:fs/promises";

const payload = await response.json();

if (!response.ok || payload.ok !== true || payload.status !== "COMPLETED") {
  throw new Error(payload.error?.code ?? "REMOVEZERO_REQUEST_FAILED");
}

const { content_type: type, output_base64: base64 } = payload.output ?? {};
const extension = type === "image/png" ? "png" : type === "image/webp" ? "webp" : null;

if (!extension || typeof base64 !== "string") {
  throw new Error("REMOVEZERO_OUTPUT_INVALID");
}

await writeFile(`removezero-result.${extension}`, Buffer.from(base64, "base64"));

Billing and Credit returns

Each request processes one image. RemoveZero validates the request, atomically reserves 1 Credit, and settles it only after both background removal and the requested output succeed. Output customization never adds another inference or Credit.

Credit lifecycle

ValidationInvalid input is rejected before authorization.No Credit used
ReservationOne Credit is reserved atomically.1 Credit held
SuccessThe result is returned and usage is completed.credits_used: 1
Verified failureThe request fails and the reservation returns once.credits_used: 0; credits_returned: 1
Unresolved returnThe final request or return cannot yet be verified.REFUND_PENDING

If the request or its return cannot be verified yet, the API returns REFUND_PENDING with the request ID and Retry-After: 30. Keep the same Idempotency-Key and do not submit the same image with a new key.

HTTP/1.1 503 Service Unavailable
Retry-After: 30
Content-Type: application/json

{
  "ok": false,
  "error": {
    "code": "REFUND_PENDING"
  },
  "request_id": "REQUEST_ID"
}

Idempotency and retries

Idempotency-Key binds the exact serialized JSON body, including the image and every supplied output field. Preserve the original request bytes as well as the key.

  • Same key and exact same body: safe retry without a second reservation or processing request.
  • Same key and changed body: 409 IDEMPOTENCY_CONFLICT.
  • Same key after a terminal request: 409 IDEMPOTENCY_REPLAY_UNAVAILABLE; completed Base64 results are not stored for replay.
  • New key: a new request that may reserve another Credit.
  • A semantically equal JSON body may still differ if whitespace, property order, or explicit defaults change.

Retry-After guidance

429 RATE_LIMITED
Wait 60 seconds, then retry the exact body with the same key.
503 REFUND_PENDING
Wait 30 seconds, then retry the exact body with the same key.
503 UPSTREAM_BUSY
Wait 10 seconds. Use a new key only for an intentional new attempt.
Network timeout or API_UNAVAILABLE
Treat the outcome as unknown and keep the original body and key until resolved.

Examples

Replace the placeholders on your server. The API key must never be exposed in a public browser bundle.

curl --request POST \
  --url https://removezero.com/api/v1/remove-background \
  --header 'Authorization: Bearer rz_live_your_api_key' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: order-2026-08-25-0001' \
  --data '{"input":{"image_base64":"BASE64_IMAGE_DATA","output":{"format":"webp","background":"#ffffff","width":1600,"height":1600,"padding_ratio":0.08}}}'

Common output starting points

These recipes are starting points, not permanent marketplace or category compliance guarantees. Platform names are labels, not API enum values.

1:1 transparent PNG

{"format":"png","background":"transparent","width":1600,"height":1600,"padding_ratio":0.08}

4:5 transparent PNG

{"format":"png","background":"transparent","width":1600,"height":2000,"padding_ratio":0.08}

3:4 transparent PNG

{"format":"png","background":"transparent","width":1500,"height":2000,"padding_ratio":0.08}

16:9 white WebP

{"format":"webp","background":"#ffffff","width":1920,"height":1080,"padding_ratio":0.08}

Amazon catalog starting point

{"format":"webp","background":"#ffffff","width":2000,"height":2000,"padding_ratio":0.075}

Shopify catalog starting point

{"format":"webp","background":"#ffffff","width":2048,"height":2048,"padding_ratio":0.08}

Errors and troubleshooting

Errors use a stable HTTP status and a short code in the JSON response.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "ok": false,
  "error": {
    "code": "ERROR_CODE"
  }
}
HTTPCodeMeaning
400INVALID_REQUESTThe JSON body, shape, Base64 data, or decoded image limit is invalid.
400IDEMPOTENCY_KEY_REQUIREDA valid Idempotency-Key is required before charging.
401AUTH_REQUIREDThe API Key is missing, invalid, or revoked.
402INSUFFICIENT_BALANCEThe account does not have enough Credits.
403ORIGIN_DENIEDPaid server requests must omit the Origin header.
409IDEMPOTENCY_CONFLICTThe same key was reused with different data.
409IDEMPOTENCY_REPLAY_UNAVAILABLEThis request key was already processed. Use a new key for a new image.
413INVALID_REQUEST_SIZEThe JSON request body is larger than 7,500,000 bytes.
415UNSUPPORTED_MEDIA_TYPEContent-Type must be application/json.
415UNSUPPORTED_ENCODINGContent-Encoding must be identity or omitted.
423ACCOUNT_FROZENThe account cannot submit paid work while frozen.
429RATE_LIMITEDSlow down and retry after Retry-After: 60.
502UPSTREAM_ERRORThe processing service returned an invalid result.
502UPSTREAM_UNAVAILABLEProcessing could not be reached.
503UPSTREAM_BUSYProcessing is busy; retry after Retry-After: 10.
503API_UNAVAILABLEThe API is temporarily unavailable.
503REFUND_PENDINGThe request or Credit return is still pending; keep the same key and wait.

Safe troubleshooting

  1. Record the HTTP status, error code, request_id when present, timestamp, and your Idempotency-Key.
  2. Never log or send the Bearer key, complete image_base64, or a complete response containing image data.
  3. Correct 4xx request, credential, balance, or header errors before trying again.
  4. Honor Retry-After and preserve the original body and key for unresolved requests.
  5. Contact support with non-secret identifiers if an unresolved state persists.

Request limits

Send one JPG, PNG, or WebP image per request as standard Base64. The decoded input may be at most 5 MiB and the complete JSON body at most 7,500,000 bytes. Custom output is limited to 4,096 px per side and 4,194,304 pixels. If an exact requested result cannot fit the inline response limit, processing fails and the reserved Credit is returned; the API never silently changes the requested size or format.

Input

  • One JPG, PNG, or WebP image per request.
  • Standard Base64 without a data-URL prefix.
  • Decoded image up to 5 MiB; complete JSON body up to 7,500,000 bytes.
  • Input dimensions from 32 to 12,000 px per side and up to 40 megapixels.

Custom output

  • PNG or WebP; transparent or #RRGGBB background.
  • Canvas from 32 to 4,096 px per side and at most 4,194,304 pixels.
  • padding_ratio from 0 through 0.25.
  • Bounded inline Base64 response; exact requests are never silently resized or reformatted.