<commit_before><!--METADATA
{
  "icon": "cc",
  "sortOrder": 90,
  "tags": [
    "captionAsset",
    "uploadToken"
  ],
  "keywords": [],
  "summary": "Learn how to serve a WebVTT caption"
}
-->

# Serve WebVTT Captions


## Getting Caption Assets
Use `captionAsset.list` to retrieve a list of Caption Assets

### API Call
```json
{
  "method": "get",
  "path": "/service/caption_captionasset/action/list",
  "parameters": [
    {
      "name": "filter[entryIdEqual]",
      "dynamicEnum": {
        "path": "/service/media/action/list",
        "method": "get",
        "array": "objects",
        "value": "id",
        "label": "name"
      }
    }
  ]
}
```

## Uploading Captions - Create an Upload Token
Use the uploadToken service to upload an WebVTT file to the Kaltura API. If you don't have an WebVTT file handy, you can [download one here](/sample_captions.srt)

First you'll need to use `uploadToken.add` to create a new upload token. In the next step we'll use this token to upload the WebVTT data.

### API Call
```json<commit_msg>Update workflow: webvtt_captions<commit_after><!--METADATA
{
  "icon": "cc",
  "sortOrder": 90,
  "tags": [
    "captionAsset",
    "uploadToken"
  ],
  "keywords": [],
  "summary": "Learn how to serve a WebVTT caption"
}
-->

# Serve WebVTT Captions


## Getting Caption Assets
Use `captionAsset.list` to retrieve a list of Caption Assets

### API Call
```json
{
  "method": "get",
  "path": "/service/caption_captionasset/action/list",
  "parameters": [
    {
      "name": "filter[entryIdEqual]",
      "dynamicEnum": {
        "path": "/service/media/action/list",
        "method": "get",
        "array": "objects",
        "value": "id",
        "label": "name"
      }
    }
  ]
}
```

## Uploading Captions - Create an Upload Token
Use the uploadToken service to upload an WebVTT file to the Kaltura API. If you don't have an WebVTT file handy, you can [download one here](assets/sample_captions.srt)

First you'll need to use `uploadToken.add` to create a new upload token. In the next step we'll use this token to upload the WebVTT data.

### API Call
```json
{'fraction_non_alphanumeric': 0.1470449172576832, 'fraction_numerical': 0.0018912529550827422, 'mean_word_length': 3.1409001956947162, 'pattern_counts': {'":': 30, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2214829', 'n_tokens_mistral': 722, 'n_tokens_neox': 687, 'n_words': 227}