Skip to main content
View as Markdown

Caption Asset CRUD - Content Management

Caption Asset CRUD​

A KalturaCaptionAsset represents a subtitle or caption file attached to a media entry. Caption creation is a two-step process: first create the asset metadata (captionAsset.add), then upload the content (captionAsset.setContent).

KalturaCaptionAsset Object​

FieldTypeDescription
idstringAuto-generated asset ID (read-only)
entryIdstringMedia entry this caption belongs to
labelstringDisplay label (e.g., "English", "Spanish CC")
languagestringLanguage from KalturaLanguage enum (e.g., "English")
languageCodestringISO 639 code, auto-derived from language (read-only)
formatintegerCaption format: 1=SRT, 2=DFXP, 3=WebVTT, 4=CAP, 5=SCC (insertOnly)
statusintegerAsset status (see 3.2)
isDefaultbooleanWhether this is the default caption for the entry
accuracyintegerAccuracy percentage (for machine-generated captions)
displayOnPlayerbooleanWhether the player shows this caption track
captionParamsIdintegerCaption parameter template ID (insertOnly)
sourceintegerOrigin: 0=UNKNOWN, 1=ZOOM, 2=WEBEX (insertOnly)
parentIdstringParent caption asset ID (insertOnly, for derived captions)
associatedTranscriptIdsstringComma-separated IDs of linked transcript assets
usageinteger0=CAPTION, 1=EXTENDED_AUDIO_DESCRIPTION
sizeintegerFile size in bytes (read-only)
versionintegerVersion number (read-only)
partnerIdintegerPartner ID (read-only)
createdAtintegerUnix timestamp (read-only)
updatedAtintegerUnix timestamp (read-only)
objectTypestringAlways "KalturaCaptionAsset" (read-only)

Caption Status Values​

ValueNameDescription
-1ERRORProcessing error
0QUEUEDQueued for processing
2READYReady for use
3DELETEDSoft-deleted
7IMPORTINGBeing imported from URL
9EXPORTINGBeing exported

Create Caption Asset​

POST /service/caption_captionAsset/action/add
curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/add" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "entryId=$KALTURA_ENTRY_ID" \
-d "captionAsset[objectType]=KalturaCaptionAsset" \
-d "captionAsset[label]=English" \
-d "captionAsset[language]=English" \
-d "captionAsset[format]=1" \
-d "captionAsset[isDefault]=1"
ParameterTypeRequiredDescription
entryIdstringYesMedia entry ID
captionAsset[objectType]stringYesAlways KalturaCaptionAsset
captionAsset[label]stringNoDisplay label
captionAsset[language]stringYesLanguage (KalturaLanguage enum value)
captionAsset[format]integerNo1=SRT (default), 2=DFXP, 3=WEBVTT, 4=CAP, 5=SCC. insertOnly — set at creation time, remains fixed.
captionAsset[isDefault]booleanNoSet as default caption for the entry
captionAsset[captionParamsId]integerNoTemplate ID — language and label auto-copied from template

Response: KalturaCaptionAsset object with generated id and status=0 (QUEUED). The format defaults to SRT (1) if not specified.

{
"id": "1_abc123de",
"entryId": "0_xyz789ab",
"partnerId": 1234567,
"label": "English",
"language": "English",
"languageCode": "en",
"format": 1,
"status": 0,
"isDefault": true,
"displayOnPlayer": true,
"accuracy": 0,
"size": 0,
"version": 0,
"createdAt": 1712620800,
"updatedAt": 1712620800,
"objectType": "KalturaCaptionAsset"
}

Upload Content (Inline String)​

After creating the asset, upload the caption content using KalturaStringResource for small files (<1 MB):

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/setContent" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "id=$CAPTION_ASSET_ID" \
-d "contentResource[objectType]=KalturaStringResource" \
--data-urlencode 'contentResource[content]=1
00:00:00,000 --> 00:00:05,000
Welcome to the presentation.

2
00:00:05,000 --> 00:00:10,000
Today we cover the Kaltura API.'
ParameterTypeRequiredDescription
idstringYesCaption asset ID (from captionAsset.add)
contentResource[objectType]stringYesKalturaStringResource for inline content
contentResource[content]stringYesCaption file content (URL-encode for special characters)

Response: Updated KalturaCaptionAsset object. Status transitions to 2 (READY) after processing.

{
"id": "1_abc123de",
"entryId": "0_xyz789ab",
"partnerId": 1234567,
"label": "English",
"language": "English",
"languageCode": "en",
"format": 1,
"status": 2,
"isDefault": true,
"displayOnPlayer": true,
"size": 142,
"version": 1,
"createdAt": 1712620800,
"updatedAt": 1712620860,
"objectType": "KalturaCaptionAsset"
}

Upload Content (Upload Token)​

For larger files, use the three-step upload token flow:

# Step 1: Create upload token
curl -X POST "$KALTURA_SERVICE_URL/service/uploadToken/action/add" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "uploadToken[objectType]=KalturaUploadToken"

