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

# Add or replace a caption track

> Adds a caption track for the given language, or replaces the existing track for that language if one is already saved. This only ever touches the one language in the path: every other track on the video is left alone. Recompiles the player so the new track is live immediately.

Requires a token with the `videos:write` scope.



## OpenAPI

````yaml /api-reference/openapi.json put /videos/{video}/captions/{lang}
openapi: 3.1.0
info:
  title: TrackPlay API
  description: >-
    Send conversions and events to TrackPlay, and read them back. Authenticated
    with scoped tokens you mint in the dashboard.
  version: 1.0.0
servers:
  - url: https://app.trackplay.io/api/v1
    description: App API. Conversions, videos, webhooks.
  - url: https://e.trackplay.io
    description: Events API. High-volume event ingest.
security:
  - bearerAuth: []
tags:
  - name: Videos
    description: Create, read, update, and delete videos, and read workspace metadata.
  - name: Video settings
    description: Save a settings draft, publish it live, and read or restore past deploys.
  - name: Uploads
    description: >-
      Upload a source video file in one request or in resumable chunks, and poll
      its processing status.
  - name: Captions and chapters
    description: >-
      Manage caption tracks, chapter markers, AI-generated segments, and CTA
      cards on a video.
  - name: Playlists
    description: Group videos into a playlist or course, and manage the videos inside it.
  - name: Webhooks
    description: Subscribe a URL to TrackPlay lifecycle events and test deliveries.
  - name: Zapier
    description: >-
      The REST-hook endpoints Zapier calls to connect a workspace and manage
      triggers.
  - name: Analytics
    description: Read play, retention, event, and conversion analytics for a video.
  - name: Exports
    description: Queue and download bulk analytics exports.
  - name: Conversions
    description: Report a sale or a lead, from your own server or from a browser fallback.
  - name: Events
    description: Send a custom event tied to a viewer's session.
  - name: Identity
    description: Resolve a viewer's identity from the page, with no token required.
paths:
  /videos/{video}/captions/{lang}:
    put:
      tags:
        - Captions and chapters
      summary: Add or replace a caption track
      description: >-
        Adds a caption track for the given language, or replaces the existing
        track for that language if one is already saved. This only ever touches
        the one language in the path: every other track on the video is left
        alone. Recompiles the player so the new track is live immediately.


        Requires a token with the `videos:write` scope.
      operationId: putVideoCaptions
      parameters:
        - name: video
          in: path
          required: true
          schema:
            type: integer
          description: The video's numeric ID.
        - name: lang
          in: path
          required: true
          schema:
            type: string
          description: >-
            The language code for this track, e.g. `en` or `es`. Not validated
            against a fixed list: whatever you send is what viewers see as the
            track's key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CaptionsRequest'
      responses:
        '200':
          description: The video's full caption track list, including the track you wrote.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaptionsResponse'
        '401':
          description: >-
            `AUTH_REQUIRED`: no token sent. `INVALID_TOKEN`: the token is
            invalid, expired, or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: '`INSUFFICIENT_SCOPE`: the token does not carry `videos:write`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: No video with that ID exists in this workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LaravelNotFoundError'
        '422':
          description: Validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '429':
          description: Rate limited. 60 requests per minute per token.
components:
  schemas:
    CaptionsRequest:
      type: object
      required:
        - label
        - src
      properties:
        label:
          type: string
          maxLength: 64
          description: >-
            The display label shown in the player's caption menu, e.g.
            `English`.
        src:
          type: string
          maxLength: 8192
          description: Either a URL to a WebVTT file, or raw WebVTT text.
        default:
          type: boolean
          description: >-
            Selects this track by default when the player loads. Defaults to
            false.
    CaptionsResponse:
      type: object
      properties:
        captions:
          type: object
          properties:
            tracks:
              type: array
              items:
                $ref: '#/components/schemas/CaptionTrack'
    ApiError:
      type: object
      description: The error shape the app API returns on a failed read or export.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                A stable error code, e.g. `INSUFFICIENT_SCOPE`,
                `VIDEO_NOT_FOUND`, `EXPORT_NOT_FOUND`.
            message:
              type: string
              description: What went wrong, in plain English.
    LaravelNotFoundError:
      type: object
      description: >-
        The default not-found body Laravel returns when a route model lookup
        fails (`findOrFail`). It carries no stable error code, unlike the app's
        own `{"error": {"code": ...}}` shape used on hand-written error paths in
        this API.
      properties:
        message:
          type: string
          examples:
            - No query results for model [App\\Models\\WorkspaceVideo] 481
    ValidationError:
      type: object
      description: >-
        Laravel's default validation-failure body. `errors` maps each invalid
        field to its list of messages.
      properties:
        message:
          type: string
          examples:
            - The given data was invalid.
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
    CaptionTrack:
      type: object
      properties:
        lang:
          type: string
          description: The language code from the path, e.g. `en`.
        label:
          type: string
        src:
          type: string
        default:
          type: boolean
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A scoped token minted in **Settings → API tokens**. Send it as
        `Authorization: Bearer tplt_…` or `X-API-Key: tplt_…`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.