> 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.

# Update audio / subtitle track

PATCH https://api.fastpix.com/v1/on-demand/{mediaId}/tracks/{trackId}
Content-Type: application/json

This endpoint allows you to update an existing audio or subtitle track associated with a media file. When updating a track, you must provide the new `languageName` and `languageCode`, ensuring both parameters are included in the request. You can optionally provide a `title` for the track.

#### How it works

1. Send a PATCH request to this endpoint, replacing `{mediaId}` with the media ID, and `{trackId}` with the ID of the track you want to update.

2. Provide the necessary details in the request body.

3. Receive a response confirming the track update.

#### Webhook Events

After updating a track, your system must receive webhook notifications:

1. After successfully updating a track, your system must receive the webhook event video.media.track.updated.

2. Once the new track is processed and ready, you must receive the webhook event video.media.track.ready.

3. Once the media file is updated with the new track details, a video.media.updated event must be triggered.

#### Example

Suppose you previously added a French subtitle track to a video but now need to update it with a different file. By calling this API, you can replace the existing subtitle file (.vtt) with a new one while keeping the same track ID. This is useful when:

* The original track file has errors and needs correction.
* You want to improve subtitle translations or replace an audio track with a better-quality version.

Related guides: Add own subtitle tracks, Add own audio tracks

Reference: https://fastpix.com/docs/video-on-demand-api/manage-videos/update-media-track

## Authentication

- `Authorization` header (basic auth, required) — FastPix APIs are secured with Basic Authentication. Use your Access Token ID as the username and Secret Key as the password in the Authorization header of each API request. * Username: Access Token ID * Password: Secret Key Activate your FastPix account to generate your API credentials. See the guide here

## Request

### Path parameters

- `trackId` (string, required) — The unique identifier assigned to the media when created. The value must be a valid UUID.
- `mediaId` (string, required) — The unique identifier assigned to the media when created. The value must be a valid UUID.

### Body (application/json)

This endpoint expects an UpdateTrackRequest.

- `languageCode` (string, required, default: fr) — The BCP 47 language code representing the track’s language.
- `languageName` (string, required, default: French) — The full name of the language corresponding to the `languageCode`.
- `title` (string, optional) — Title of the track.

## Response

### 200

Media details updated successfully

- `success` (boolean, optional) — Demonstrates whether the request is successful or not.
- `data` (UpdateTrackResponse, optional) — Contains details about the track that was added or updated.

## Types

### UpdateTrackResponse

Contains details about the track that was added or updated.

- `id` (string, optional) — The unique identifier of the track.
- `type` (enum, optional) — Specifies the type of track (audio or subtitle).
  - Allowed values: `audio`, `subtitle`
- `url` (string, optional) — The direct URL of the track file.
- `languageCode` (string, optional) — The BCP 47 language code representing the track's language.
- `languageName` (string, optional) — The full name of the language corresponding to the `languageCode`.
- `title` (string, optional) — Title of the track.

## Examples

**Request**

```json
{
  "languageCode": "fr",
  "languageName": "french",
  "title": "French subtitles"
}
```

**Response**

```json
{
  "success": true,
  "data": {
    "id": "2452ca23-b7ed-4daf-babf-841996b0100e",
    "type": "subtitle",
    "url": "http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.vtt",
    "languageCode": "fr",
    "languageName": "french",
    "title": "French subtitles"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6"

payload = {
    "languageCode": "fr",
    "languageName": "french",
    "title": "French subtitles"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'PATCH',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"languageCode":"fr","languageName":"french","title":"French subtitles"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6"

	payload := strings.NewReader("{\n  \"languageCode\": \"fr\",\n  \"languageName\": \"french\",\n  \"title\": \"French subtitles\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"languageCode\": \"fr\",\n  \"languageName\": \"french\",\n  \"title\": \"French subtitles\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"languageCode\": \"fr\",\n  \"languageName\": \"french\",\n  \"title\": \"French subtitles\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6', [
  'body' => '{
  "languageCode": "fr",
  "languageName": "french",
  "title": "French subtitles"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.PATCH);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"languageCode\": \"fr\",\n  \"languageName\": \"french\",\n  \"title\": \"French subtitles\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "languageCode": "fr",
  "languageName": "french",
  "title": "French subtitles"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/4fa85f64-5717-4562-b3fc-2c963f66afa6")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```