> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elbic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dictionaries API

> REST reference for pronunciation dictionaries: list, create, update and delete dictionaries, add entries and bulk replace them from your own glossary.

Custom dictionaries let you control how the TTS pipeline pronounces
specific words. Each dictionary is scoped to a project and contains
word-to-replacement/IPA mappings that are applied before synthesis.

Use these endpoints to sync dictionaries from your own data sources
(PIM, CMS, internal glossary). The TTS-side cache is invalidated after
every mutation, so the next synthesis request that uses the dictionary picks
up your changes immediately. Authentication uses your project-scoped API key.

## Use a dictionary in synthesis

With a project API key, synthesis uses the dictionaries of the key's own project
when the request carries no `project_id`. To use another project's dictionaries,
or when you authenticate without a project key, send the `project_id` from the
dictionary response on
[`/v1/tts/generate`](/api-reference/tts/generate#request-body) or in the
WebSocket config, optionally with `dictionary_ids` to pick specific dictionaries:

```json
{
  "text": "Welcome to KugelAudio.",
  "voice_id": 1071,
  "language": "en",
  "project_id": 42,
  "dictionary_ids": [7]
}
```

The SDKs send the same field on every generation and session method:
`project_id` in Python and `projectId` in Java and JavaScript. The LiveKit and
Pipecat plugins take it as a constructor option (`project_id` in Python,
`projectId` in JavaScript).

## Common Request Fields

| Field | Location | Type | Applies to | Description |
|-------|----------|------|------------|-------------|
| `project_id` | query | integer | Every endpoint on this page | Optional; if supplied, it must match the key's project. |
| `dict_id` | path | integer | Single-dictionary and entry endpoints | Dictionary ID returned by list or create. |
| `entry_id` | path | integer | Update/delete entry | Entry ID returned by list or add. |

The `project_id` query parameter is omitted from the examples because ordinary
Dashboard API keys are already project-scoped.

## Response Objects

Dictionary responses contain:

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer | Dictionary ID |
| `project_id` | integer | Owning project ID |
| `name` | string | Display name |
| `description` | string \| null | Optional description |
| `language` | string \| null | Optional BCP-47 language filter |
| `is_active` | boolean | Whether the dictionary applies by default |
| `created_at` | string | Creation timestamp |
| `updated_at` | string | Last-update timestamp |

Entry responses contain:

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer | Entry ID |
| `dictionary_id` | integer | Parent dictionary ID |
| `word` | string | Source text to match |
| `replacement` | string | Replacement text sent to synthesis |
| `ipa` | string \| null | Optional IPA transcription |
| `case_sensitive` | boolean | Whether matching preserves case |
| `created_at` | string | Creation timestamp |
| `updated_at` | string | Last-update timestamp |

Wrapper responses contain:

| Operation | Fields |
|-----------|--------|
| List dictionaries | `dictionaries` (array of dictionary objects) |
| List entries | `entries` (array), `total` (integer before pagination), `limit` (integer), `offset` (integer) |
| Bulk replace | `upserted` (integer), `deleted` (integer), `total` (integer; resulting payload size) |
| Delete dictionary/entry | `deleted` (boolean, always `true` on a successful response) |

---

## List Dictionaries

Return every dictionary in the caller's project.

```http
GET /v1/dictionaries
```

### Query Parameters

<ParamField query="project_id" type="integer">
  Optional; rejected when it disagrees with the key's project.
</ParamField>

### Response

```json
{
  "dictionaries": [
    {
      "id": 1,
      "project_id": 42,
      "name": "Brand names",
      "description": "Customer product names",
      "language": "en",
      "is_active": true,
      "created_at": "2026-05-20T09:00:00+00:00",
      "updated_at": "2026-05-20T09:05:00+00:00"
    }
  ]
}
```

### Example

<CodeGroup>

```bash cURL
curl -X GET "https://api.elbic.com/v1/dictionaries" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```python Python
from kugelaudio import KugelAudio

client = KugelAudio(api_key="YOUR_API_KEY")
for d in client.dictionaries.list():
    print(f"{d.id}: {d.name} ({d.language})")
```

```typescript JavaScript
import { KugelAudio } from 'kugelaudio';

const client = new KugelAudio({ apiKey: 'YOUR_API_KEY' });
const dictionaries = await client.dictionaries.list();
for (const d of dictionaries) {
  console.log(`${d.id}: ${d.name} (${d.language})`);
}
```

```java Java
KugelAudio client = KugelAudio.fromEnv();
for (Dictionary d : client.dictionaries().list()) {
    System.out.println(d.getId() + ": " + d.getName());
}
```

</CodeGroup>

---

## Create Dictionary

```http
POST /v1/dictionaries
```

### Body

<ParamField body="name" type="string" required>
  Display name (1-200 characters). Must be unique within the project; a duplicate answers `409`.
</ParamField>

<ParamField body="description" type="string">
  Free-form description (maximum 2000 characters). Omit or send an empty string
  for no description.
</ParamField>

<ParamField body="language" type="string">
  BCP-47 language tag (`en`, `de-DE`, ...), maximum 16 characters. Omit or
  send an empty string for all languages.
</ParamField>

### Example

<CodeGroup>

```bash cURL
curl -X POST "https://api.elbic.com/v1/dictionaries" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Brand names", "language": "en"}'
```

```python Python
d = client.dictionaries.create(name="Brand names", language="en")
print(d.id)
```

```typescript JavaScript
const d = await client.dictionaries.create({ name: 'Brand names', language: 'en' });
console.log(d.id);
```

```java Java
Dictionary d = client.dictionaries().create("Brand names", null, "en");
System.out.println(d.getId());
```

</CodeGroup>

---

## Get Dictionary

```http
GET /v1/dictionaries/{dict_id}
```

Returns the dictionary record. Returns `403 Forbidden` if the dictionary
belongs to a project your API key is not scoped to.

---

## Update Dictionary

```http
PATCH /v1/dictionaries/{dict_id}
```

Only the provided fields are changed.

### Body

<ParamField body="name" type="string">
  New name (1-200 characters).
</ParamField>
<ParamField body="description" type="string">
  New description (maximum 2000 characters). Send an empty string to clear it;
  `null` leaves it unchanged.
</ParamField>
<ParamField body="language" type="string">
  New language tag (maximum 16 characters). Send an empty string to clear it;
  `null` leaves it unchanged.
</ParamField>
<ParamField body="is_active" type="boolean">
  Disable a dictionary without deleting it.
</ParamField>

### Example

<CodeGroup>

```bash cURL
curl -X PATCH "https://api.elbic.com/v1/dictionaries/1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"is_active": false}'
```

```python Python
client.dictionaries.update(1, is_active=False)
```

```typescript JavaScript
await client.dictionaries.update(1, { isActive: false });
```

```java Java
client.dictionaries().update(1, null, null, null, false);
```

</CodeGroup>

---

## Delete Dictionary

```http
DELETE /v1/dictionaries/{dict_id}
```

Deletes the dictionary and all its entries.

### Response

```json
{ "deleted": true }
```

---

## List Entries

```http
GET /v1/dictionaries/{dict_id}/entries
```

### Query Parameters

<ParamField query="search" type="string">
  Case-insensitive substring filter on `word`.
</ParamField>

<ParamField query="limit" type="integer" default="100">
  Page size, 1-500.
</ParamField>

<ParamField query="offset" type="integer" default="0">
  Pagination offset.
</ParamField>

### Response

```json
{
  "entries": [
    {
      "id": 11,
      "dictionary_id": 1,
      "word": "Postgres",
      "replacement": "post-gres",
      "ipa": null,
      "case_sensitive": false,
      "created_at": "2026-05-20T09:00:00+00:00",
      "updated_at": "2026-05-20T09:00:00+00:00"
    }
  ],
  "total": 12,
  "limit": 100,
  "offset": 0
}
```

---

## Add Entry

```http
POST /v1/dictionaries/{dict_id}/entries
```

### Body

<ParamField body="word" type="string" required>
  Word to match (≤ 200 chars). Must be unique within the dictionary; a duplicate answers `409`.
</ParamField>

<ParamField body="replacement" type="string" required>
  Text the engine pronounces instead (≤ 1000 chars).
</ParamField>

<ParamField body="ipa" type="string">
  Optional IPA transcription (maximum 200 characters). Takes precedence over
  `replacement` when set.
</ParamField>

<ParamField body="case_sensitive" type="boolean" default="false">
  Match the original case exactly.
</ParamField>

### Example

<CodeGroup>

```bash cURL
curl -X POST "https://api.elbic.com/v1/dictionaries/1/entries" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"word": "Postgres", "replacement": "post-gres"}'
```

```python Python
e = client.dictionaries.entries.add(
    dictionary_id=1,
    word="Postgres",
    replacement="post-gres",
)
```

```typescript JavaScript
const e = await client.dictionaries.entries.add(1, {
  word: 'Postgres',
  replacement: 'post-gres',
});
```

```java Java
DictionaryEntry e = client.dictionaries().entries().add(
    1, new DictionaryEntryInput("Postgres", "post-gres"));
