# Records & libraries

> Makes the records and library items other tasks take: moodboards, brand kits, range plans, fabrics, poses and backgrounds.

## Tasks

- [Create a moodboard](https://docs.refabric.com/task-api-reference/moodboard.create) — `moodboard.create`: Analyse 10 to 60 images into a moodboard — its palette, fabrics, prints, key items and keywords — delivered as a `moodboard:` record you can read, and pass to generation.
- [Create a fabric](https://docs.refabric.com/task-api-reference/fabric.create) — `fabric.create`: Turn photos of a fabric into a library fabric you can design with, rendered in every extra colour you ask for. The result is the fabric record, fabric:<id>.
- [Add a colour to a fabric](https://docs.refabric.com/task-api-reference/fabric.add_colour) — `fabric.add_colour`: Render one more colour of a fabric you made with fabric.create. The result is the same fabric record with the new colour in it.
- [Create a brand kit](https://docs.refabric.com/task-api-reference/brand_kit.create) — `brand_kit.create`: Create a brand kit from your colours and your looks, fabrics, prints and other images. The kit is ready to read at once; its items are prepared so generation can use them.
- [Create a range plan](https://docs.refabric.com/task-api-reference/range_plan.create) — `range_plan.create`: Plan a collection from your moodboards: isolate garments from runway looks, or design new pieces line by line. The plan is delivered as one record whose items are its images.
- [Add a pose](https://docs.refabric.com/task-api-reference/pose.create) — `pose.create`: Turn a photo of a person posing into a pose in your library, to shoot or re-pose models in. The result is the pose, pose:<id>.
- [Add a background](https://docs.refabric.com/task-api-reference/background.create) — `background.create`: Turn a photo of a place, or of a studio backdrop, into a background in your library: background:<id>.

## Quick start (`moodboard.create`)

```python
import os
import time
import requests

headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}

job = requests.post(
    "https://api.refabric.com/v1/tasks/moodboard.create",
    headers=headers,
    json={
        "images": [
            "https://example.com/looks/1.jpg",
            "https://example.com/looks/2.jpg",
            "https://example.com/looks/3.jpg",
            "https://example.com/looks/4.jpg",
            "https://example.com/looks/5.jpg",
            "https://example.com/looks/6.jpg",
            "https://example.com/looks/7.jpg",
            "https://example.com/looks/8.jpg",
            "https://example.com/looks/9.jpg",
            "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())
```

```javascript
const headers = {
  Authorization: `Key ${process.env.REFABRIC_API_KEY}`,
  "Content-Type": "application/json",
};

const job = await fetch("https://api.refabric.com/v1/tasks/moodboard.create", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "images": [
      "https://example.com/looks/1.jpg",
      "https://example.com/looks/2.jpg",
      "https://example.com/looks/3.jpg",
      "https://example.com/looks/4.jpg",
      "https://example.com/looks/5.jpg",
      "https://example.com/looks/6.jpg",
      "https://example.com/looks/7.jpg",
      "https://example.com/looks/8.jpg",
      "https://example.com/looks/9.jpg",
      "art:9f3c01"
    ]
  }),
}).then((r) => r.json());
console.log(job.job_id);

let status = job;
while (status.lifecycle !== "terminal") {
  await new Promise((r) => setTimeout(r, 5000));
  status = await fetch(job.status_url, { headers }).then((r) => r.json());
}

console.log(await fetch(job.result_url, { headers }).then((r) => r.json()));
```

```bash
curl -X POST "https://api.refabric.com/v1/tasks/moodboard.create" \
  -H "Authorization: Key $REFABRIC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=60" \
  -d '{"images":["https://example.com/looks/1.jpg","https://example.com/looks/2.jpg","https://example.com/looks/3.jpg","https://example.com/looks/4.jpg","https://example.com/looks/5.jpg","https://example.com/looks/6.jpg","https://example.com/looks/7.jpg","https://example.com/looks/8.jpg","https://example.com/looks/9.jpg","art:9f3c01"]}'
```
