# mv.audioAssets

> The audioAssets methods of @morevoice/sdk: Uploaded prompts and hold music.

Uploaded prompts and hold music. These methods are on `mv.audioAssets`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `create()`

**Upload an audio asset.** Uploads a WAV (mono or stereo PCM 8–48 kHz, 8/16/24/32-bit or float, or G.711 μ-law / A-law), up to 20 MB and 10 minutes, as multipart/form-data (a `file` part) or as JSON with the file base64. It is stored as mono 16-bit PCM at up to 16 kHz. MP3 is not accepted: convert it to WAV first.

```ts
mv.audioAssets.create(body: AudioAssetsCreateData["body"], options?: RequestOptions): Promise<AudioAssetsCreateResponse>
```

`POST /audio_assets` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_create/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.file` | `object` | yes | The recording. JSON uploads send it base64; multipart/form-data uploads send a `file` part. |
| `body.kind` | `"prompt" \| "music"` | no | Default prompt. |
| `body.name` | `string` | no | Default: “Prompt” / “Music” with the time. |
| `body.text` | `string` | no | What the recording says. |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const audioAsset = await mv.audioAssets.create({
	file: {
		content_base64: "UklGRiQAAABXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YQAAAAA=",
		filename: "welcome.wav",
	},
	kind: "prompt",
	name: "Welcome (Hebrew)",
	text: "שלום, הגעתם ל…",
});
console.log(audioAsset);
```

## `delete()`

**Delete an audio asset.** Refused (409) while a flow (draft or a published version) or a queue's hold audio uses it; `details.used_by` lists them.

```ts
mv.audioAssets.delete(id: AudioAssetsDeleteData["path"]["id"], options?: RequestOptions): Promise<AudioAssetsDeleteResponse>
```

`DELETE /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A audio asset ID (`aud_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`DeletedAudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `deleted` | `true` | — |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const deletedAudioAsset = await mv.audioAssets.delete("aud_7Hk2Lm9Qp");
console.log(deletedAudioAsset);
```

## `list()`

**List audio assets.** Returns a page of `AudioAsset` objects, newest first. Pass `next_cursor` as `starting_after` for the next page; the SDKs iterate every page for you.

```ts
mv.audioAssets.list(query?: NonNullable<AudioAssetsListData["query"]>, options?: RequestOptions): PagedList<AudioAssetsListResponse["data"][number], NonNullable<AudioAssetsListData["query"]>>
```

`GET /audio_assets` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query.limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `query.starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `query.ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `query.kind` | `string` | no | Only prompts or only music. |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

A [`PagedList`](https://docs.morevoice.ai/sdk/typescript/pagination/): `await` it for the first page, `for await` it for every item.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

for await (const audioAsset of mv.audioAssets.list()) {
	console.log(audioAsset);
}
```

## `retrieve()`

**Retrieve an audio asset.** Returns the `AudioAsset` object. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```ts
mv.audioAssets.retrieve(id: AudioAssetsRetrieveData["path"]["id"], options?: RequestOptions): Promise<AudioAssetsRetrieveResponse>
```

`GET /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A audio asset ID (`aud_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const audioAsset = await mv.audioAssets.retrieve("aud_7Hk2Lm9Qp");
console.log(audioAsset);
```

## `retrieveContent()`

**Download an audio asset.** The recording as a WAV file (mono 16-bit PCM at its stored rate).

```ts
mv.audioAssets.retrieveContent(id: AudioAssetsRetrieveContentData["path"]["id"], options?: RequestOptions): Promise<AudioAssetsRetrieveContentResponse>
```

`GET /audio_assets/{id}/content` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_retrieve_content/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A audio asset ID (`aud_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

Nothing, on success.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const data = await mv.audioAssets.retrieveContent("aud_7Hk2Lm9Qp");
console.log(data);
```

## `update()`

**Rename an audio asset.** Changes the name or the text (what it says). To replace the audio, upload a new asset.

```ts
mv.audioAssets.update(id: AudioAssetsUpdateData["path"]["id"], body?: AudioAssetsUpdateData["body"], options?: RequestOptions): Promise<AudioAssetsUpdateResponse>
```

`PATCH /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_update/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A audio asset ID (`aud_…`). |
| `body.name` | `string` | no |  |
| `body.text` | `string` | no |  |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const audioAsset = await mv.audioAssets.update("aud_7Hk2Lm9Qp", {
	name: "Welcome (Hebrew, v2)",
});
console.log(audioAsset);
```