```

</CodeGroup>

---

## Bulk Replace Entries

```http
PUT /v1/dictionaries/{dict_id}/entries
```

Replace every entry in the dictionary. Entries currently in the dictionary
whose `word` is not in the supplied list are deleted. The operation is
idempotent: calling twice with the same payload converges to the same final
state.

### Body

<ParamField body="entries" type="array" required>
  Array of `{ word, replacement, ipa?, case_sensitive? }` items.
  `word` and `replacement` are required on every item; their limits and
  `case_sensitive: false` default match [Add Entry](#add-entry). Duplicate
  `word` values within the payload are rejected.
</ParamField>

### Response

```json
{ "upserted": 25, "deleted": 3, "total": 25 }
```

### Example

<CodeGroup>

```bash cURL
curl -X PUT "https://api.elbic.com/v1/dictionaries/1/entries" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "entries": [
      {"word": "Postgres",   "replacement": "post-gres"},
      {"word": "Kubernetes", "replacement": "koo-ber-net-eez"}
    ]
  }'
```

```python Python
result = client.dictionaries.entries.replace_all(
    dictionary_id=1,
    entries=[
        {"word": "Postgres",   "replacement": "post-gres"},
        {"word": "Kubernetes", "replacement": "koo-ber-net-eez"},
    ],
)
print(result.upserted, result.deleted)
```

```typescript JavaScript
const result = await client.dictionaries.entries.replaceAll(1, [
  { word: 'Postgres',   replacement: 'post-gres' },
  { word: 'Kubernetes', replacement: 'koo-ber-net-eez' },
]);
console.log(result.upserted, result.deleted);
```

```java Java
BulkReplaceResult result = client.dictionaries().entries().replaceAll(
    1,
    List.of(
        new DictionaryEntryInput("Postgres",   "post-gres"),
        new DictionaryEntryInput("Kubernetes", "koo-ber-net-eez")));
