> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Add audio to a video

Reaching a global audience means offering audio in multiple languages, but re-encoding and re-uploading the entire video for each locale wastes time and storage. FastPix lets you attach, update, and delete audio tracks on an existing On-Demand Video through the `/on-demand/{mediaId}/tracks` endpoint. HLS manifests expose each track automatically, so viewers can switch languages in the player without any extra client-side work.

\


## Prerequisites

* A FastPix account with an active workspace ([Activate your account](/getting-started/activate-your-account))
* Your **Access Token ID** and **Secret Key** from the FastPix dashboard → API Settings
* An existing on-demand video and its `mediaId`
* A publicly accessible audio file in MP3, AAC, WAV, or OGG format

\


## Key terms

* **`mediaId`** - The unique identifier FastPix assigns to every uploaded on-demand video.
* **`trackId`** - The identifier FastPix returns when you add an audio track. Pass it back in update and delete calls.
* **`languageCode`** - A BCP 47 language tag (for example, `en`, `fr`, `es-419`) that players use to label and select a track.
* **`accessPolicy`** - `public` or `private`. Track operations inherit the parent media's access policy.

\


## Language code support (BCP 47)

FastPix follows **BCP 47** language codes for audio and subtitle tracks. When you add or update a track, set `languageCode` in this format so HLS manifests expose the correct `LANGUAGE` attribute and players can surface an accurate language picker.

Examples:

* `en` - English
* `en-US` - English (United States)
* `fr` - French
* `es-419` - Spanish (Latin America)
* `hi` - Hindi

See the [BCP 47 specification](https://en.wikipedia.org/wiki/IETF_language_tag#List_of_common_primary_language_subtags) for the full list of primary language subtags.

\


## Add an audio track

Send a `POST` request to attach a new audio track to an existing media. Pass the `mediaId` in the path and the audio file URL, type, and language in the request body. See the [add media track reference](/video-on-demand-api/manage-videos/add-media-track) for the full contract.

**`POST`**

```Text POST
https://api.fastpix.com/v1/on-demand/{mediaId}/tracks
```

Subscribe to the [video.media.track.ready](/webhooks/transform-media-events#videomediatrackready) and [video.media.track.created](/webhooks/transform-media-events#videomediatrackcreated) webhook events to know when the track is created and ready for playback.

**Request body**:

**`Request`**

```json Request
{
  "tracks": {
    "url": "https://static.fastpix.com/music-1.mp3",
    "type": "audio",
    "languageCode": "en",
    "languageName": "English"
  }
}
```

> **NOTE**
>
> * FastPix supports **MP3**, **AAC**, **WAV**, and **OGG** formats for audio tracks.
> * The `url` must point to a publicly accessible audio file.
> * Set `languageCode` using a BCP 47 tag for accurate localization.

**Response example**:

```json
{
  "success": true,
  "data": {
    "id": "ce926a2b-5448-4d39-88ab-d33641379a45",
    "type": "audio",
    "url": "https://static.fastpix.com/music-1.mp3",
    "languageCode": "en",
    "languageName": "English"
  }
}
```

Store the returned `id` as the `trackId`, you need it for update and delete calls.

\


> **TIP:** You can also add an audio track from the dashboard, with no code. See [Add tracks to a video from the dashboard](/video-on-demand/add-tracks-from-the-dashboard).

\


## Update an audio track

Send a `PATCH` request to change a track's source file or language metadata without creating a new `trackId`. See the [update media track reference](/video-on-demand-api/manage-videos/update-media-track).

**`PATCH`**

```text PATCH
https://api.fastpix.com/v1/on-demand/{mediaId}/tracks/{trackId}
```

Subscribe to the [video.media.track.updated](/webhooks/transform-media-events#videomediatrackready) webhook event to know when the updated track is re-processed and ready.

**Request body**:

**`Request`**

```json Request
{
  "url": "https://static.fastpix.com/music-2.mp3",
  "languageCode": "fr",
  "languageName": "French"
}
```

> **NOTES**
>
> * The new `url` must point to a valid, publicly accessible audio file.
> * Use the `trackId` of the track you want to update.
> * Set `languageCode` using a BCP 47 tag.

**Response example**:

**`Response`**

```json Response
{
  "success": true,
  "data": {
    "id": "ce926a2b-5448-4d39-88ab-d33641379a45",
    "type": "audio",
    "url": "https://static.fastpix.com/music-2.mp3",
    "languageCode": "fr",
    "languageName": "French"
  }
}
```

\


## Delete an audio track

Send a `DELETE` request to remove an audio track from a video. See the [delete media track reference](/video-on-demand-api/manage-videos/delete-media-track).

**`DELETE`**

```Text DELETE
https://api.fastpix.com/v1/on-demand/{mediaId}/tracks/{trackId}
```

**Response example**:

**`Response`**

```json Response
{
  "success": "true"
}
```

> **NOTES**
>
> * Deletion is permanent and cannot be undone.
> * Provide the correct `trackId` for the audio file you want to remove.

\


#### Frequently asked questions

The original audio muxed into the source video stays the default. Tracks you add through this endpoint appear as alternate audio tracks in the HLS manifest, and most HLS-compatible players let viewers switch tracks from a language menu.

FastPix exposes each audio track in the HLS manifest with the `LANGUAGE` attribute set from `languageCode`. The FastPix Player and other HLS players render these as selectable options in the track menu with no extra configuration.

FastPix accepts BCP 47 tags such as `en`, `en-US`, `fr`, `de`, `es-419`, and `hi`. Tags that do not match BCP 47 are rejected at track creation.

Yes. Use [Replace existing audio](/video-on-demand/replace-a-videos-audio-track) to overwrite the primary audio on a media. Use the track endpoints on this page when you want to keep the original and add additional language tracks.

\


## What's next?

* [Replace existing audio with new audio](/video-on-demand/replace-a-videos-audio-track)
* [Overlay audio at a specific timeline](/video-on-demand/overlay-audio-on-a-video-timeline)
* [API reference: Add media track](/video-on-demand-api/manage-videos/add-media-track)
* [API reference: Update media track](/video-on-demand-api/manage-videos/update-media-track)
* [API reference: Delete media track](/video-on-demand-api/manage-videos/delete-media-track)

For additional questions, reach out to the [FastPix support team](https://www.fastpix.io/technical-support).