# Step 2: Upload file to token
curl -X POST "$KALTURA_SERVICE_URL/service/uploadToken/action/upload" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "uploadTokenId=$UPLOAD_TOKEN_ID" \
-F "fileData=@captions.srt"

# Step 3: Attach to caption asset
curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/setContent" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "id=$CAPTION_ASSET_ID" \
-d "contentResource[objectType]=KalturaUploadedFileTokenResource" \
-d "contentResource[token]=$UPLOAD_TOKEN_ID"
ParameterTypeRequiredDescription
idstringYesCaption asset ID (from captionAsset.add)
contentResource[objectType]stringYesKalturaUploadedFileTokenResource for upload token
contentResource[token]stringYesUpload token ID (from uploadToken.upload)

See Upload & Ingestion API for upload token details.

Upload Content (Remote URL)​

Server fetches caption from a URL. Creates an async import job:

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/setContent" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "id=$CAPTION_ASSET_ID" \
-d "contentResource[objectType]=KalturaUrlResource" \
-d "contentResource[url]=https://example.com/captions/english.srt"
ParameterTypeRequiredDescription
idstringYesCaption asset ID (from captionAsset.add)
contentResource[objectType]stringYesKalturaUrlResource for remote URL import
contentResource[url]stringYesDirect URL to the caption file

Status transitions to 7 (IMPORTING) during fetch, then 2 (READY) on completion.

Get Caption Asset​

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/get" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "captionAssetId=$CAPTION_ASSET_ID"
ParameterTypeRequiredDescription
captionAssetIdstringYesCaption asset ID to retrieve

Response: Full KalturaCaptionAsset object. Use to poll for status after setContent.

List Caption Assets​

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/list" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "filter[objectType]=KalturaAssetFilter" \
-d "filter[entryIdEqual]=$KALTURA_ENTRY_ID"
ParameterTypeRequiredDescription
filter[objectType]stringYesKalturaAssetFilter or KalturaCaptionAssetFilter
filter[entryIdEqual]stringRecommendedFilter by entry ID
pager[pageSize]integerNoResults per page (default 30, max 500)
pager[pageIndex]integerNoPage number (1-based, default 1)

Filter fields (KalturaCaptionAssetFilter):

FieldDescription
entryIdEqual / entryIdInFilter by entry ID (recommended)
formatEqual / formatInFilter by caption format
statusEqual / statusIn / statusNotInFilter by status
captionParamsIdEqual / captionParamsIdInFilter by template
sizeGreaterThanOrEqual / sizeLessThanOrEqualFilter by file size
createdAtGreaterThanOrEqual / createdAtLessThanOrEqualDate range
updatedAtGreaterThanOrEqual / updatedAtLessThanOrEqualDate range
tagsLikeTag-based search
orderBy+size, -size, +createdAt, -createdAt

Response:

{
"totalCount": 2,
"objects": [
{
"id": "1_abc123",
"entryId": "0_abc123",
"label": "English",
"language": "English",
"languageCode": "en",
"format": 1,
"status": 2,
"isDefault": true,
"objectType": "KalturaCaptionAsset"
}
],
"objectType": "KalturaCaptionAssetListResponse"
}

Update Caption Asset​

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/update" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "id=$CAPTION_ASSET_ID" \
-d "captionAsset[objectType]=KalturaCaptionAsset" \
-d "captionAsset[label]=English (Corrected)"
ParameterTypeRequiredDescription
idstringYesCaption asset ID
captionAsset[objectType]stringYesAlways KalturaCaptionAsset
captionAsset[label]stringNoUpdated label
captionAsset[language]stringNoUpdated language
captionAsset[isDefault]booleanNoUpdate default status

Response: Updated KalturaCaptionAsset object.

{
"id": "1_abc123de",
"entryId": "0_xyz789ab",
"partnerId": 1234567,
"label": "English (Corrected)",
"language": "English",
"languageCode": "en",
"format": 1,
"status": 2,
"isDefault": true,
"displayOnPlayer": true,
"size": 142,
"version": 2,
"createdAt": 1712620800,
"updatedAt": 1712621400,
"objectType": "KalturaCaptionAsset"
}

The format field is insertOnly — set it at creation time, as it remains fixed for the lifetime of the asset.

Set as Default Caption​

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/setAsDefault" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "captionAssetId=$CAPTION_ASSET_ID"
ParameterTypeRequiredDescription
captionAssetIdstringYesCaption asset ID to set as default

Marks this caption asset as the default for its entry. Automatically unsets the previous default. Returns no response body on success.

Delete Caption Asset​

curl -X POST "$KALTURA_SERVICE_URL/service/caption_captionAsset/action/delete" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "captionAssetId=$CAPTION_ASSET_ID"
ParameterTypeRequiredDescription
captionAssetIdstringYesCaption asset ID to delete

Returns no response body on success. The caption asset status transitions to 3 (DELETED).