```

</CodeGroup>

---

## Update Entry

```http
PATCH /v1/dictionaries/{dict_id}/entries/{entry_id}
```

Only non-null fields are sent.

### Body

<ParamField body="word" type="string">
  New word (1-200 characters).
</ParamField>
<ParamField body="replacement" type="string">
  New replacement (1-1000 characters).
</ParamField>
<ParamField body="ipa" type="string">
  New IPA transcription (maximum 200 characters). Send an empty string to clear
  it; `null` leaves it unchanged.
</ParamField>
<ParamField body="case_sensitive" type="boolean" />

---

## Delete Entry

```http
DELETE /v1/dictionaries/{dict_id}/entries/{entry_id}
```

### Response

```json
{ "deleted": true }
```

Deletion is idempotent after the parent dictionary has been authorized: a
missing `entry_id` also returns `{ "deleted": true }`.

---

## Error responses

| Status | Code               | Meaning                                                    |
|--------|--------------------|------------------------------------------------------------|
| 400    | `VALIDATION_ERROR` | Missing or invalid field.                                   |
| 401    | `UNAUTHORIZED`     | API key missing, invalid, or not project-scoped.           |
| 403    | `UNAUTHORIZED`     | API key is scoped to a different project than the target.  |
| 404    | `NOT_FOUND`        | Dictionary does not exist, or an entry requested for update does not exist. |
| 409    | `VALIDATION_ERROR` | The name is already used by another dictionary in the project, or the word by another entry in the dictionary. Choose a different one, or edit the existing one. |
| 503    | `INTERNAL_ERROR`   | Dictionary management is unavailable on this deployment.  |
