For AI agents: this page is also available as Markdown at https://docs.refabric.com/task-api-reference/image.extract_materials.md, and the index of every page is https://docs.refabric.com/llms.txt.
Production prep
Extract the materials of a garment
Read the fabrics, trims and components a garment is made of from its image, each with a close-up, and the garment's colours. Delivered as one file with the findings in its data.
Endpoint: POST https://api.refabric.com/v1/tasks/image.extract_materialsTask: image.extract_materialsScope: tasks:runCategory: Production prep
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.extract_materials",
headers=headers,
json={
"image": "art:9f3c01",
},
).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 garment image to read its materials from, as one string: a URL, a file from an earlier result (
art:…or its url) or an upload (file:…). If it is an image of one of your designs, the result is also saved on that design.pattern: ^(https://|art:|file:).+$
Example:
art:9f3c01
Output schema
- array<object>optional
One file: the image you sent, with what it is made of in
data.- objectoptional
What the garment is made of: its name, colours and parts.
- stringoptional
The garment's name.
- stringoptional
What kind of garment it is.
- array<object>optional
The materials' colours, one per hex.
- stringrequired
The colour as #RRGGBB, like "#E8D9C4".
pattern: ^#[0-9A-Fa-f]{6}$
- stringoptional
A name for the colour.
- stringoptional
Its Pantone code, when known.
- array<object>optional
Every material, trim and component found, each with its close-up (
url, absent when no close-up could be made):typefabricfor a material,detailfor a trim or component,otherfor a label or packaging.- stringoptional
What one part (
items[]) of a record is.Values
fabric— A fabric: its swatch or a photo of it. When the image is a fabric swatch or a photo of a fabric.detail— A close crop of one detail of a look or a product (a collar, a pocket). When the image is a close crop of one detail.other— Any other image the record holds. When the image is none of the other kinds.
- stringoptional
What the part is called.
- stringoptional
What it is made of or does.
- stringoptional
A picture, as one string: a URL, a file from an earlier result (
art:…, or itsurl) or an upload (file:…).pattern: ^(https://|art:|file:).+$
Required-fields example
{
"image": "art:9f3c01"
}Full example
{
"image": "art:9f3c01"
}Response example
{
"job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
"lifecycle": "queued",
"status_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
"result_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968/result",
"cancel_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968/cancel"
}Result example
{
"job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
"files": [
{
"file": "art:a1b2c3",
"url": "https://files.example.com/image.extract_materials/1.png",
"media_type": "image/png",
"task": "image.extract_materials",
"job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
"created_at": "2026-10-01T09:30:00Z",
"data": {
"name": "Relaxed Poplin Shirt",
"description": "Button-down shirt",
"colours": [
{
"hex": "#E8D9C4",
"name": "Bleached Sand",
"pantone": "13-1008 TCX"
},
{
"hex": "#F4F1EA",
"name": "Snow White",
"pantone": "11-0602 TCX"
}
],
"items": [
{
"type": "fabric",
"name": "Main Fabric",
"description": "Mid-weight cotton poplin, plain weave, matte finish",
"url": "https://files.example.com/image.extract_materials/2.png"
},
{
"type": "detail",
"name": "Shell Button",
"description": "Four-hole natural shell button",
"url": "https://files.example.com/image.extract_materials/3.png"
},
{
"type": "other",
"name": "Care Label",
"description": "Woven care label at the side seam"
},
{
"type": "detail",
"name": "Patch Pocket",
"description": "Single patch pocket on the left chest",
"url": "https://files.example.com/image.extract_materials/4.png"
}
]
}
}
],
"has_more": false
}The file is the image you sent, with what it is made of in data. The image is one of your designs, so the bill of materials is also saved on that design's production details.
Send an image of a garment and get back what it is made of: each fabric, trim and component, with a close-up of each where one can be made, and the colours of its materials. If the image is one of your designs, the findings are also saved on that design.
Built for
- Bills of materials for production
- Sourcing and costing a garment's fabrics and trims
- Tech-pack preparation
What you get
- One file: the image you sent, with the garment's name and description in
data. data.items: every fabric, trim and component found, each with a close-upurlwhen one could be made.data.colours: the colours of its materials.
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 file per job. |
Choosing a task
- Use this when you need the materials, trims and components themselves. Use image.extract_colours when you only need the garment's colours.
Errors
field_not_acceptedinvalid_requestnot_foundpermission_deniedinsufficient_creditscontent_refusedprocessing_failed
Related
image.generate· It runs before: its result is this input.image.extract_colours· It does a neighbouring job.image.extract_print· It does a neighbouring job.
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.extract_materials/llms.txt
- https://api.refabric.com/v1/tasks/image.extract_materials/openapi.json
GET https://api.refabric.com/v1/tasks/image.extract_materials