# Mastering profiles

Genre profiles and the closest match for a session.

Paths start at `$ACTIVQC_BASE_URL`, and every call sends `Authorization: Bearer $ACTIVQC_KEY`. Errors use the [error envelope](https://activqc.wavbee.com/docs/errors.md). [All endpoints](https://activqc.wavbee.com/docs/api-reference.md).

## GET /v1/mastering/profiles

List the library's genres and whether each can make a profile.

**Auth:** a secret key, `Authorization: Bearer $ACTIVQC_KEY`.

#### Example request

```bash
curl -s "$ACTIVQC_BASE_URL/v1/mastering/profiles" \
  -H "Authorization: Bearer $ACTIVQC_KEY"
```

#### Responses

| Status | Meaning |
|---|---|
| `200` | Genres. |

#### Response `200`

| Field | Type | Description |
|---|---|---|
| `object` | string | **Required.** Always `list`. |
| `data` | array of object | **Required.** genre, genre_key, references, training, ready (enough training references). |

```json
{
  "object": "list",
  "data": [
    {}
  ]
}
```

## GET /v1/mastering/profiles/{genre}

A genre's profile, built from its approved references.

**Auth:** a secret key, `Authorization: Bearer $ACTIVQC_KEY`.

#### Parameters

| Name | In | Type | Description |
|---|---|---|---|
| `genre` | path | string | **Required.** |

#### Example request

```bash
curl -s "$ACTIVQC_BASE_URL/v1/mastering/profiles/{genre}" \
  -H "Authorization: Bearer $ACTIVQC_KEY"
```

#### Responses

| Status | Meaning |
|---|---|
| `200` | The profile. |
| `422` | Too few approved references. [Error envelope](https://activqc.wavbee.com/docs/errors.md). |

#### Response `200`

| Field | Type | Description |
|---|---|---|
| `object` | string | **Required.** Always `mastering.profile`. |
| `label` | string | **Required.** Example `Pop`. |
| `mode` | string | **Required.** One of `genre`, `closest`. |
| `references` | array of object | **Required.** id, title, artist, genre (and distance, for closest) of every reference used. |
| `curve` | object | **Required.** Median relative spectrum: bands_hz[], mid_db[], side_db[] (null unless every reference has a side spectrum). The target a tone-shaped render EQs toward. |
| `spread` | object | **Required.** mid_p25_db[] and mid_p75_db[]: how much the references agree. |
| `typical` | object | **Required.** Median integrated_lufs, plr_db, lra, side_to_mid_db. |

```json
{
  "object": "mastering.profile",
  "label": "Pop",
  "mode": "genre",
  "references": [
    {}
  ],
  "curve": {},
  "spread": {},
  "typical": {}
}
```

## GET /v1/mastering/sessions/{id}/closest

The references that sound closest to this master, as a profile.

Ranks every approved reference by tonal balance, dynamics and width, whatever its genre label, and builds a profile from the nearest 12.

**Auth:** a secret key, `Authorization: Bearer $ACTIVQC_KEY`.

#### Parameters

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | integer | **Required.** |

#### Example request

```bash
curl -s "$ACTIVQC_BASE_URL/v1/mastering/sessions/{id}/closest" \
  -H "Authorization: Bearer $ACTIVQC_KEY"
```

#### Responses

| Status | Meaning |
|---|---|
| `200` | The closest references. |
| `404` | Another tenant's session. [Error envelope](https://activqc.wavbee.com/docs/errors.md). |
| `422` | The master has no spectrum yet. [Error envelope](https://activqc.wavbee.com/docs/errors.md). |

#### Response `200`

| Field | Type | Description |
|---|---|---|
| `object` | string | **Required.** Always `mastering.profile`. |
| `label` | string | **Required.** Example `Pop`. |
| `mode` | string | **Required.** One of `genre`, `closest`. |
| `references` | array of object | **Required.** id, title, artist, genre (and distance, for closest) of every reference used. |
| `curve` | object | **Required.** Median relative spectrum: bands_hz[], mid_db[], side_db[] (null unless every reference has a side spectrum). The target a tone-shaped render EQs toward. |
| `spread` | object | **Required.** mid_p25_db[] and mid_p75_db[]: how much the references agree. |
| `typical` | object | **Required.** Median integrated_lufs, plr_db, lra, side_to_mid_db. |

```json
{
  "object": "mastering.profile",
  "label": "Pop",
  "mode": "genre",
  "references": [
    {}
  ],
  "curve": {},
  "spread": {},
  "typical": {}
}
```

