# Build with Refabric

> Run fashion tasks — designs, photoshoots, edits, videos and production files — from your own code with one HTTP API.

Refabric's API runs the same tasks as the Refabric app. You send a task its input, Refabric runs it
as a job, and you get files and records back that you can pass straight into the next task.

Refabric runs 27 tasks today, in 6 categories.

::::cards
:::card{title="Design generation · 2 tasks" href="/task-api-reference/design-generation"}
Makes new designs and patterns from your words, reference images or a moodboard.
:::
:::card{title="Image editing · 9 tasks" href="/task-api-reference/image-editing"}
Changes one thing in an image you send — its background, frame, face, pose, fabric, views or finish — and keeps the rest.
:::
:::card{title="Photoshoots · 3 tasks" href="/task-api-reference/photoshoots"}
Turns product photos into shoot photos: on a model, on a ghost mannequin or on a mannequin.
:::
:::card{title="Video · 1 task" href="/task-api-reference/video"}
Turns an image into a short video.
:::
:::card{title="Production prep · 5 tasks" href="/task-api-reference/production-prep"}
Takes what production needs from an image: its materials, colours or print, a larger copy, or a vector file.
:::
:::card{title="Records & libraries · 7 tasks" href="/task-api-reference/records-libraries"}
Makes the records and library items other tasks take: moodboards, brand kits, range plans, fabrics, poses and backgrounds.
:::
::::

Search the docs with ⌘K, or start from one of the cards below.

| | Task APIs | Platform API |
|---|---|---|
| **What it is for** | Running a task: you send an input, a job makes files or a record | Everything around the jobs: tasks, jobs, files, prices, usage, reference data |
| **Auth** | An API key with the `tasks:run` scope | An API key; some reads need no key ([Authentication](https://docs.refabric.com/api-reference/platform/authentication)) |
| **Example call** | `POST /v1/tasks/image.generate` | `GET /v1/jobs/{job_id}` |

::::cards
:::card{title="Task API Reference" href="/task-api-reference"}
Every task, its inputs, outputs and errors, grouped by category.
:::
:::card{title="Quick Start" href="/quick-start"}
Run your first job and read its files.
:::
:::card{title="Calling tasks" href="/task-apis/calling-tasks/overview"}
Submit and poll, wait for the answer, or get a webhook.
:::
:::card{title="Records & libraries" href="/records-and-libraries/overview"}
Moodboards, fabrics, brand kits, poses and backgrounds that tasks reuse.
:::
::::

::::cards
:::card{title="Platform API" href="/api-reference/platform"}
One base URL for tasks, jobs, files, reference data, webhooks and your account.
:::
::::

## Start with a task call

1. Create a key in **Panel › Developers › Keys** and set it as `REFABRIC_API_KEY` ([Get your API key](https://docs.refabric.com/setting-up/get-your-api-key)).
2. Submit a task:

::::code-group
```python
import os, requests

r = requests.post(
    "https://api.refabric.com/v1/tasks/image.generate",
    headers={"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"},
    json={"prompt": "a navy linen shirt dress, studio photo"},
)
print(r.status_code, r.json())  # 202 and the job's handle
```

```javascript
const r = await fetch("https://api.refabric.com/v1/tasks/image.generate", {
  method: "POST",
  headers: {
    Authorization: `Key ${process.env.REFABRIC_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ prompt: "a navy linen shirt dress, studio photo" }),
});
console.log(r.status, await r.json()); // 202 and the job's handle
```

```bash
curl -s -X POST "https://api.refabric.com/v1/tasks/image.generate" \
  -H "Authorization: Key $REFABRIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a navy linen shirt dress, studio photo"}'
```
::::

3. The answer is `202` with a `job_id` and the URLs to poll, read and cancel the job. Read the
   `result_url` once the job has ended: each delivered design is one line of `files`, with its
   `file` id and its `url` ([Asynchronous jobs](https://docs.refabric.com/task-apis/calling-tasks/asynchronous-jobs#result)).

## Turn records into products

A task can make a **record** — a moodboard, a fabric, a brand kit, a range plan — instead of a plain
image. A record has an id (`moodboard:…`) that later tasks take as input, so one run feeds the next.
[Recipes](https://docs.refabric.com/task-apis/recipes) chain tasks this way, step by step.

## Next steps

::::cards
:::card{title="Why Refabric" href="/why-refabric"}
What the API gives your fashion workflow.
:::
:::card{title="Get your API key" href="/setting-up/get-your-api-key"}
Create, test, roll and revoke keys.
:::
:::card{title="Task APIs overview" href="/task-apis/overview"}
The one pattern every task follows.
:::
::::
