Edit an existing caption track on a Mux asset with the Mux Robots API. Use find-and-replace rules to fix terms, or censor profanity with an LLM.
Edit an existing text track on a Mux asset. The workflow supports three kinds of edits — static word/phrase replacements, speaker label renames via speaker_replacements, and LLM-driven profanity censoring via auto_censor_profanity — and you can combine them in a single job. By default the edited captions replace the original track, keeping its name. See Managing existing tracks. See the Edit Captions API referenceAPI for the full endpoint specification. See Mux Robots pricing for unit costs.
Check the shared workflow prerequisites before creating a job.
Caption editing requires an existing, ready text track on the asset. Add captions first, either auto-generated or manually added, before creating an edit-captions job. You must provide at least one of replacements, speaker_replacements, or auto_censor_profanity.
edit-captions jobcurl https://api.mux.com/robots/v1/jobs/edit-captions \
-H "Content-Type: application/json" \
-X POST \
-d '{
"parameters": {
"asset_id": "YOUR_ASSET_ID",
"track_id": "YOUR_TRACK_ID",
"replacements": [
{ "find": "Mucks", "replace": "Mux", "case_sensitive": true },
{ "find": "gonna", "replace": "going to" }
],
"auto_censor_profanity": {
"mode": "blank"
}
}
}' \
-u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}This request is asynchronous. The POST returns immediately with the job in pending status and does not include results. We strongly recommend listening for the robots.v1.job.edit_captions.completed webhook — the payload contains the full completed job, so no follow-up API call is needed. If webhooks aren't an option, you can poll GET /robots/v1/jobs/edit-captions/{JOB_ID} with the id from the response until the status is completed.
| Parameter | Type | Description |
|---|---|---|
asset_id | string | Required. The Mux asset ID whose existing text track should be edited. |
track_id | string | Required. Mux text track ID of the source captions. Must identify a ready subtitle track, or the single ready legacy text transcript without subtitle metadata on an audio-only asset. A missing or unready source is rejected. |
auto_censor_profanity | object | Optional LLM-driven profanity detection and censorship rules applied to the selected caption track. |
replacements | array of object | Optional static word or phrase replacements applied directly to cue text. |
speaker_replacements | array of object | Optional replacements for bracketed speaker labels at the start of caption cues. Values omit the surrounding square brackets, and matching spoken text is not changed. |
upload_to_mux | boolean | Whether to upload the edited VTT back to the Mux asset as a text track. Defaults to true. |
replace_existing_tracks | string | What to do with the source track. Defaults to replace: the source is deleted and the edited track takes its place under the same name, language and closed-captions setting; no other track is touched, and the source is restored if the edited track can't be added. fail deletes nothing and adds the edited track alongside the source, so it requires a track_name different from the source's. Either way the request is rejected if a track other than the source already has the edited track's name. replace requires upload_to_mux to be true. |
track_name | string | Name for the edited Mux text track. Defaults to the source track's name. Required and must differ from the source's name when replace_existing_tracks is fail. Mux requires text track names to be unique on an asset. |
auto_censor_profanity
| Field | Type | Description |
|---|---|---|
detection_method | string | How profanity is detected. Currently only llm is supported, which uses an LLM to identify profanity in cue text. Defaults to "llm". |
mode | string | Replacement strategy for detected profanity: blank inserts bracketed underscores, remove drops the match, and mask replaces characters with question marks. Defaults to "blank". |
always_censor | array of string | Additional words or short phrases that should always be censored even if the model does not detect them. |
never_censor | array of string | Words or short phrases that should never be censored even if the model flags them. |
replacements[]
| Field | Type | Description |
|---|---|---|
find | string | Required. Exact word or phrase to replace in cue text. |
replace | string | Required. Replacement text to insert when a match is found. Use an empty string to delete the match. |
case_sensitive | boolean | When true, find is matched only with exact case. Defaults to false (case-insensitive matching), so "gonna" also matches "Gonna" and "GONNA". |
speaker_replacements[]
| Field | Type | Description |
|---|---|---|
find | string | Required. Existing speaker label without the surrounding square brackets. Must match the label in the track exactly, including case. |
replace | string | Required. New speaker label without the surrounding square brackets. |
Each entry in replacements is applied to every cue in the source track.
Use speaker_replacements to rename speakers, for example in captions generated by generate premium captions with speaker diarization (include_speakers). Each entry renames a bracketed label at the start of a cue. Spoken text that contains the same words isn't changed.
Labels can't contain square brackets or line breaks.
{
"speaker_replacements": [
{ "find": "speaker_0", "replace": "Alice" },
{ "find": "speaker_1", "replace": "Bob" }
]
}Use auto_censor_profanity to detect and replace profane terms automatically.
The outputs object is included once the job's status is completed. You'll receive it on the robots.v1.job.edit_captions.completed webhook (recommended), or you can fetch it with GET /robots/v1/jobs/edit-captions/{JOB_ID}. It contains:
| Field | Type | Description |
|---|---|---|
total_replacement_count | integer | Required. Total count of cue text replacements applied across all edit operations. |
temporary_vtt_url | string | Temporary pre-signed URL for downloading the edited VTT file. Expires 7 days after the job completes. |
track_id | string | Mux text track ID of the newly created edited captions, distinct from the source parameters.track_id. Present when upload_to_mux is true and the upload succeeds. |
replaced_track_ids | array of string | IDs of tracks deleted during replacement. Omitted when no deletions were recorded; historical jobs may lack this information. |
This is the job delivered in the robots.v1.job.edit_captions.completed webhook's data field and returned by GET /robots/v1/jobs/edit-captions/{JOB_ID}:
{
"data": {
"id": "rjob_example123",
"workflow": "edit-captions",
"status": "completed",
"units_consumed": 500,
"created_at": 1746403200,
"updated_at": 1746403260,
"parameters": {
"asset_id": "mux_asset_123abc",
"track_id": "text_track_456def",
"replacements": [
{ "find": "Mucks", "replace": "Mux", "case_sensitive": true },
{ "find": "gonna", "replace": "going to" }
],
"upload_to_mux": true,
"replace_existing_tracks": "replace"
},
"outputs": {
"total_replacement_count": 5,
"track_id": "text_track_789ghi",
"temporary_vtt_url": "https://s3.example.com/edited.vtt?sig=abc",
"replaced_track_ids": ["text_track_456def"]
}
}
}When upload_to_mux is true (the default), the edited caption track is attached to your asset. By default it replaces the original, so viewers see the corrected captions in the player's caption menu.
Use replace_existing_tracks to choose what happens to the source track when the edit is uploaded.
| Value | Behavior |
|---|---|
replace (default) | The source track is deleted and the edited track takes its place, with the same name, language, and closed-captions setting. |
fail | Nothing is deleted. The edited track is added alongside the source, so it needs a track_name different from the source's. |
replace requires upload_to_mux to be true.replace, if the edited track can't be added, Mux attempts to restore the source under a new track ID and the job errors. Restoration is best-effort and can also fail.outputs.replaced_track_ids.422. If a conflicting track is added while the job runs, the job errors instead. Neither case is billed.