Upload Caption Track
youtube_upload_captionUpload a caption track to a YouTube video from a local file. Specify video ID, language, name, and file path.
Instructions
Upload a new caption track to a YouTube video from a local file.
The file is streamed directly from disk via fs.createReadStream. The MIME type
is inferred from the file extension (.vtt → text/vtt, .srt → application/x-subrip,
.sbv → text/x-google-video-subtitle, .ttml → application/ttml+xml).
Args
videoId(string, required): The video ID to attach the caption track to.language(string, required): BCP-47 language tag for the track (e.g. "en", "fr-CA").name(string, required): A human-readable display name for the track (e.g. "English (CC)").filePath(string, required): Absolute local path to the caption file (.vtt, .srt, .sbv, .ttml).isDraft(boolean, default false): Whether to upload the track as a draft (not publicly visible).
Returns
{
"id": "string",
"videoId": "string",
"language": "string",
"name": "string",
"trackKind": "string",
"isDraft": boolean
}Examples
Upload an English SRT:
videoId="dQw4w9WgXcQ", language="en", name="English", filePath="/captions/en.srt"Upload as draft:
videoId="dQw4w9WgXcQ", language="es", name="Spanish", filePath="/captions/es.vtt", isDraft=true
Errors
400: Invalid language tag or file format not supported.
403: You can only add captions to videos on your own channel. Check scopes (
youtube.force-ssl).404: Video not found.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| videoId | Yes | The video ID to attach the new caption track to. | |
| language | Yes | BCP-47 language tag for the track (e.g. "en", "fr-CA"). | |
| name | Yes | Human-readable display name for the track (e.g. "English (CC)"). | |
| filePath | Yes | Absolute local path to the caption file (.vtt, .srt, .sbv, .ttml). | |
| isDraft | No | Upload the track as a draft (not publicly visible). Default false. |