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

# Upload VTT File

> Upload VTT subtitle files to associate with existing video projects

Upload VTT (WebVTT) subtitle files to associate with your existing video projects for enhanced accessibility and translation workflows.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api-integration.ollang.com/integration/upload/vtt" \
    -H "X-Api-Key: <your-api-key>" \
    -H "Content-Type: multipart/form-data" \
    -F "file=@/path/to/your/subtitles.vtt" \
    -F "projectId=60b8d6f1e1b9b1d8c6c0d8e1" \
    -F "name=sample_subtitles"
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append("file", vttFile);
  formData.append("projectId", "60b8d6f1e1b9b1d8c6c0d8e1");
  formData.append("name", "sample_subtitles");

  const response = await fetch(
    "https://api-integration.ollang.com/integration/upload/vtt",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "<your-api-key>",
      },
      body: formData,
    },
  );
  ```

  ```python Python theme={null}
  import requests

  files = {'file': open('path/to/your/subtitles.vtt', 'rb')}
  data = {
      'projectId': '60b8d6f1e1b9b1d8c6c0d8e1',
      'name': 'sample_subtitles'
  }
  headers = {'X-Api-Key': '<your-api-key>'}

  response = requests.post(
      'https://api-integration.ollang.com/integration/upload/vtt',
      files=files,
      data=data,
      headers=headers
  )
  ```

  ```php PHP theme={null}
  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api-integration.ollang.com/integration/upload/vtt',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => array(
          'X-Api-Key: <your-api-key>'
      ),
    CURLOPT_POSTFIELDS => array(
      'file' => new CURLFile('path/to/your/subtitles.vtt'),
      'projectId' => '60b8d6f1e1b9b1d8c6c0d8e1',
      'name' => 'sample_subtitles'
    ),
  ));

  $response = curl_exec($curl);
  curl_close($curl);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "io"
      "mime/multipart"
      "net/http"
      "os"
  )

  func main() {
      file, _ := os.Open("path/to/your/subtitles.vtt")
      defer file.Close()

      body := &bytes.Buffer{}
      writer := multipart.NewWriter(body)

      part, _ := writer.CreateFormFile("file", "subtitles.vtt")
      io.Copy(part, file)

      writer.WriteField("projectId", "60b8d6f1e1b9b1d8c6c0d8e1")
      writer.WriteField("name", "sample_subtitles")
      writer.Close()

      req, _ := http.NewRequest("POST", "https://api-integration.ollang.com/integration/upload/vtt", body)
      req.Header.Set("X-Api-Key", "<your-api-key>")
      req.Header.Set("Content-Type", writer.FormDataContentType())

      client := &http.Client{}
      resp, _ := client.Do(req)
  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.post("https://api-integration.ollang.com/integration/upload/vtt")
    .header("X-Api-Key", "<your-api-key>")
    .field("file", new File("path/to/your/subtitles.vtt"))
    .field("projectId", "60b8d6f1e1b9b1d8c6c0d8e1")
    .field("name", "sample_subtitles")
    .asString();
  ```
</RequestExample>

## Authorizations

This endpoint requires API key authentication. Include your API key in the request header:

* **Header name**: `X-Api-Key`
* **Header value**: Your API key from the Ollang dashboard
* **Format**: `X-Api-Key: your-api-key-here`

You can obtain your API key from your [Ollang dashboard](https://lab.ollang.com).

## Body Parameters

<ParamField body="file" type="file" required>
  The VTT (WebVTT) subtitle file to upload. Only .vtt format is supported.
  Maximum file size: 1GB. **Note: For testing in the API playground, the upload
  limit is 5MB.**
</ParamField>

<ParamField body="projectId" type="string" required>
  Unique identifier for the project to associate this VTT file with. This should
  be an existing project ID from a previous video upload.
</ParamField>

<ParamField body="name" type="string" required>
  Name of the file being uploaded. This will be used as the identifier for your
  uploaded subtitle content.
</ParamField>

<ParamField body="sourceLanguage" type="string">
  The source language of the content in the uploaded file. Use one of the codes
  listed in [Supported Languages](/apis/ollang-api-reference/supported-languages).
  The special value `all` is also accepted for auto-detection workflows.
</ParamField>

## Response

<ResponseField name="projectId" type="string">
  Unique identifier for the project associated with the uploaded VTT file. This
  confirms the successful association of the subtitle file with the project.
</ResponseField>

<ResponseExample>
  ```json 201 theme={null}
  {
    "projectId": "60b8d6f1e1b9b1d8c6c0d8e1"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Invalid file format",
    "message": "Only VTT files are supported",
    "code": "INVALID_FILE_FORMAT"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "Project not found",
    "message": "No project found with the provided projectId",
    "code": "PROJECT_NOT_FOUND"
  }
  ```

  ```json 413 theme={null}
  {
    "error": "File too large",
    "message": "Maximum file size is 1GB",
    "code": "FILE_TOO_LARGE"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing API key",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseExample>
