# Settings and profiles endpoints

Settings are the active profile's preferences. A profile is a separate
library in the same install. These endpoints read and change settings, browse
folders on the server's disk, and manage profiles.

Each endpoint lists the errors it returns itself. Any endpoint can also return
the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors).

## Settings object

The settings endpoints return this object, one per profile:

| Field | Type | Description |
|---|---|---|
| `data_dir` | string | The active profile's directory |
| `output_format` | string | `wav` or `mp3`. Default `wav` |
| `normalize_lufs` | number or null | Loudness target in LUFS, or `null` for none. Default −16 |
| `trim_silence` | boolean | Trim silence from new sounds. Default `true` |
| `auto_unload_minutes` | integer | Idle minutes before the loaded model and engines stop, 0 to 600 (0: never). Default 10 |
| `device` | string | `auto`, `cuda`, `mps` or `cpu`. Default `auto` |
| `hf_token_set` | boolean | A Hugging Face token is stored, or `HF_TOKEN` is set |
| `enabled_audiocpp_models` | string[] | The audio.cpp model ids that are on |
| `audiocpp_mode` | string | `managed` (Mirli's own audio.cpp, the default) or `external` (one already installed) |
| `audiocpp_models_dir` | string | Where audio.cpp weights are read, always resolved: the custom folder in `external` mode, else `<INSTALL_ROOT>/models/audiocpp` |
| `sounds_dir` | string | The folder new audio is written to, always resolved. Default `<DATA_DIR>/sounds` |
| `llm_mode`, `image_mode` | string | Prompt assistant and artwork engines: `off` (the default), `managed` or `external` |
| `llm_model`, `image_model` | string | The managed models. Defaults `qwen3-1.7b` and `sd-turbo` |
| `llm_external_base_url`, `llm_external_model`, `image_external_base_url`, `image_external_model` | string | The external servers and models |
| `llm_external_api_key_set`, `image_external_api_key_set` | boolean | An external key is stored |
| `image_external_kind` | string | `openai` (the default) or `a1111` |
| `image_auto_artwork` | boolean | Draw cover art after each music generation |
| `otel_endpoint` | string | OpenTelemetry endpoint. `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence |
| `update_check` | boolean | The daily update check. Default `true` |
| `setup` | string | `full` or `simple` (only models that run elsewhere). Default `full` |
| `setup_include_local` | boolean | On the simple setup, also offer models installed here |
| `onboarded_at` | string or null | ISO 8601 time first-run setup was finished or skipped |

## Get settings

`GET /api/settings`

Returns the active profile's settings. This endpoint takes no parameters.

This request reads the settings:

```bash
curl http://127.0.0.1:17494/api/settings
```

A successful response is `200 OK` with the settings. The example is abridged:

```jsonc
{
  "data_dir": "C:\\Users\\x\\.mirli",
  "hf_token_set": true,
  "output_format": "wav",
  "normalize_lufs": -16.0,
  "trim_silence": true,
  "auto_unload_minutes": 10,
  "sounds_dir": "C:\\Users\\x\\.mirli\\sounds",
  "llm_mode": "off",
  "llm_model": "qwen3-1.7b",
  "llm_external_api_key_set": false
  // ...more fields
}
```

This endpoint returns only the common errors.

## Update settings

`PATCH /api/settings`

Changes the settings sent and keeps the rest. A missing or `null` field is
unchanged, except `"normalize_lufs": null`, which switches normalisation off.
Unknown fields and settings in the
[capabilities](https://mirli.app/docs/api-server/index.md#get-capabilities)' `settings_locked` are
ignored; the rest are saved.

| Name | Type | Required | Description |
|---|---|---|---|
| `output_format`, `trim_silence`, `auto_unload_minutes`, `device`, `audiocpp_mode`, `llm_mode`, `llm_model`, `llm_external_base_url`, `llm_external_model`, `image_mode`, `image_model`, `image_external_kind`, `image_external_base_url`, `image_external_model`, `image_auto_artwork`, `otel_endpoint`, `update_check`, `setup`, `setup_include_local` | As listed | No | See the [settings object](#settings-object) |
| `normalize_lufs` | number or null | No | `null` switches normalisation off |
| `hf_token`, `llm_external_api_key`, `image_external_api_key` | string | No | Write-only: the response has `hf_token_set`, `llm_external_api_key_set` and `image_external_api_key_set` instead. `""` clears one |
| `enabled_audiocpp_models` | string[] | No | Replaces the whole list: send every id that stays on |
| `audiocpp_models_dir` | string | No | The external weights folder. `""` restores the default |
| `sounds_dir` | string | No | `""` resets to `<DATA_DIR>/sounds`. Changing it moves the existing library to the new folder |
| `onboarded_at` | string | No | ISO 8601 time. `""` clears it, so first-run setup shows again |

This request switches loudness normalisation off:

```bash
curl -X PATCH "http://127.0.0.1:17494/api/settings" \
  -H 'Content-Type: application/json' \
  -d '{"normalize_lufs": null}'
```

A successful response is `200 OK` with the updated
[settings object](#settings-object).

| Status | Cause |
|---|---|
| `400` | `sounds_dir` is sent while anything is queued or generating, names a network share, is inside the current folder or contains it, or cannot be created. The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) |

## List folders

`GET /api/fs/dirs`

Lists the subfolders of a folder on the server's own disk, for the folder
pickers in Settings. It never returns files. A missing path resolves to its
nearest existing ancestor; a folder that cannot be opened has no entries.

| Name | Type | Required | Description |
|---|---|---|---|
| `?path` | string | No | The folder to list. Default: the server user's home |

This request lists the folders in a home directory:

```bash
curl "http://127.0.0.1:17494/api/fs/dirs?path=C:%5CUsers%5Cx"
```

A successful response is `200 OK` with the listing:

```json
{
  "path": "C:\\Users\\x",
  "parent": "C:\\Users",
  "separator": "\\",
  "home": "C:\\Users\\x",
  "writable": true,
  "roots": [
    {
      "name": "C:",
      "path": "C:\\"
    }
  ],
  "entries": [
    {
      "name": "Music",
      "path": "C:\\Users\\x\\Music"
    }
  ]
}
```

`parent` is `null` at a root, and `writable` is a best-effort hint. `roots`
holds every drive letter that answers on Windows, or `/` elsewhere. `entries`
includes symbolic links to folders and is sorted by name.

| Status | Cause |
|---|---|
| `400` | `path` is a network share, is not a folder, or cannot be read |
| `403` | The server's capabilities turn `filesystem` off |

## Profile object

A profile is a data directory with its own `soundbox.db`, `sounds/`,
`artwork/` and `settings.json`, so switching profiles changes everything the
library endpoints return. Model weights (`models/`) and runtime binaries
(`bin/`) live at the install root, shared by every profile.

The install root is `~/.mirli`, or `MIRLI_DATA_DIR` or `--data-dir`. The
`default` profile is the install root itself, so an install that predates
profiles is the default profile. Named profiles live in
`<INSTALL_ROOT>/profiles/<PROFILE_ID>`. At startup, `--profile NAME` opens the
profile with that id (the default one if none matches); without it, the last
active profile opens.

The profile endpoints return this object:

| Field | Type | Description |
|---|---|---|
| `id` | string | A slug of the name, fixed at creation: lower-case letters, digits and hyphens, up to 40 characters |
| `name` | string | Display name |
| `created_at` | string | ISO 8601 time it was made. `""` for the default profile |
| `data_dir` | string | Its directory |
| `active` | boolean | The profile the server has open |

## List profiles

`GET /api/profiles`

Returns every profile and the active id. This endpoint takes no parameters.

This request lists the profiles:

```bash
curl http://127.0.0.1:17494/api/profiles
```

A successful response is `200 OK` with the list:

```json
{
  "active": "default",
  "profiles": [
    {
      "id": "default",
      "name": "Default",
      "created_at": "",
      "data_dir": "C:\\Users\\x\\.mirli",
      "active": true
    },
    {
      "id": "demo",
      "name": "Demo",
      "created_at": "2026-02-01T10:00:00Z",
      "data_dir": "C:\\Users\\x\\.mirli\\profiles\\demo",
      "active": false
    }
  ]
}
```

This endpoint returns only the common errors.

## Create a profile

`POST /api/profiles`

Creates a profile and its directory without switching to it. A taken slug
gets `-2`, `-3` and so on; `default` is never reused.

| Name | Type | Required | Description |
|---|---|---|---|
| `name` | string | Yes | 1 to 60 characters, trimmed |

This request creates a profile named "Demo":

```bash
curl -X POST "http://127.0.0.1:17494/api/profiles" \
  -H 'Content-Type: application/json' \
  -d '{"name": "Demo"}'
```

A successful response is `201 Created` with the new
[profile object](#profile-object).

| Status | Cause |
|---|---|
| `400` | `name` is only spaces |
| `403` | The server's capabilities turn `filesystem` off |

## Rename a profile

`PATCH /api/profiles/<PROFILE_ID>`

Changes a profile's display name; the id and directory stay.

| Name | Type | Required | Description |
|---|---|---|---|
| `<PROFILE_ID>` | string | Yes | The profile's id |
| `name` | string | Yes | 1 to 60 characters, trimmed |

This request renames a profile:

```bash
curl -X PATCH "http://127.0.0.1:17494/api/profiles/<PROFILE_ID>" \
  -H 'Content-Type: application/json' \
  -d '{"name": "Client demo"}'
```

A successful response is `200 OK` with the updated
[profile object](#profile-object).

| Status | Cause |
|---|---|
| `400` | `name` is only spaces |
| `404` | No profile has this id |

## Activate a profile

`POST /api/profiles/<PROFILE_ID>/activate`

Switches the running server to another profile without a restart. The loaded
model stays in memory; the profile's settings, enabled models and custom
endpoints take over.

| Name | Type | Required | Description |
|---|---|---|---|
| `<PROFILE_ID>` | string | Yes | The profile's id |

This request switches to another profile:

```bash
curl -X POST -H 'X-Soundbox: 1' \
  "http://127.0.0.1:17494/api/profiles/<PROFILE_ID>/activate"
```

A successful response is `200 OK` with the
[profile list](#list-profiles), whose `active` is the new id.

| Status | Cause |
|---|---|
| `400` | No profile has this id, or a job is queued or running (its file and database row, written at the end, would land in the wrong library). The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) |

## Delete a profile

`DELETE /api/profiles/<PROFILE_ID>`

Removes a profile from the list. Its directory stays by default.

| Name | Type | Required | Description |
|---|---|---|---|
| `<PROFILE_ID>` | string | Yes | The profile's id |
| `?delete_data` | string | No | `1` also deletes the profile's directory |

> [!WARNING]
> `?delete_data=1` permanently deletes the profile's directory: its database,
> settings and artwork, and its sounds unless its `sounds_dir` is elsewhere.

This request removes a profile and keeps its files:

```bash
curl -X DELETE -H 'X-Soundbox: 1' \
  "http://127.0.0.1:17494/api/profiles/<PROFILE_ID>"
```

A successful response is `204 No Content`.

| Status | Cause |
|---|---|
| `400` | The profile is the default profile or the active profile, which cannot be deleted |
| `403` | The server's capabilities turn `filesystem` off |
| `404` | No profile has this id |
