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

# Generate track subtitle

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

This endpoint allows you to generate subtitles for an existing audio track in a media file. By calling this API, you can generate subtitles automatically using speech recognition

#### How it works

1. Send a `POST` request to this endpoint, replacing `{mediaId}` with the media ID and `{trackId}` with the track ID.

2. Provide the necessary details in the request body, including the languageName and languageCode.

3. You receive a response containing a unique subtitle track ID and its details.

#### Webhook Events

1. After the subtitle track is generated and ready, you receive the webhook event video.media.subtitle.generated.

2. Finally the video.media.updated event notifies your system about the media’s updated status.

Related guide: Add auto-generated subtitles

Reference: https://fastpix.com/docs/video-on-demand-api/manage-videos/generate-subtitle-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

- `mediaId` (string, required) — The unique identifier assigned to the media when created. The value must be a valid UUID.
- `trackId` (string, required) — A universally unique identifier (UUID) assigned to the specific track for which subtitles must be generated.

### Body (application/json)

This endpoint expects a TrackSubtitlesGenerateRequest.

- `languageName` (string, required, default: English) — The full name of the language used to generate the subtitles.
- `languageCode` (enum, required, default: en-US) — Language code for content localization
  - Allowed values: `ar-SA`, `bn-BD`, `bn-IN`, `ca-ES`, `cs-CZ`, `da-DK`, `de-AT`, `de-CH`, `de-DE`, `el-GR`, `en-AU`, `en-CA`, `en-GB`, `en-IE`, `en-IN`, `en-NZ`, `en-US`, `en-ZA`, `es-AR`, `es-CL`, `es-CO`, `es-ES`, `es-MX`, `es-US`, `fi-FI`, `fr-BE`, `fr-CA`, `fr-CH`, `fr-FR`, `he-IL`, `hi-IN`, `hr-HR`, `hu-HU`, `id-ID`, `it-CH`, `it-IT`, `ja-JP`, `ko-KR`, `ms-MY`, `nb-NO`, `nl-BE`, `nl-NL`, `no-NO`, `pl-PL`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sk-SK`, `sv-SE`, `ta-IN`, `ta-LK`, `te-IN`, `th-TH`, `tr-TR`, `uk-UA`, `vi-VN`, `bg-BG`, `zh-CN`, `zh-HK`, `zh-TW`
- `metadata` (map from string to string, optional) — You can search for videos with specific key value pairs using metadata, when you tag a video in "key" : "value" pairs. Dynamic metadata allows you to define a key that allows any value pair. You can have maximum of 255 characters and upto 10 entries are allowed.
- `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` (GenerateTrackResponse, optional) — Represents the response for a successfully generated subtitle track.

## Types

### GenerateTrackResponse

Represents the response for a successfully generated subtitle track.

- `id` (string, optional) — A unique identifier for the generated track.
- `type` (enum, optional) — The type of track generated ("subtitle").
  - Allowed values: `subtitle`
- `languageCode` (enum, optional) — The BCP 47 language code representing the language of the generated track.
  - Allowed values: `ar-SA`, `bn-BD`, `bn-IN`, `ca-ES`, `cs-CZ`, `da-DK`, `de-AT`, `de-CH`, `de-DE`, `el-GR`, `en-AU`, `en-CA`, `en-GB`, `en-IE`, `en-IN`, `en-NZ`, `en-US`, `en-ZA`, `es-AR`, `es-CL`, `es-CO`, `es-ES`, `es-MX`, `es-US`, `fi-FI`, `fr-BE`, `fr-CA`, `fr-CH`, `fr-FR`, `he-IL`, `hi-IN`, `hr-HR`, `hu-HU`, `id-ID`, `it-CH`, `it-IT`, `ja-JP`, `ko-KR`, `nl-BE`, `nl-NL`, `no-NO`, `pl-PL`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sk-SK`, `sv-SE`, `ta-IN`, `ta-LK`, `th-TH`, `tr-TR`, `uk-UA`, `bg-BG`, `zh-CN`, `zh-HK`, `zh-TW`
- `languageName` (string, optional) — The full name of the language for the generated track.
- `metadata` (map from string to string, optional) — You can search for videos with specific key value pairs using metadata, when you tag a video in "key" : "value" pairs. Dynamic metadata allows you to define a key that allows any value pair. You can have maximum of 255 characters and upto 10 entries are allowed.
- `title` (string, optional) — Title of the track.

## Examples

**Request**

```json
{
  "languageName": "Italian",
  "languageCode": "it-IT",
  "title": "Italian subtitles"
}
```

**Response**

```json
{
  "success": true,
  "data": {
    "id": "ace60fc7-e876-4fc6-b9d9-c33fa242f84b",
    "type": "subtitle",
    "languageCode": "it-IT",
    "languageName": "Italian",
    "title": "Italian subtitles"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles"

payload = {
    "languageName": "Italian",
    "languageCode": "it-IT",
    "title": "Italian subtitles"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(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/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"languageName":"Italian","languageCode":"it-IT","title":"Italian 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/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles"

	payload := strings.NewReader("{\n  \"languageName\": \"Italian\",\n  \"languageCode\": \"it-IT\",\n  \"title\": \"Italian subtitles\"\n}")

	req, _ := http.NewRequest("POST", 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/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles")

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

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"languageName\": \"Italian\",\n  \"languageCode\": \"it-IT\",\n  \"title\": \"Italian 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.post("https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"languageName\": \"Italian\",\n  \"languageCode\": \"it-IT\",\n  \"title\": \"Italian subtitles\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fastpix.com/v1/on-demand/4fa85f64-5717-4562-b3fc-2c963f66afa6/tracks/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles', [
  'body' => '{
  "languageName": "Italian",
  "languageCode": "it-IT",
  "title": "Italian 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/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"languageName\": \"Italian\",\n  \"languageCode\": \"it-IT\",\n  \"title\": \"Italian 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 = [
  "languageName": "Italian",
  "languageCode": "it-IT",
  "title": "Italian 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/d46f5df9-1a8f-4f0a-b56e-9f5b5d5b9e21/generate-subtitles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```