# Create a reference set

POST

/v2/workspaces/{workspace\_id}/reference-sets

```bash
curl --request POST \
  --url https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "category": "general",
  "file_ids": [
    "<uuid>"
  ],
  "description": "<string>",
  "cover_file_ids": [
    "<uuid>"
  ]
}'
```

```python
import requests


url = "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets"


payload = {
    "name": "<string>",
    "category": "general",
    "file_ids": ["<uuid>"],
    "description": "<string>",
    "cover_file_ids": ["<uuid>"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}


response = requests.post(url, json=payload, headers=headers)


print(response.json())
```

```js
const url = 'https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"<string>","category":"general","file_ids":["<uuid>"],"description":"<string>","cover_file_ids":["<uuid>"]}'
};


try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main


import (
  "fmt"
  "strings"
  "net/http"
  "io"
)


func main() {


  url := "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets"


  payload := strings.NewReader("{\n  \"name\": \"<string>\",\n  \"category\": \"general\",\n  \"file_ids\": [\n    \"<uuid>\"\n  ],\n  \"description\": \"<string>\",\n  \"cover_file_ids\": [\n    \"<uuid>\"\n  ]\n}")


  req, _ := http.NewRequest("POST", url, payload)


  req.Header.Add("Authorization", "Bearer <token>")
  req.Header.Add("Content-Type", "application/json")


  res, _ := http.DefaultClient.Do(req)


  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)


  fmt.Println(res)
  fmt.Println(string(body))


}
```

```php
<?php


$curl = curl_init();


curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'name' => '<string>',
    'category' => 'general',
    'file_ids' => [
        '<uuid>'
    ],
    'description' => '<string>',
    'cover_file_ids' => [
        '<uuid>'
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);


$response = curl_exec($curl);
$err = curl_error($curl);


curl_close($curl);


if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

```java
OkHttpClient client = new OkHttpClient();


MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"name\": \"<string>\",\n  \"category\": \"general\",\n  \"file_ids\": [\n    \"<uuid>\"\n  ],\n  \"description\": \"<string>\",\n  \"cover_file_ids\": [\n    \"<uuid>\"\n  ]\n}");
Request request = new Request.Builder()
  .url("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets")
  .post(body)
  .addHeader("Authorization", "Bearer <token>")
  .addHeader("Content-Type", "application/json")
  .build();


Response response = client.newCall(request).execute();
```

```ruby
require 'uri'
require 'net/http'


url = URI("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets")


http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true


request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"<string>\",\n  \"category\": \"general\",\n  \"file_ids\": [\n    \"<uuid>\"\n  ],\n  \"description\": \"<string>\",\n  \"cover_file_ids\": [\n    \"<uuid>\"\n  ]\n}"


response = http.request(request)
puts response.read_body
```

```csharp
var client = new RestClient("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/reference-sets");
var request = new RestRequest("", Method.Post);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"<string>\",\n  \"category\": \"general\",\n  \"file_ids\": [\n    \"<uuid>\"\n  ],\n  \"description\": \"<string>\",\n  \"cover_file_ids\": [\n    \"<uuid>\"\n  ]\n}", ParameterType.RequestBody);
var response = client.Execute(request);
```

* Production

> **Unchanged from v1.** This endpoint’s documented request and response schemas are identical in v1 and v2 — change the `/v1` prefix to `/v2`. Schema equality is not a promise about behaviour, so keep your usual smoke tests.

Create a reference set (a curated collection of already-uploaded files) that can then be trained into a custom style/LoRA. Upload files first via the Files API, then pass their IDs here.

## Authorizations

* **[bearerAuth](/docs/v2/rest-api#bearerauth)**

## Parameters

### Path Parameters

**workspace\_id**

required

_Workspace Id_

Id of the workspace that owns the resource.

string format: uuid

Id of the workspace that owns the resource.

## Request Bodyrequired

_CreateReferenceSetRequest_object

**name**

required

_Name_

Display name for the reference set.

string

<= 255 characters

**category**

required

_Category_

Training category: general (overall aesthetic), character (person/creature), object (specific item), scene (environment), or effect (visual effect).

string

Allowed values: general character object scene effect

**file\_ids**

required

_File Ids_

Ordered image or video file IDs to include. Must belong to the workspace.

Array<string>

\>= 1 items <= 1000 items

**description**

Any of:

**string**

string

<= 2000 characters

**null**

null

**cover\_file\_ids**

Any of:

**Array<string>**

Array<string>

**null**

null

## Responses

### 201

Successful Response

_CreateReferenceSetResponse_object

**reference\_set\_id**

required

_Reference Set Id_

ID of the created reference set (train this with a training run).

string format: uuid

**name**

required

_Name_

string

**asset\_count**

required

_Asset Count_

Number of input files added to the reference set.

integer

**cover\_count**

required

_Cover Count_

Number of cover thumbnails set on the reference set.

integer

**skipped**

_Skipped_

Files from file\_ids that were not included, each with the reason.

Array<object>

_SkippedFile_object

**file\_id**

required

_File Id_

string format: uuid

**reason**

required

_Reason_

Why this file\_id was not added: not\_found (no such file), foreign\_workspace (belongs to another workspace), already\_member (already in the set), or duplicate\_in\_request (listed more than once in this call).

string

Allowed values: not\_found foreign\_workspace already\_member duplicate\_in\_request

##### Example

```json
{
  "skipped": [
    {
      "reason": "not_found"
    }
  ]
}
```

### 401

Unauthenticated — missing or invalid Bearer token.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```

### 403

Forbidden — insufficient permissions.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```

### 404

Resource not found.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```

### 422

Invalid input parameters.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```

### 429

Rate limited — too many concurrent requests.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```

### 500

Internal server error.

object

**type**

required

string

**title**

required

string

**status**

required

integer

**detail**

required

string

##### Example

```json
{
  "type": "https://api.layer.ai/errors/ERROR_CODE",
  "title": "Error Title",
  "status": 400,
  "detail": "Human-readable description."
}
```
