For AI agents: this page is also available as Markdown at https://docs.refabric.com/task-api-reference/image.change_background.md, and the index of every page is https://docs.refabric.com/llms.txt.
Image editing
Change an image's background
Put a finished image on a new background — a backdrop from your library, a photo, a scene you describe, or none at all (a transparent PNG) — keeping everything in front of it as it is. Delivered as one image file.
Endpoint: POST https://api.refabric.com/v1/tasks/image.change_backgroundTask: image.change_backgroundScope: tasks:runCategory: Image editing
Quick start
import os
import time
import requests
headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}
job = requests.post(
"https://api.refabric.com/v1/tasks/image.change_background",
headers=headers,
json={
"image": "art:9f2c01",
"background": {
"type": "library",
"background": "background:4417",
},
},
).json()
print(job["job_id"])
while True:
status = requests.get(job["status_url"], headers=headers).json()
if status["lifecycle"] == "terminal":
break
time.sleep(5)
print(requests.get(job["result_url"], headers=headers).json())cURL waits for the result with Prefer: wait; when the job outlives the wait, it answers 202 with the job's URLs.
Input schema
- stringrequired
The finished image whose background to replace; the person, the garment and the styling are kept. As one string: a URL, a file from an earlier result (
art:…or its url) or an upload (file:…). If it is one of your files placed in a project or on a design in the Refabric app, the result is filed there too.pattern: ^(https://|art:|file:).+$
Example:
art:9f2c01 - objectrequired
The new backdrop, chosen by
type:library(abackground:<id>),image(a photo of the backdrop),prompt(the scene in words) ortransparent(no backdrop).Example:
{"type":"library","background":"background:4417"}type: library
A backdrop from your library (
GET /v1/refs/background).- stringrequired
Picks this alternative:
library.Values
library
- stringrequired
A
background:<id>handle, listed atGET /v1/refs/background.pattern: ^background:.+$
type: image
A photo of the backdrop to use.
- stringrequired
Picks this alternative:
image.Values
image
- stringrequired
A picture, as one string: a URL, a file from an earlier result (
art:…, or itsurl) or an upload (file:…).pattern: ^(https://|art:|file:).+$
type: prompt
The scene in words; it is the whole instruction.
- stringrequired
Picks this alternative:
prompt.Values
prompt
- stringrequired
What you want, in words.
min length 1
type: transparent
No backdrop: the result is a PNG with a transparent background.
- stringrequired
Picks this alternative:
transparent.Values
transparent
- stringoptional
The model the image shows, as a
model:<id>handle (GET /v1/refs/model). An image from a shoot, or an edit of one, already carries its model; sendmodelfor any other picture (an upload, a url).pattern: ^model:.+$
Output schema
- array<object>optional
One file: the image on its new background (
image/pngwith a transparent background when you chosetransparent). Pass it on to another edit to continue from it.
Required-fields example
{
"image": "art:9f2c01",
"background": {
"type": "library",
"background": "background:4417"
}
}Full example
{
"image": "art:9f2c01",
"background": {
"type": "library",
"background": "background:4417"
}
}Response example
{
"job_id": "d2b3c4d500004000800000000000000b",
"lifecycle": "queued",
"status_url": "http://v3-api.refabric.com/v1/jobs/d2b3c4d500004000800000000000000b",
"result_url": "http://v3-api.refabric.com/v1/jobs/d2b3c4d500004000800000000000000b/result",
"cancel_url": "http://v3-api.refabric.com/v1/jobs/d2b3c4d500004000800000000000000b/cancel"
}Result example
{
"job_id": "d2b3c4d500004000800000000000000b",
"files": [
{
"file": "art:9f2c03",
"url": "https://files.example.com/image.change_background/1.png",
"media_type": "image/png",
"task": "image.change_background",
"job_id": "d2b3c4d500004000800000000000000b",
"created_at": "2026-10-01T09:12:40Z"
}
],
"has_more": false
}background is a choice by type: library (a background:<id> from GET /v1/refs/background), image ({type: image, image}), prompt ({type: prompt, prompt: "a sunlit marble hall"}) or transparent ({type: transparent}, a PNG with a transparent background). The image is one of your products, so the result is saved on that product too.
Send a finished image and choose its new backdrop: one from your library, a photo, a scene in words, or none at all. The person, the garment and the styling in front of it are kept.
Built for
- A shoot image placed in a new setting
- A transparent cut-out for a web shop or a layout
- The same look shown in several scenes
What you get
- One image on its new background — a PNG with a transparent background when you choose
transparent.
Specs
| Input formats | Images, each one string: a URL, an upload (file:…) or a file from an earlier result (art:…). Upload types and sizes: GET /v1/meta limits.upload. |
|---|---|
| Input count | image: one |
| Output format | Files: each one line with its url and its media_type, in the job's result. |
| Outputs per job | One image file per job. |
Choosing a task
- Use this when the whole backdrop behind the subject should change. Use image.glam when one detail you name should change and the rest stay as it is.
Errors
field_not_acceptedinvalid_requestnot_foundpermission_deniedinsufficient_creditscontent_refusedprocessing_failedinvalid_optionfield_not_supported
Related
background.create· It runs before: its result is this input.photoshoot.create· It runs before: its result is this input.image.upscale· It runs after: it takes this task's result.
Good to know
Pricing: Estimate a request before you run it, or see the price of each option.
For agents and code generation
- https://api.refabric.com/v1/tasks/image.change_background/llms.txt
- https://api.refabric.com/v1/tasks/image.change_background/openapi.json
GET https://api.refabric.com/v1/tasks/image.change_background